$ComputerScan = @(Get-QADComputer -sizelimit $sizelimit -IncludedProperties LastLogonTimeStamp -WarningAction SilentlyContinue -Inactive:$false -OSName $computerFilter | where {$_.AccountIsDisabled -eq $false} )
# Create list of computers
ForEach ($Computer in $ComputerScan){
$compObj = New-Object PsObject -Property @{
Computer = $computer
Credentials = $credentials
Domain = $domain
}
$computers += $compObj
}
此后我在foreach
上$computers
,但我希望有一个免责清单。
最好像这样格式化
computer1
server4
computet4
但是,怎么样?
来自挪威的问候!
答案 0 :(得分:1)
$ComputerScan = @('blah', 'bluh', 'blih', 'bloh')
$ExclusionList = @('blih', 'blah')
$ComputerScan | where { $ExclusionList -notcontains $_ } | Write-Host
答案 1 :(得分:1)
计算机查询的一些改进:
使用where-object,使用ldap过滤器获取启用的计算机
$ computerScan = Get-QADComputer
-LdapFilter '(!(userAccountControl:1.2.840.113556.1.4.803:=2))'
-Sizelimit $ sizelimit -WarningAction SilentlyContinue
-OSName $ computerFilter |
Select-Object -ExpandProperty Name