我想筛选以下PS脚本的输出;筛选PowerShell输出
我们使用像服务器名称:
SRV-APP-001, PRD-APP-001, TST-APP-001 等等
$strCategory = "computer"
$strOperatingSystem = "Windows*Server*"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("OperatingSystem=$strOperatingSystem")
$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$objComputer = $objResult.Properties;
$objComputer.name
}
这个脚本的输出是域中的所有服务器。
但我希望只看到以“SRV”或“珠三角”
的| where { $_name -like "SRV*"}
启动服务器$objComputer.name
部分后不真的工作。
预先感谢您
请不要使用[匈牙利命名法(http://windowsitpro.com/blog/what-do-not-do -powershell部分-5)。谢谢。 –