Task:
Return list of computers with the version of OS installed or some other software component.
Steps:
1. Open PowerShell prompt:
Start --> Search bar --> Windows PowerShell --> Run as Administrator
2. Run one of the following PowerShell command sets:
a. To Use Active Directory:
- Load the module and run:
PS C:\> Import-Module activedirectory
- Run the query:
Note:
- Replace the SearchBase with your environment
PS C:\> Get-ADComputer -SearchBase 'OU=US,DC=mindwatering,DC=net' -Filter * -Properties * | FT Name, OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion -Wrap -Auto | export-csv
b. To use old WMI:
- Load the module and run:
PS C:\> Import-Module activedirectory
- Build list of computers:
$lastLogon = (Get-Date).AddDays(-50).ToFileTime()
$computers = Get-ADComputer -LDAPFilter (lastlogontimestamp<=$lastLogon) -Properties dnshostname
$computers = $computers | ?{Test-connection $_.dnshostname -Quiet}
- Run the query:
$osInfo = Get-WmiObject -query "Select version,buildnumber from win32_operatingsystem" -ComputerName $computers
previous page
|