PowerShell Create Server configuration item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 07:43 AM
Hey fellow scripters, we are taking our server provisioning to another level and I need to be able to create a server CI with (most) of the fields populated. I am not so familiar with the REST coding other than getting records. It was suggested to me that I just let SCCM create the CI once the server has been provisioned and then update the record. The issue with this is that it is not efficient in our environment and does not meet the requirements for this particular task.
I would like to use PowerShell to create the CI, but would like to know if anyone has more information on this topic. The REST API explorer isnt making much sense to me right now.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2016 07:42 AM
Hi,
Your approach is an idea and it's possible. There are a few key points to have in consideration:
1. If you are going to use a powershell to get the server info, you need to sheduled it using system task manager.
2. You can find similar powershell scripts online (microsoft technet) which can cover 90% of your goal. Please check the link below
https://gallery.technet.microsoft.com/scriptcenter/PowerShell-Script-Get-beced710. It contains all server information: memory, cpu, core, processor type, OS type, etc.
3. You can use powershell to create a REST request. Please check the links below
Powershell REST api examples - ServiceNow Express Support
json - Get ServiceNow Records Powershell - More than 250 - Stack Overflow
REST table API create a record - ServiceNow Express Support
ServiceNow API Example in PowerShell.md · GitHub
4. Create a transform map for each class.
Hope you find this useful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 10:56 AM
Thanks Rafael, using the REST API explorer I was able to figure out what I needed. Part of the issue was that the account I was using did not have the correct permissions (401). The only issue that I ran into was the way that the REST API explorer provides the body. I had to do a little research but figured out how to create and modify CI items in the CMDB so my goal has been met and we are off and automating a huge component of our infrastructure services!
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2016 01:22 AM
Yeay! Perfect! That's good news. Glad I could help you Jake!
Please close this topic if your issue has been solved.