仮想サーバーの C:\windows からすべての .dll ファイルを新しい仮想サーバーにコピーしようとしています。すべての .dll ファイルを取得できましたが、それらを新しい仮想サーバーにコピーする方法が見つからず、Powershell でこれを行う方法を誰かが知っているかどうか疑問に思っていました。
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$server = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the server name with files you want to copy", "Server")
$server2 = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the server name you want files copied to", "Server")
$destinationName = ("\\" + $server2 + '\C$\windows')
$Files = Get-ChildItem -Path ("\\" + $server + '\C$\windows') -recurse | Where {$_.extension -eq ".dll"}
$Files 変数を新しい VM にコピーするには、どうすればよいですか? copy-item コマンドレットは知っていますが、それを使用してこれらすべてを新しい仮想サーバーに移動する方法を知りません。
編集:
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$server = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the server name with files you want to copy", "Server")
$server2 = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the server name you want files copied to", "Server")
$destinationName = ("\\" + $server2 + '\C$\windows')
$Files = Get-ChildItem -Path ("\\" + $server + '\C$\windows') -recurse | Where {$_.extension -eq ".dll"}
foreach($dll in $Files){
$destinationName +=
cp $dll.fullname $destinationName}
特定のファイルごとに、パスの文字列を「\$server2\C$\windows\ ..\ ..」にする必要があります。
現時点でコードを実行すると、すべてのファイル/ディレクトリが "\$server2\C$\windows" として表示され、フル パスが取得されません。