Get A ServiceNow User Using PowerShell

ServiceNow is a cloud computing company whose software is used for IT Service Management based on ITIL standards. They’ve got a bunch of different modules for managing problems and incidents, operations management, performance analytics, and more. You there some custom development you can do to modify their solutions or build your own. It’s pretty flexible, and we use it where I work.

I have been working with the ServiceNow API a lot lately. This week, I’m going to show you something pretty simple: Getting a ServiceNow user.

Let’s jump into some code first and I’ll break down what I’m doing.

First, I’m compiling the authentication information and header info as per the ServiceNow documentation. This isn’t my favorite way of handling credentials, but it’s what the ServiceNow documentation recommends and, well, it works.

Next, I’m constructing my URI using a variable holding my subdomain and another variable for the username I’m interested in ($SubscriptionSubDomain and $Username respectively).

Then, I am invoking the web request to get the information about the user, and parsing the result. I can then use the $result variable later in my script.

This has been particularly helpful for me when I’m trying to figure out the sys_id (ServiceNow’s unique ID) for a specific user and all I know is their username.

Leave a Reply