Sharepoint服務器PS Code
Enter-PSSession //一次執行即可
Enable-WSManCredSSP -Role Server -Force //一次執行即可
Client PS Code
Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.0.* //一次執行即可
$mypwd = convertto-securestring "sharepointserverpwd" -asplaintext -force
$mycreds = New-Object System.Management.Automation.PSCredential ("domain\username", $mypwd)
Enter-PSSession szxwis01-wb -Credential $mycreds -Authentication Credssp
invoke-command -ScriptBlock { D:\test.ps1 } -ComputerName cumputerName -Credential $mycreds -Authentication Credssp
參考文章:http://blogs.msdn.com/b/besidethepoint/archive/2010/05/26/powershell-remoting-for-sharepoint.aspx