我有导出当前已登录服务器的网站的命令(如下所示)。我需要命令来导出其他服务器的网站。
%windir%\ system32 \ inetsrv \ appcmd列出站点/ config / xml> c:\ websites.xml
最佳答案
尝试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
关于powershell - Powershell命令导出远程服务器的IIS网站和应用程序池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42703791/