Retrieve Oracle instance port number using PowerShell | REGEX

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

We need to get the port number – Which is really a very straight forward approach using regular expression


Result : PORT = 15210


Change BMC TrueSight Slot Values Using SOAP and PowerShell

BMC TrueSight – An Aerial View!!!

While working on Event Management a requirement popped up “Update TruSight the slot value when orchestrator automates the event(s)”. In short the automation agent should close the alert after auto-healing. I expected a REST endpoint but unfortunately SOAP web service was the only option.

To solve this we have to take five steps approach connect, map the mc_ueid, manipulate, update using SendEvent operation and disconnect. Yes, it’s that easy!

Establish the Connection

Map mc_ueid

Manipulate status

Update Using SendEvent

Disconnect (Do bulk operation and call disconnect)

Enjoy PowerShell 🙂

Play with node-powershell!


One of my colleague asked me a PowerShell script to query AD User information! Yes, I did your voice!

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 shared an app which  serves as a REST endpoint to query AD User information from any platforms like ASP.NET , NODE JS, PowerShell etc.


The PS script for User.PS1 is using ADSI 🙂 with a parameter for samaccountname which is named as GUID (A Friendly Name 🙂 )!

Spin your NODE and browse for the result!  REST URL :

The RESTful continues! Happy PowerShell!

Create a HPSM9 incident with an attachment using PowerShell


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

The documentation for HPSM9 is here! Get the full script from GitHub!


Part 2: Customize SharePoint Online User Interface using JavaScript | CSOM | PowerShell


This is a continuation of part 1 and we will cover about adding a custom action in site action of the web. Note: You can think about any solution. This blog post is to show an option in PowerShell and Client Side Object Model to customize the Site Actions of the web.

  1. To know Default Custom Action and Location ID’s – Navigate here.
  2. How to work with User Custom Action – Navigate here.

Here is the sample code to add a link in Site Actions!

Site Actions Before


Site Actions After


Full Code

Enjoy PowerShell!

Part 1: Customize SharePoint Online User Interface using JavaScript | CSOM | PowerShell


Woman’s hand drawing a light globe with a felt pen


During my web-ex session “Manage SharePoint Online Using CSOM” I showed few of the custom functions wrapped up as script module. I will be posting the recording session by next week and module will be shared in Git! In the session content management team was actively posting questions and this blog series shares all the questions and solutions we discussed.

Question: Can we Inline Java Script and modify the ribbons, menu items etc in SharePoint Online? If yes can you show step by step procedure?

Answer: Start from here!

Step 1: Create a folder and save all the required files and test the simple java script code to show Hello, World!


Step 2: Now, we need to know the existing custom actions attached in the list, the below code does it for you!

For now, we haven’t attached any custom user actions so the script returns nothing for the list custom (In your case if you have any user custom actions attached you get to see whole bunch of information)!

Step 3: Now, we will add a simple menu in the SharePoint List item menu (The code is in MSDN link and we will use the same but in PowerShell). Take a look at the screen shot which is default out of the box options.


Let us add a menu name as Bing to open the bing search engine !  below is the code which does it easily

It works! Here is the output 🙂


Step 4: If we rerun the Get Custom Actions script we get to see information about the custom actions we added. The below image illustrate it


If you re run the script List Drop Down Menu it gets duplicated! So, don’t do that if accidentally did that like me not an issue quickly clean the dirt by running the below piece of code

Clear! Now, it’s time to use java script 🙂 since I have very basic knowledge in java I showed the example using the MSDN code sample 🙂 Yes Copy + Paste !

In this example we will add a custom ribbon user interface in list display form  – All I did is removing the unnecessary nodes from the XML and below is my example

I don’t have the BingSearch and bing image in my layouts so image breaks but code works as expected



Sample code is below, you need to change the URL, credentials and list name as applicable! Exception handling is not in place because this is built during the demo

Go through the MSDN reference links for more information! In next part I will show bit more automation of UI settings using PowerShell. Cheers 🙂 Enjoy PowerShell 🙂

Import User Profile Picture from Exchange Online using EWS and PowerShell

One of our customer requested a solution to import user profile picture from Exchange Online. Not a big task but this article is to share the simple and clean method to carry out the task without MSOnline module. Yes, we use only PowerShell! At customer environment user uploads profile picture in intranet portal which saves the picture in file share, yeah I got the same question why can’t they get it from the file share? We can but not easy to do because of the profile image file naming convention, every user has an intranet portal profile ID so the files are saved as ID_DATETIMESTAMP. E.G “PROFILEID_YYYYMMDDHHMMSS”. There are many possibilities to do like query intranet portal DB to retrieve image file information and retrieve, use MSOnline module Get-UserPhoto etc.

Outclass is to use PowerShell and get it done on the fly. All we need is the EWS url for the profile picture residing in the Exchange Online and it’s shared below with sizes for reference and hew is the documentation for Get User Photos by using EWS in Exchange

1”UserEmail” &size=HR96x96 HR96x96
2”UserEmail” &size=HR240x240 HR240x240
3”UserEmail” &size=HR648x648 HR648x648


All set to spin up PowerShell ISE for scripting! Simply use Invoke-WebRequest cmdlet with OutFile parameter to save the profile image in disk like shown below

Yay, its easy to get the profile picture information at ease without using Get-UserPhoto cmdlet and no need of Set-Content with Encoding parameters (Saves more time) ! here is my picture – Output of the above snippet!


Check out the sample script below which use ADSI Searcher to retrieve user AD information and save the picture in disk as sAMAccountName_DisplayName.jpg 🙂


VS Binary Module Tip: PowerShell 5.0 SDK Reference Assemblies – Nuget

PowerShell 5.0 SDK Reference Assemblies is available in NuGet. If you are building binary modules you can add the references from Visual Studio just by executing the below command in NPM Console

In the NPM UI we can get it in one go – By Clicking Install
Cool, its easy to add the reference to our project and start building the binary module easily. When we build cmdlet we need to run and test the functionality and each time we execute it’s necessary to close the PowerShell Console Host or ISE host if the binary module is loaded and we can’t rebuild the solution. It will end up in Dll in use error. We can easily over come this by following the below steps.

  • Right Click the Solution from Solution Explorer.
  • Choose Properties and in the Right Pane Select Debug
  • Click Select External Program. Navigate to “C:\Windows\System32\WindowsPowerShell\v1.0\”.
  • Select PowerShell.exe
  • Select the option Enable native code debugging

So after building the code simple click “Start” in Visual Studio which open the PowerShell Console.
Additionally, we can load our module with the help of Command line arguments.

Enjoy PowerShell 🙂 🙂 🙂

PowerShell Tip: Extract Images from DOCX File


It’s an immense pleasure to explore $objects! We do IT Automation tasks using C# or PowerShell. It depends on the requirement and business needs. Recently our team was engaged to extract images from the DOCX files. It’s possible by simply renaming it to ZIP and extract to get the images folder which is not optimal solution at our client environment. So, we used OPEN XML SDK 2.5 (Supported for Office 2016) to accomplish the task.


Extract all the images from the given DOCX File. Example Get-Image -FilePath “C:\Temp\Document.Docx”


  • OPEN XML SDK 2.5
  • Windows PowerShell
  • Visual Studio 2015 (C# Class Library – Binary Module)
  • PowerShell Code

    Cool, here is the C# Binary cmdlet code to do the same


    We prefer to pick a tool which costs less to deliver the solution. So, at my client place we opted for PowerShell to achieve few automation task with respect to Data Manipulation. To loop through multiple files just used the below snippet:

    Enjoy PowerShell!

    Note: You can modify the filename of the image as required. In our case it needs to be the same because its customized.

    Converting JSON Time Format in SharePoint Document Library Metadata

    The SharePoint farm has a Document Library and a List which are linked for some requirements, while querying information we received some data which are not in proper format. Challenge is to split, remove characters and count the total which is little tedious

    Example- The Field3 in CSV yields [“\/Date(1444995273796)\/”,”\/Date(1444996968515)\/”]

    It’s a JSON format and the time format is EPOCH (UNIX format) – With Reference to the link MSDN My advice to customer was to use below code snippet to break the mystery!

    To get the count: (Unfortunately, this is what customer need!) – No Fun in it because this kills the actual flavor of SharePoint development and data.

    The reason for the SPContext Code by developer is unknown. So here comes the ConvertFrom-JSON power in Windows PowerShell Version 3+ 🙂 🙂 🙂

    To get the information about the data in JSON: [We will deep dive in Part 2 of this Blog]

    The file which is generated as report is done using C# and CSOM – So, in next blog post (Part 2) we will cover Binary Module using C# Class Library, PowerShell Module, String Manipulation and Data consolidation.

    Enjoy PowerShell !