Question

I'm trying to create wmi query to sccm to get PC, where was user's last logon. Something like:

Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select lastlogon, PCname from sms_? where LastLogonUserName='$SamAccountName'" | select lastlogon, PCname.

I can see this information in sccm report, but I don't know what class I have to use for a query. I'm using sms_r_system for getting IP and computer name.

Is anyone knew sccm class with this information or sql queries will be better for me?

Was it helpful?

Solution

Which report are you viewing the data with? You might want to open up the report's SQL code, figure out which ConfigMgr SQL views it's referencing, and then translate that to the SCCM WMI class names. The WMI class names closely correlate to the SQL view names.

Use a WMI browser like SAPIEN's free WMI Explorer GUI tool to help explore the root\sms\site_xyz WMI namespace and discover which class you are looking for. You can also use Windows PowerShell to help discover which class contains this property:

gwmi -name root\cimv2 -list | ? { ($_.Properties.Name -join ',') -match 'lastlogon' }

Note: Make sure you're using PowerShell version 3.0 Release Preview for the above command, otherwise it won't work right.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top