远程
WinRM 打开: Enable-PSRemoting -force
1 2 3 4 5 6 7 8
| Enter-PSSession -ComputerName XXXName -Credential domainxxx\userxx
Invoke-Command -ComputerName SErver01, SErver02 -ScriptBlock {...} Invoke-Command -ComputerName SErver01, SErver02 -FielPath c:\Scripts\...
$s = New-PSSession -ComputerName SErver01, SErver02 Invoke-Command -Session $s ...
|
远程编辑
- 使用vs code 中的powershell插件 ,进入其集成的PS环境,远程后调用psedit.
JOB
1 2 3 4 5 6 7 8 9 10 11
| Start-Job -ScriptBlock {...} $job = Get-Job -Id 1
Receive-Job -Job $job
Remove-Job -Job $job
$job.ChildJobs[0].JobStateInfo.Reason
Invoke-Command -ComputerName SErver01 -ScriptBlock {...} -asjob Invoke-Command -Session $s -ScriptBlock { start-job -ScriptBlock { ... }}
|