powershell - Powershell命令导出远程服务器的IIS网站和应用程序池

标签 powershell iis command-line web export

我有导出当前已登录服务器的网站的命令(如下所示)。我需要命令来导出其他服务器的网站。

%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/

相关文章:

powershell - 通过纯批处理将远程文件下载到内存中

iis - 使用 Powershell 添加 IIS 8.5 自定义日志记录字段

javascript - 与SPA一起使用时,与ASP.NET MVC API一起使用时,slidingExpiration似乎不起作用

c# - 软关闭云角色以忽略新的操作请求?

java - 通过命令行编译和运行

windows - 有没有 'compiles'到windows批处理语法的脚本语言?

powershell - 通过powershell向Azure RM AD应用程序添加权限

windows - 为什么安装Chocolatey时PowerShell是 "not recognized"?

c# - MS Log Parser 2.2 查询错误

bash - 使用 jq 或 sed 替换 JSON 中的属性或键