![](/img/trans.png)
[英]How to Export the SSL Cert expiration deatils to Excel sheet using Powershell script
[英]How to export the IIS site deatils to excel sheet from multiple servers using Poweshell script
我編寫了一個腳本,其中該腳本僅提供一台服務器的 IIS 詳細信息,但我需要使用同一腳本的多台服務器的 IIS 站點詳細信息。
Import-Module WebAdministration
get-website | select Name,Id,State,physicalpath,
@{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ‘;’ }} ,
@{n="LogFile";e={ $_.logfile | select -expa directory}},
@{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ‘;’ }}|
Export-Csv -NoTypeInformation -Path C:\Temp\IIS_sites.csv
試試這個:請注意,如果遠程機器上的 winRM 關閉,這將不起作用
$Machines = @('machine1','machine2') # list of your machines
foreach($M in $Machines)
{
Invoke-Command -ComputerName $M -ScriptBlock {
& {
# your script here
}
}
}
此外,如果您希望從命令中獲得輸出,並希望將它們保存在不同的變量中,請使用以下命令:
$Responses = Invoke-Command -ComputerName somecomp -ScriptBlock { (Get-Website), (Get-Process) }
#IIS Sites:
$Responses[0]
#Processes
$Responses[1]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.