$strCategory = "computer"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$temp=[System.ServiceProcess.ServiceController]::GetServices($objComputer.name)
where{$_.name -eq 'Dhcp'}
If($temp.status -eq "Running")
{
Write-host $objComputer.name
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment