使用powershell远程处理、invoke命令和模块webadministration从许多Web服务器获取IIS绑定

使用powershell远程处理、invoke命令和模块webadministration从许多Web服务器获取IIS绑定,powershell,iis,powershell-3.0,powershell-4.0,powershell-remoting,Powershell,Iis,Powershell 3.0,Powershell 4.0,Powershell Remoting,现在我制作了一个小脚本来查看我在服务器上的实际网络绑定 Import-Module WebAdministration; $today = Get-Date -format M.d.yyyy $machine = hostname function IISRport { Get-ChildItem -path IIS:\Sites | out-file "\\server01\d$\_utils\PowerShell Scripts\IISexport\IISExport$machine$t

现在我制作了一个小脚本来查看我在服务器上的实际网络绑定

Import-Module WebAdministration;

$today = Get-Date -format M.d.yyyy
$machine = hostname
function IISRport

{
Get-ChildItem -path IIS:\Sites | out-file "\\server01\d$\_utils\PowerShell Scripts\IISexport\IISExport$machine$today.txt"
}

IISReport 
这将把我的IIS绑定文件导出到txt,它工作得非常出色。 现在,我需要对其他几个服务器调用该命令,并将输出文件保存在一个服务器上。由于机器名不同,我希望输出与服务器一样多

例如,我尝试了以下方法:

icm -comp server02 {get-childitem -path IIS:\Sites}
但是导入的模块webadministration不起作用,因为我只在一台服务器上加载。因此,我尝试使用以下方式远程加载:

icm -comp server02 {import-module webadministration}
没有成功


如何实现这一点?

这将从
$machines
中定义的所有计算机获取数据,并输出到\\server01\d$\u utils\PowerShell Scripts\IISexport\

$today=获取日期-格式为M.d.yyyy
$machines=@(“server01”、“server02”)
foreach($机器中的机器){
icm-comp$machine{param($machine$today)
导入模块webadministration;
获取ChildItem-路径IIS:\Sites |
输出文件“\\server01\d$\\u utils\PowerShell Scripts\IISexport\IISexport$machine$today.txt”
}-ArgumentList$machine$today
}

当然,您可以更改输出路径(并从文件、AD或其他来源导入机器列表)。

谢谢,这正是我需要的。有趣的是,我得到了一个错误“拒绝访问”的开场白错误:(:)[Out File],UnauthorizedAccessException-即使我是域管理员。嗯,这是一个双跳身份验证问题,您可以阅读更多有关它的内容。。你能做的最好的事情就是把报告放在所有盒子上的同一个位置,然后在最后把它们都拉出来。是的,我就是这么想的。我想我就是这么做的。。。谢谢