SquigglyMonkey
asked on
iis site name script powershell
I looked at a couple of the answers here, but they aren'tquite what I am looking for.
I need to find any sites on a number of windows servers, running iis. I am able to run this locally and get the name(s).
Import-Module WebAdministration; Get-ChildItem -path IIS:\Sites
This works fine, but I need to do this on a 100+ servers, so I don't want to log onto them.
I tried this:
Import-Csv servers.csv | ForEach-Object {
Invoke-Command -ComputerName $serverName { Import-Module WebAdministration; Get-ChildItem -path IIS:\Sites }
} |format-list
when I run this in PS, it just returns to the prompt. So I guess I am missing getting each object to be the variable $servername, I can't seem to find an example of it to get this work.
I need to find any sites on a number of windows servers, running iis. I am able to run this locally and get the name(s).
Import-Module WebAdministration; Get-ChildItem -path IIS:\Sites
This works fine, but I need to do this on a 100+ servers, so I don't want to log onto them.
I tried this:
Import-Csv servers.csv | ForEach-Object {
Invoke-Command -ComputerName $serverName { Import-Module WebAdministration; Get-ChildItem -path IIS:\Sites }
} |format-list
when I run this in PS, it just returns to the prompt. So I guess I am missing getting each object to be the variable $servername, I can't seem to find an example of it to get this work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER