Get ADcomputer Buil windows extend - powershell

I wanted to know if I can retrieve via script or powershel command the extended build of windows in order to make a report of the computers which received the last patch and those which are in later version
What i want
for the moment I found this command but I only get the windows build
It only allows me to know which version of windows 10 the computers have
Get-ADComputer -Filter * -Properties OperatingSystemVersion | Select-Object -Prperty Name, OperatingSystemVersion
Thanks

try this:
get-ADComputer -Filter * -Properties OperatingSystemVersion, operatingSystem, name | #
Where-Object {($_.operatingSystem -like "Windows*")} |
Select-Object name, OperatingSystemVersion | sort name #or OperatingSystemVersion
If you want a build version:
(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name "UBR").UBR
By
Invoke-Command -ComputerName name -ScriptBlock {}

Related

Powershell: Get number of computers connected to Active Directory by OS

I have a task to get the number of computers connected to a certain Active Directory, grouped by OS.
I figured out how to find out the name of the OS installed on a certain computer:
Get-ADComputer -Filter * -Properties * | Select-Object -ExpandProperty OperatingSystem
I am having a hard time understanding, how should I group and then count the different kind of operating system in powershell. Also in the testing enviroment I got set up, I only have one computer connected to the AD, so I really don't have room to test out my ideas. I have requested some additional virtual machines to be connected to the AD, but I would like to figure the how until I get those.
As suggested in the comments by #Scepticalist - Group-Object is the tool designed for this specific purpose.
Get-ADComputer -Filter * -Properties OperatingSystem | group-object OperatingSystem | select name,count
All Windows Servers
Get-ADComputer -Filter {operatingsystem -like 'server'} -Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address,lastlogondate | Export-Csv c:\temp\WinServers6.csv
All Windows clients
Get-ADComputer -Filter {operatingsystem -notlike 'server'} -Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address,lastlogondate | Export-Csv c:\temp\WinClients.csv
All Computers in AD
Get-ADComputer -Filter * -Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address

LDAP Query for Active-Directory Get-ADComputer in PowerShell

