Public/MIT/Invoke-MITFileDownload.ps1
function Invoke-MITFileDownload { [CmdletBinding()] param ( [Parameter(Mandatory)] [string]$Id, [Parameter(Mandatory)] [string]$OutFile ) $hostname = $Script:MITHostname $token = $Script:MITToken $resource = "/files/$Id/download" $Uri = "https://$hostname/api/v1/$Resource" $Headers = @{ Accept = "application/octet-stream" Authorization = "Bearer $token" } $response = Invoke-RestMethod -Uri $Uri -Headers $Headers -OutFile $OutFile Write-Output $response } |