Windows PowerShell

TIP: Query servicenow Incident record using PowerShell and REST API

Posted on

In order to query the servicenow incident records and to list out the required fields use the sysparm_fields column which helps in optimization. Now,  See the code, result and performance All Fields function Get-ServiceNowIncident { [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] $IncidentID, [Parameter(Mandatory)] [pscredential] $Credential ) try { $Uri = “https://dev42835.service-now.com/api/now/table/incident?sysparm_query=number=$($IncidentID)” $Result = Invoke-RestMethod -Uri […]

PowerShell

Retrieve Oracle instance port number using PowerShell | REGEX

Posted on

A requirement popped up to get the Oracle instance(s) port number before building a connection string for establishing a connection. Team used tnsping utility which returns results like shown below TNS Ping Utility for 64-bit Windows: Version 11.2.0.4.0 – Production on 09-MAR-2018 04:44:04 Copyright (c) 1997, 2013, Oracle. All rights reserved. Used parameter files: D:\app\oracle\product\11.2.0\network\admin\sqlnet.ora […]

Windows PowerShell

Play with node-powershell!

Posted on

#iHeartPowerShell One of my colleague asked me a PowerShell script to query AD User information! Yes, I did your voice! Import-Module ActiveDirectory Get-ADUser -Identity <samaccountname> But, he asked “How will I do it in NODE JS with no AD Module?” Well! it’s too deep to discuss about node js! Anyways to make it simple I […]

Windows PowerShell

Create a HPSM9 incident with an attachment using PowerShell

Posted on

  One of our valuable customer asked a script to create a HPSM9 incident with a screen shot! Yes, it is really easy if we understand the WSDL! With no wait here is the snippet #region Attaching a screen shot $Stream = [System.IO.MemoryStream]::new() $Image = [System.Drawing.Bitmap]::new(“C:\Temp\Pictures\easy.jpg”) $Image.Save($Stream, [System.Drawing.Imaging.ImageFormat]::Jpeg) $Stream.Close() $ImageBytes = $Stream.ToArray() $Attachment = New-Object […]