I have the below LDAP query (from my previous question answered by Bill_Stewart) in my script that returns all computers from Get-ADComputer for Windows 7, with some exclusions.
$computersFilter= "(&(operatingSystem=*Windows 7*)(name=*-*)(!name=V7-*)(!name=*-none)(!name=*-oncall)(!name=*-blackbaud)(!name=sc-win7-1)(!name=ut-swclient-01))"
and it works fine with the below call to Get-ADComputer:
$computers= Get-ADComputer -LDAPFilter $computersFilter -Property LastLogonDate | Select-Object Name,LastLogonDate
$computers | Select Name, LastlogonDate | Export-Csv $ServiceTagsPath -NoTypeInformation
However, I want to have my query return all computers with Windows 7 and above but when I change it like so:
(&(operatingSystem=*Windows 7*)(operatingSystem=*Windows 8*)(operatingSystem=*Windows 10*)
nothing is returned into the $computers variable.
So what's the right way to write an LDAP query to return all operating system versions Windows 7 and above?
After some help from Rob in the comments, and some more research, I found that the correct way is to use OR, and the operator is |
like so:
$computersFilter= "(&(|(operatingSystem=*Windows 7*)"
$computersFilter+= "(operatingSystem=*Windows 8*)"
$computersFilter+= "(operatingSystem=*Windows 8.1*)"
$computersFilter+= "(operatingSystem=*Windows 10*))"
$computersFilter+= "(name=*-*)(!name=V7-*)(!name=*-none)(!name=*-oncall)"
$computersFilter+= "(!name=*-blackbaud)(!name=sc-win7-1)(!name=ut-swclient-01))"
$computers= Get-ADComputer -LDAPFilter $computersFilter
-Property * | Select-Object Name, OperatingSystem, LastLogonDate
$computers | Select Name, OperatingSystem, LastLogonDate |
Export-Csv $ServiceTagsPath -NoTypeInformation
References:
IBM LDAP Search Filter Expressions
MSDN - LDAP Query Basics

Get-WmiObject -Class Win32_Product - showing wrong version of program

Get-WmiObject -Class Win32_Product | where-object { $_.name -like "*OfficeScan*" }
Shows me the wrong version number of the TrendMicro OfficeScan Client - the default Version 12.0.1222 when the installed version is 12.0.4430.
I also tried:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
There it doesnt show up at all. It's weird because in the old systemcontrol if i go to deinstallation it shows the correct version:
So I need to somehow extract the information of the actual version to my powershell. I need it for a auto update feature, it has to be using powershell.
Assuming you're using a 64bit system, you're looking in the wrong place in the registry.
I don't have TrendMicro, so using Adobe Reader as an example:
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object { $_.DisplayName -like "*Adobe Reader*" } |
Select-Object DisplayName, DisplayVersion
If you just want a numerical Version property to use as a comparison, update:
Select-Object -Expand DisplayVersion

Powershell: Get-ADComputer from another domain returns OperatingSystem information blank/missing

Trying to list all computers with their OS information that belong to another trusted domain, but OperatingSystem and OperatingSystemVersion returns blank values:
Get-ADComputer -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion -SearchBase "" -Server OtherDomain.com.au:3268 | Format-Table Name, OperatingSystem, OperatingSystemVersion
Only the Name property is populated.
If I run this, it returns alot of info, but the OS info is all blank:
Get-ADComputer -Filter * -Properties * -SearchBase "" -Server OtherDomain.com.au:3268
If I run this command on the "OtherDomain" it works just fine:
Get-ADComputer -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion | Format-Table Name, OperatingSystem, OperatingSystemVersion
I get all 3 information I want. Is there some security issue here that I am encountering when I run it from a different domain? I can browse through Active Directory Users and Computers (dsa.msc) and see the OS information of computers in the other domain without a problem too.
I'm using Powershell 3.0
Get-ADComputer -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion -SearchBase "DC=OtherDomain,DC=com,DC=au" -Server "OtherDomain.com.au" | Format-Table Name, OperatingSystem, OperatingSystemVersion
Had to include a value in the Searchbase parameter (cdidn't work with a null value) and remove the port number from the Server parameter value.

Powershell ActiveDirectory module Variable with wildcard not working

Why doesn't the below get-adcomputer commandline return any results? It's really irritating when cmdlets don't accomodate powershell syntax. At least that's what it looks like is happening here. If I do a write-output, it displays exactly what I want to be inserted in the commandline. However, when I go to use it with the get-adcomputer cmdlet, no results are returned.
PS: C:\> $Variable = "88FF"
PS: C:\> write-output "*$($Variable)*"
*88FF*
PS: C:\> Get-ADComputer -Filter {Name -like "*$($Variable)*"} -Property *
PS: C:\>
PS: C:\> Get-ADComputer -Filter {Name -like "*88FF*"} -Property *
computer1
computer2
computer3
I've tried a bunch of different variants... including even adding literal quotes to the variable by escaping them. I've been pulling my hair out trying to figure out something that should take less than 10 seconds to do.
PS: C:\> $Variable = "`"*888FF*`""
PS: C:\> $Variable
"*88FF*"
PS: C:\> PS: C:\> Get-ADComputer -Filter {Name -like $Variable} -Property *
PS: C:\>
Edit: I've also tried below variant with same exact result:
PS: C:\> Get-ADComputer -Filter {Name -like '*$Variable*'} -Property *
PS: C:\>
Give this a try:
Get-ADComputer -Filter "Name -like '*$Variable*'" -Property *
Pretty lame, it looks like this is one of the many limitations of the Powershell Active-Directory module that comes with Windows. I wasn't doing anything wrong in my original attempts. I ended up having pipeline the output to where{ } to filter it items.
Get-ADComputer -properties Name, OperatingSystem -Filter *| ?{$_.name -like "*$($Variable)*"} |ft Name, OperatingSystem -Wrap -Auto
How about this:
$myvar="*888FF*"
get-adcomputer -filter {name -like $myvar} -property *
It's really annoying, you would expect this to work but -filter just has some weird parsing rules internally I guess
$myvar="888FF"
get-adcomputer -filter {name -like "*$myvar*"} -property *
Shay's solution works beautifully (at least on v4)
I also found out that LDAPFilters will work too!
get-adcomputer -LDAPFilter "(&(name=$name*)(operatingsystem=server))"