Using SMLets Beta 3 Post #1 – Using Get-SCSMObject, Get-SCSMClass to Dump Data from SCSM
Published Feb 15 2019 05:55 AM 2,631 Views
First published on TECHNET on Apr 21, 2011

Yesterday we released SMLets Beta 3 .  This will be the first in a series of posts on using SMLets Beta 3.

To start out with let’s answer a question in the comments on the release announcement blog post from Sam:

I also wanted to ask you about the which table in the database that contains the user information. I know that the BaseManagedEntity table contains the user ID and the display name but where the other information is stored? If i wanted to get a list of all user and their information in the system where can i get that?

The issue that i am trying to resolve is that in some cases you select a user from the user selection window but the display name is returned as a different user! based on my analysis, it seems that there was an error in the import date file i used so i am trying to fix that.

So – to get started with let’s see a quick example of using the Get-SCSMObject cmdlet.

Before we begin make sure you have the SMLets Beta 3 installed.  Then open a PowerShell window and Import the Module.

Note – if you are running these cmdlets remotely from the SCSM server, you will need to add the –ComputerName <your SCSM server name> parameter to the end of all the cmdlet examples below.

If you run just Get-SCSMObject without any parameters PowerShell will prompt you for the –Class required parameter.

In SMLets Beta 3, the class must be passed as a ManagementPackClass object not simply the name.  Fortunately, we have also provided a Get-SCSMClass cmdlet.  To get the class you need to know the class name.  For example:

Notice how multiple classes are returned, but they all start with System.WorkItem.Incident.  Since we only want the System.WorkItem.Incident class we can add a $ to the end of the name to tell PowerShell to only get us the System.WorkItem.Incident class:

Nice.  Now we just need to store this in a variable:

Now we can pass the $IncidentClass to the Get-SCSMObject –Class parameter:

We can also shorten this as follows.

Unless you need to use the incident class as a variable to something else later this is probably a shorter/faster way to get what you want.  You can also pass the class through the pipeline:

So – you may be wondering how you get the class name in the first place.  Well – just use the Get-SCSMClass cmdlet to figure it out (or you can use the model Visio diagram ) assuming you know at least part of the name:

If you know the display name but have no idea what the name is you could do something like this:

OK – so let’s apply what we learned here to Sam’s question:

First we need to know the Name of the user class…

We don’t need any of the Abstract classes so we can filter those out like this:

So – we can safely assume that the correct class is probably Microsoft.AD.UserBase, Microsoft.AD.User, or System.Domain.User, but which one??  This might be a case where you want to consult the Visio model:

You can also look up the base classes of a given class by doing this:


So – assuming we care about Users and Groups lets use the Microsoft.AD.UserBase class.  Let’s get all the users in the system…

Alright!  Now let’s say we want to look at certain properties of the users.  We can pipe the output to a Format-Table cmdlet and specify the properties we want to see in the columns:

Super!  Now, lets say we want to sort the data so it is easier to consume. Use the Sort-Object cmdlet in the pipeline before the Format-Table.

Can this get any more awesome? Yes!

Let’s say we only want to get users that have a UserName that starts with ‘A’.  We can do that using the Filter parameter like this:

Note: DO NOT use Where-Object to filter records. See this blog post to learn more.

OK – now – how do you know which properties are available on a given class to query by or to display?  Use the Get-Member cmdlet!

This will show you all of the methods that are available on the objects and the properties.

So – to finally answer Sam’s question….. You can do something like this to find all the users that have a particular display name.

Note – you could of course do all of this in the Users view in the UI but what fun is that?

In the next blog post we will see why figuring this stuff out in PowerShell can be extraordinarily powerful - we’ll look at updating objects using Set-SCSMObject!

Version history
Last update:
‎Mar 11 2019 08:43 AM
Updated by: