远程主机执行powershell
1,需要再域环境中
2,需要用管理员权限运行powershell
2.1,开启Enable-PSRemoting -Force -SkipNetworkProfileCheck
2.2,开启set-executionpolicy remotesigned
3,执行代码
Invoke-Command -ComputerName [ServerName] -ScriptBlock {ipconfig}
4,{}中执行命令
5,本地传参
$Log = "PowerShellCore/Operational" Invoke-Command -ComputerName Server01 -ScriptBlock {Get-WinEvent -LogName $Using:Log -MaxEvents 10}