I need to check which devices in our network, Which does not have the OS version 1809 Windows 10 and I need to do a scan to determine those devices pulling data from AD.
Try{$Domain = $(get-addomain).dnsroot}
Catch{$Domain = ""}
$Log = "C:\Temp\Audit\$Domain OS Compliance $(get-date -f yyyy-MM-dd).csv"
$Computers = Get-ADComputer -Filter {Enabled -eq $True} -Property * |
Select Enabled,Name,OperatingSystem,OperatingSystemVersion
foreach ($Computer in $Computers)
{
#properties
$Version = $Computer.OperatingSystemVersion
$Enabled = $Computer.Enabled
$Name = $Computer.Name
$OS = $Computer.OperatingSystem
}
#Windows10 Build 1908 check
If($OS -like "Windows 10*")
{
$Type = "Computer"
$CountComputers++
$Build = "1908"
$obj = New-Object PSobject
$obj | Add-Member NoteProperty -Name "Enabled" -Value $Enabled
$obj | Add-Member NoteProperty -Name "Name" -Value $Computer.Name
$obj | Add-Member NoteProperty -Name "Operating System" -Value
$Computer.OperatingSystem
$obj | Add-Member NoteProperty -Name "Version" -Value $Version
$obj | Add-Member NoteProperty -Name "Build" -Value $Build
}
$OutData = $OutData | sort -Property "Type","Name"
$OutData | Export-CSV $Log -notype -Encoding UTF8
write-host "Log Export Complete to $Log" -foregroundcolor yellow
I seem to be doing something wrong calling out the query I am not that well versed with Powershell anyone can share me or give me any inputs so i can formulate my own code would help out