现在我制作了一个小脚本来查看我在服务器上的实际网络绑定。
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}
没有成功。
如何做到这一点?