Azure Monitor Alert when VM is not available/Shutdown Down

Assuming you connected Virtual machine to Log Analytics already . Now You can run below powershell

Convert pfx certificate to base64 string using Powershell

To get Certificate data from PFX File Run below Script in powershell.


To Export it to a text file



Export data from All SQL tables within a Database in CSV format- Using Powershell


Here is the script you can use to export all the data from SQL tables within a given database into csv format. This script is purely powershell based.


List all the Classsic Azure VMs

Below script will list all the Classic VMs in azure .



Some useful OMS Queries

Percentage CPU Usage

Perf | where CounterName == “% Processor Time” | summarize avg(CounterValue) by Computer

Percentage Memory Usage

Perf | where CounterName == “% Committed Bytes In Use” | summarize avg(CounterValue) by Computer

Remove Header from Powershell get output

When you select one column in output of get command and then try to use it in a for loop you see each line is embedded in Curly braces {}

Instead of using select xyz you will use ForEach-Object {$}



Export /Import ADFS Claim Rules for your relying party trusts to a text file

Sometimes you might be bored creating similar/same claim rules accross your enviornments . Below method will quickly help you export your claim rules and apply to different relying party trust

Step1 : Export to a text file 


Step 2 : Apply /Set your claim rules from text file you exported in last step 


Multi-Home OMS Agent using powershell

You can run below script on the VM iteself to talk to multiple workspaces. One Microsoft Monitoring Agent can talk to upto 4 workspaces. You can embed this into Remote PS-Session if you want to use PSRemoting.


ADFS second node not authenticating after certificate renewal

If you are getting below error

Event 15021 HttpEvent

An error occurred while using SSL configuration for endpoint  The error status code is contained within the returned data.


Here is the fix.

  1. Import New Certificate on Personal store.
  2. Get Service Comms Certificate thumbprint and run below on node 2



Cross Subscription or Tenant VNET to VNET VPN Gateway


There are 2 tenants , Tenant A and B.

They both have existing infrastructure in their subscriptions. Due to organisational merge they want to connect VNETs together on Azure Fabric keep both sides secure.

On both the sides they have Express route and doesnt have enough bandwidth on gateway subnet to house a gateway.

How do we do this ? 

they will need to use VNET to VNET VPN gateway is the solution.

In subscription A

In subscription B

VNET 1 to VNET 2 are connected via VNET- VNET Peering you choose the option “Use remote gateways”. For vnet 2 you select “Allow gateway transit”.
VNET 3 to VNET 4 are connected via VNET- VNET Peering Do the same for subscription B, except, vnet D will use remote gateway, and C will allow it.

VNET 2 VNET 4 are connected via cross subscription VPN Site-to-Site Gateway


Use VPN Gateway between 3 and 4 .