$NoInfo = $null
$Offline = $null
$List = $null
#Get-Content unknowns.txt | foreach {
Get-ADComputer -Filter 'OperatingSystem -like "*Windows server*"' -Properties * | foreach {
$FQDN = $_.DNSHostName
$Path = "\\$FQDN\c`$\Windows\debug\NetSetup.log"
if (Test-Connection $FQDN -Count 1 -ErrorAction SilentlyContinue) {
if (Test-Path $Path) {
write-host "`n`nChecking $FQDN..."
$User = ($($(Select-String -Path $Path -Pattern "lpAccount: " -CaseSensitive) -split " ")[3])
$User
[array]$List += Write-Output $FQDN";"$User
}
else {[array]$NoInfo += $FQDN}
}
else {[array]$Offline += $FQDN}
#sleep 5
}
$list
Comments
Post a Comment