我想在下面执行powershell函数:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c (new-object System.Net.WebClient).DownloadFile('https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe','C:\Users\<User>\Downloads\putty.exe')
我已经在上面的主要cmd终端上使用了上面的powershell代码
但是
远程使用下面的cmd命令:
**cmd /c
我已经尝试了下面的代码,但是没有用:
cmd /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c (new-object System.Net.WebClient).DownloadFile('https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe','C:\Users\<User>\Downloads\putty.exe')
cmd /c powershell.exe -c (new-object System.Net.WebClient).DownloadFile('https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe','C:\Users\<User>\Downloads\putty.exe')
请,我需要解决方案。在此先感谢
为什么使用Powershell中的cmd代码?使用这个:
$wc = New-Object System.Net.Webclient; $wc.DownloadFile('The url', 'C:\Users\Downloads\Putty.exe')
要远程调用它,请使用此:
Invoke-Command -ComputerName TheComputerNameWhereToExecute -ScriptBlock {$wc = New-Object System.Net.Webclient; $wc.DownloadFile('The url', 'C:\Users\Downloads\Putty.exe')}