Tag: PowerShell
-
Azure Functions (PowerShell) : Find the current FunctionApp and Function names
I was writing an Azure Function in PowerShell. I wanted to know the name of the current FunctionApp and the current Function. Since it was a timer triggered function, I couldn’t pass the names. It took me a while to to figure this out. There may be other ways, but this only way I could…
-
Quick 1 liner to download your Azure Billing Statements
Simple and quick – I had never done it before. I was working on a different script, but I realized that I have never downloaded my billing statements from azure. Simple 1 liner to download them: Hope that helps someone!
-

PowerShell to get the cost of a VM per day
I wanted to get the cost of a VM each day. I came up with the following code. Just the VM cost, not the ingress (DataTrIn) or egress (DataTrOut). I hope it helps someone!
-

PowerShell: Remove old Az modules
I recently ran a Get-Modules -ListAvaiable and I saw a lot of older versions: I wanted to remove all versions except the most recent. Here is my script: Hope that helps someone.
-
Using Azure Resource Graph for your inventory script
In the past I have always run Get-AzureRmResourceGroup, and then looped through all the resources groups and the VMs inside of them. This can be slow. So I put together this script to leverage Azure Resource Graph for your inventory. I hope this helps some one: This pulls back everything and then you can pull…
-
Add a Document to CosmosDB via the REST API using PowerShell
There are a lot of examples out there on how to POST a document to Cosmos DB, but they weren’t working for me. I kept getting a 400 Bad Request. After far to long, I finally got it to work. I need the “x-ms-documentdb-partitionkey” header to make it work. Code for anyone who needs it…
-
Connecting to the Azure REST API from an Azure Automation RunBook
I was looking for data that I couldn’t find in a PowerShell command, so I needed an access token to run a query against an Azure API. I was stuck with the basic problem of how do I query the Azure REST endpoints from a RunBook. In my last post, I just learned that you…
-
Azure Runbook to enable Auto-Shutdown for New VMs
I have an azure lab subscription (as do you, I am sure). In this lab, I am always provisioning and deleting and scaling VMs. In order to keep my costs down, I want to enable the AutoShutdown feature on all new VMs. I can do that easily with an ARM template. But for machines that…
-
Moving to the new (and future) Azure PowerShell Module : Az
It looks like we need to move to the new Az module. It is not required, but future functionality will not be added to AzureRM, so I decided to make the switch. Here is how I went about it. First, to enable backwards compatibility, you need to add this command to your profile : “Enable-AzureRmAlias”…
-
Code to query Azure Load Balancer Metrics to verify Availability (VipAvailability )
This one was fun to put together. I wanted to write code to query the status of an Azure Load Balancer. I couldn’t find much out there. This code query’s the Azure Load Balancer’s Metrics for VipAvailability – through the REST API. If it returns 100 then are good to go. Anyting else, then there may…
