简体   繁体   English

使用Powershell远程处理从许多Web服务器获取IIS绑定,调用命令和模块Webadministration

[英]Get IIS Bindings from many webservers using powershell remoting, invoke command and module webadministration

Right now I made a small script to see my actual webbindings on a server. 现在,我做了一个小脚本,以查看服务器上的实际Web绑定。

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 

This wil outfile my IIS bindings to txt which works brilliant. 这将使我的IIS绑定胜过txt,效果很好。 I now need to invoke that command to several other servers and save the output file on one server. 现在,我需要对其他几台服务器调用该命令,并将输出文件保存在一台服务器上。 since the machine name will be diffrent I expect as many outputs as servers. 由于机器名称将有所不同,因此我希望输出与服务器一样多。

I tried for example the following : 我尝试例如以下内容:

icm -comp server02 {get-childitem -path IIS:\Sites}

But than the imported Module webadministration is not working, since I only loaded on one server. 但是比导入的模块webadministration无法正常工作,因为我仅在一台服务器上加载。 So I tried to load that remotely using : 所以我尝试使用以下方式远程加载该文件:

icm -comp server02 {import-module webadministration}

without success. 没有成功。

How to achieve that? 如何实现呢?

This will get the data from all machines defined in $machines and output to \\\\server01\\d$_utils\\PowerShell Scripts\\IISexport\\ . 这将从$machines machines中定义的所有计算机中获取数据,然后输出到\\\\ server01 \\ d $ _utils \\ PowerShell Scripts \\ IISexport \\中

$today = Get-Date -format M.d.yyyy
$machines = @("server01","server02")
foreach($machine in $machines) {
    icm -comp $machine { param($machine,$today)
        import-module webadministration;
        Get-ChildItem -path IIS:\Sites | 
        out-file "\\server01\d$\_utils\PowerShell Scripts\IISexport\IISExport$machine$today.txt"
    } -ArgumentList $machine,$today 
}

You can of course change the output path( and import list of machines from a file,AD or some other source). 当然,您可以更改输出路径(并从文件,AD或其他来源导入机器列表)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Powershell WebAdministration模块获取网站的根应用程序 - Get root application for a web site using Powershell WebAdministration module Powershell:IIS,Microsoft.Web.Administration,导入模块WebAdministration,PSSnapin WebAdministration - Powershell: IIS, Microsoft.Web.Administration, Import-Module WebAdministration, PSSnapin WebAdministration PowerShell + WebAdministration - 如何从webapplication获取网站? - PowerShell + WebAdministration - How to get website from webapplication? 运行Get-Childitem的IIS Web管理模块中的问题 - Issue in IIS webadministration module running Get-Childitem PowerShell远程处理-调用命令不返回输出 - PowerShell Remoting - Invoke-Command not Returning Output 可以使用Powershell导出IIS ip绑定吗? 没有安装单独的模块 - Possible to Export IIS ip bindings using Powershell ? no seperate module installed 使用 PowerShell 的 Invoke-Command 进行远程处理时,如何包含本地定义的函数? - How do I include a locally defined function when using PowerShell's Invoke-Command for remoting? 当命令在本地运行以尝试获取 SSLBinding 时,使用 PowerShell Invoke-Command 不提供相同的 IIS 信息 - Using PowerShell Invoke-Command not providing same IIS info when commands ran locally trying to get SSLBinding 使用Powershell WebAdministration复制正在运行的IIS App Pool - Copy running IIS App Pool with Powershell WebAdministration 使用WebAdministration管理单元从.NET运行Powershell脚本 - Running Powershell scripts from .NET using WebAdministration snap in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM