Set-ExecutionPolicy -ExecutionPolicy Bypass
$webServers = "remoteservername1"
$deploymentCredentials = Get-Credential
Invoke-Command -ComputerName $webServers -Credential $deploymentCredentials -ScriptBlock {
$appVersionDirectory = "C:\Test"
New-Item は問題なくディレクトリを作成します。
New-Item -ItemType directory -Path $appVersionDirectory
Copy-Item はエラーにはなりませんが、ファイルをコピーしません
この同じ Copy-Item コマンドをリモート サーバーで直接実行すると、機能します。
$sourceFiles = "\\sourceserver\DeploymentSource\shared\*"
Copy-Item $sourceFiles -Destination $appVersionDirectory
}