PowerShellでファイル送信

Add-Type -AssemblyName System.Web;

function UrlEnc($str){

return [System.Web.HttpUtility]::UrlEncode($str,[Text.Encoding]::UTF8);

}

$pmtlhost="http://localhost:8081/";

$access_token="";

$SrcFilePath="C:\Users\PCUSER\Desktop\!TEMP\v3.png";

$TargetFolder="D:\!TEMP\";

$FileName=[System.IO.Path]::GetFileName($SrcFilePath);

$TargetPathUrlEnc=UrlEnc($TargetFolder+$FileName);

$URi=$pmtlhost+"?target=pmtl_savefile&filepath="+ $TargetPathUrlEnc +"&access_token="+$access_token;

Invoke-RestMethod -Uri $URi -Method POST -InFile $SrcFilePath;