# Get all the websites stopped in the SharePoint 2010 farm
function GetStoppedWebSitesInFarm
{
foreach ($server in (Get-SPServer | Where {$_.Role -ne "Invalid"}) )
{
$websites = Get-WmiObject -namespace "root/webadministration" -class Site -ComputerName $server.name -Authentication 6 | Where {$_.GetState().ReturnValue -ne 1} | select name
if ($websites -eq $null) {
Write-Host "No web sites are stopped on server $($server.Name)" -foregroundcolor green
continue
}
else
{
foreach ($web in $websites)
{
Write-Host "web site '$($web)' is stopped on server $($server.Name)" -foregroundcolor red
}
}
}
}
Example:
function GetStoppedWebSitesInFarm
{
foreach ($server in (Get-SPServer | Where {$_.Role -ne "Invalid"}) )
{
$websites = Get-WmiObject -namespace "root/webadministration" -class Site -ComputerName $server.name -Authentication 6 | Where {$_.GetState().ReturnValue -ne 1} | select name
if ($websites -eq $null) {
Write-Host "No web sites are stopped on server $($server.Name)" -foregroundcolor green
continue
}
else
{
foreach ($web in $websites)
{
Write-Host "web site '$($web)' is stopped on server $($server.Name)" -foregroundcolor red
}
}
}
}
Example:
No comments:
Post a Comment