# Gather your information.
$email = "myEmail@website.com";
$password = "powershellR0cks!";
$subDomain = "****";
$url = "https://$subDomain.perfectomobile.com/services/repositories/media/PRIVATE:test.apk?operation=upload&user=$email&password=$password&overwrite=true";
$filePath = ".\test.apk";
# Make the request.
$response = Invoke-WebRequest -Uri $URL -Method Post -InFile $filePath -ContentType "application/octet-stream";
# Check for success.
if (-not ($response.StatusCode -eq 200)) {
throw "There was an error uploading the APK manifest.";
}
您可能需要检查
-ContentType
$response
HtmlWebResponseObject
它包含了响应的内容、状态代码和其他一些有用的信息。您可以通过运行
$response | Get-Member
最后
Invoke-WebRequest
cmdlet还有其他可能对您有用的参数,例如
-Credential
,
-Headers
,等等。
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1
顺便说一下,如果你跑
Get-Alias -Name "curl"
,你可以随时看到
curl
在PowerShell,你真的只是打电话
调用WebRequest
卷曲