Jump to content

Recommended Posts

Posted

Are you well???

 

 

 

 

 

 

I thought you were...

 

Anyways, I have a VB Script that runs as the logged on user and pulls in the OS type and the username and updates the Computer Description in AD.

 

I have been asked to look at changing this script to include the following:

 

Windows Version

Release Number (1709, 1803, 1809 etc...)

RAM

Processor type (i5, i3, i7)

 

I am aware that it is possible to get some of this information via Powershell but I've barely touched Powershell so have no clue where to start.

 

Anyone have a similar script that I could have a look at?

 

Cheers

Posted
Oh wow, thats seems like a sledge hammer to crack a nut. If you use Solus for Sims it should have all that info in the agent details already. There are also many other audit programs like spiceworks that can do it on mass.
Posted

It's for a quick and dirty Audit as we are trying to see the different versions of Windows we have in the 30+ schools we look after. We are rolling out LTSC over the summer but need to see how many machines are capable of running it without doing a full site audit for each school as we don't have the man power to do it.

 

Unfortunately we don't run Spiceworks either, as much as I have pushed for it.

Posted (edited)

CPU Type in Powershell/CMD - wmic CPU get NAME

RAM in Powershell - Get-WmiObject win32_physicalmemory (you may need to jiggle this to just get the info you require)

Other Info as a bonus - Get-WmiObject Win32_BaseBoard

 

Any chance you could share your current script? Sounds useful.

Edited by gtg93
Posted

Thanks gtg93

 

That's a good start. This is the script I currently use:

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set oss = objWMI.ExecQuery ("Select * from Win32_OperatingSystem")

' Get service tag and computer manufacturer

For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")

serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")

manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")

Next

' Get computer model

For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")

model = trim(replace(objComputer.Model, ",", "."))

Next

' Get Windows Version

For Each objOperatingSystem in oss

ver = objOperatingSystem.Caption

Next

' Get computer object in AD

Set objSysInfo = CreateObject("ADSystemInfo")

Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

' Build up description field data and save into computer object if different from current description

' We also do not update computers with a description that starts with an underscore (_)

newDescription = WshNetwork.UserName & " - " & ver

if not objComputer.Description = newDescription and not left(objComputer.Description,1) = "_" then

objComputer.Description = newDescription

objComputer.SetInfo

end if

 

Thanks again

Posted (edited)

No problem,

 

thanks for sharing the script too.

 

Just found these which may help too:

Show OS (Win10Edu/Wind10Pro etc) - (Get-WmiObject -class Win32_OperatingSystem).Caption

Show OS Version (1803/1809 etc) - (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId

Edited by gtg93
Posted

Quick Update

 

We have changed our idea slightly as some of the schools already use the AD Description field for identifying locations of equipment. We also want to be able to export and filter key pieces of information. Our new plan is to modify the local computer description and then split this description with the comma delimiter and write the individual values to the Extension Attributes for the machine.

 

Our new script looks like this:

 

#Get the Installed Version of Windows

$windver = (Get-WmiObject -class Win32_OperatingSystem).Caption

 

#Get the release ID Number where applicable

$releasever = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId

 

#Retrieve the CPU Type

$cputype = (Get-WMIObject win32_Processor).Name

 

#Retrieve total installed RAM in GB

$physicalram = -join ((Get-WMIObject -class Win32_PhysicalMemory | Measure-Object -Property capacity -Sum | % {[Math]::Round(($_.sum / 1GB),2)}),"GB")

 

#Retrieve total HDD Size for the C: Drive in GB

$totalhdd = -join ([Math]::Truncate((gwmi win32_logicaldisk | where-object {$_.deviceid -eq $env:systemdrive} ).Size/1GB),"GB")

 

#Create the Dexription Field Text as a single variable

$compdesc = -join ($windver,",",$releasever,",",$cputype,",",$physicalram,",",$totalhdd)

 

#This section deals with setting the Computer Description to the $compdesc variable

$OSWMI=Get-WmiObject -class Win32_OperatingSystem

$OSWMI.Description= $compdesc

$OSWMI.put()

 

The first part is done and works. Just to parse this information into the correct fields now.

  • Thanks 1
  • 3 months later...
Posted
You could use group policy to enable win RM and just use Powershell to query all devices for the info you want. If you would like some help with any PowerShell feel free to message me - I love a bit of PowerShell :)
Posted

If your going down the route of remoting and your on PS 5.1 you can just use:-

 

get-computerinfo

 

If ps remoting is going to be an issue then you could GP it and output the data to a share using:-

 

Get-computerinfo | Export-Csv "\$($env:computername).csv" -NoTypeInformation

 

Something like that... On my phone so not going to delve into each and every facet right now but its a starter for 10,and saves all the faffing with wmi and splitting strings. If 5.1 ain't available then I would have to write something else. I would not go writing all this out to AD ext attributes, a share is the place for it then you can just turn gci on it and use select-string and all the other ps goodness for picking out the machines that you are interested in or more preferably ripple PowerBI over it.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...