Set-Item WSMan:localhost\client\trustedhosts -value * -Force
$cred=convertto-securestring -AsPlainText -Force -String $password
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "${ip}\${user}",$cred
$session = New-PSSession -ComputerName $ip -Credential $cred
Invoke-Command $session -ScriptBlock { Stop-WebAppPool -Name "test" }
Copy-Item -Path "d:\test\*" -Destination "c:\wwwroot\test" -ToSession $session -Recurse
Invoke-Command $session -ScriptBlock { Start-WebAppPool -Name "test" }
Invoke-Command $session -ScriptBlock {
wmic --% process where "name='node.exe' and CommandLine like '%test.js%'" get Name,CommandLine,ProcessId
ps
}
03-13