I am writing a script to query what edition of Windows machines are on. So far I have the following code:
$ASSETNUM = Read-Host "Please enter a valid asset tag"
Get-WmiObject Win32_OperatingSystem -ComputerName $ASSETNUM | select PSComputerName, Caption, OSArchitecture, Version, BuildNumber | FL
if (Caption = "Microsoft Windows 10 Enterprise"){
Write-Host "This works"
} else {
Write-Host "This did not work"
}
The first part before the if statement works as intended. However, I wish to query the "Caption" to be able to run a further function afterwards. However, I'm at a loss on how to query this. The Write-Host parts are just for testing until I get this working.
Thanks in advance for all your help!
Aucun commentaire:
Enregistrer un commentaire