2017-03-09 63 views

回答

0

嘗試Invoke-Command

注意你的語法是一個DOS命令。以下應該讓你走上正軌。當然,您可能必須通過憑據。

必須在遠程服務器上啓用遠程處理在每臺服務器上運行Enable-PSRemoting -Force

Invoke-Command -Computer remoteserver -ScriptBlock { 
    & $Env:Windir\system32\inetsrv\appcmd.exe list site /config /xml 
} | Out-File c:\websites.xml -Append 

注意,讓網站爲PowerShell中的對象「的PowerShell」的方式如下所示:https://stackoverflow.com/a/25091831/1165140

+0

謝謝@avvi 我有點理解了它以後。我使用PSSession命令建立到遠程服務器的連接,並執行Invoke-Command,如上所述。 '輸入-的PSSession $ SourceServerName 調用命令-ComputerName $ SourceServerName -FilePath $ ExtractWebsiteScriptPath -ArgumentList $ WebServerTemplateXML,$ SourceServerName,$ DestinationServerName 出入境PSSession' – AnupDharia

+0

新來的StackOverflow,所以請不要介意格式 – AnupDharia

相關問題