Category Archives: PowerShell

Azure PowerShell: Scale App Service Plan to Save Money

Here’s a bit of PowerShell to scale your Azure App Service down to save money. This task could be scheduled to “size down” at night, and “size up” for business hours.   Login-AzureRmAccount   $AppServicesJson = @" [ { "ResourceGroupName": … Continue reading

Posted in Azure, PowerShell | Leave a comment

Azure PowerShell: Querying Kudu WebJobs API

Here’s how you can query the Kudu WebJobs API to get the publishing credentials for an Azure App Service which in turn you can use to in a Basic authorization header of an HTTP request to get WebJob status etc. … Continue reading

Posted in Azure, PowerShell | Leave a comment

PowerShell: Generate Self-Signed Certificate and Encode to Base64

Here’s how you can generate a self-signed SSL certificate in PowerShell. Be sure to use an Administrative PowerShell session. After creating the self-signed certificate, you can also export the certificate as a .pfx file and encode the output to a … Continue reading

Posted in Azure, PowerShell | Leave a comment

Azure PowerShell: Deploy Linux Custom Script Extension

Here’s how you can deploy an Azure VM Extension via PowerShell: # Before running this, upload your bash script to an Azure storage account container, grab its name and key via PowerShell or the Azure portal   Login-AzureRmAccount   $Subscription … Continue reading

Posted in Azure, Bash, PowerShell | Leave a comment

PowerShell: Extract Files from Zip Archive

Here’s a quick PowerShell snippet to extract files from a .zip archive: Add-Type -Assembly System.IO.Compression.FileSystem   $PathToZipFile = "C:\temp\myarchive.zip" $ExtractPattern = "*.log" $ExtractDirectory = "C:\temp\extracted"   New-Item -ItemType Directory -Path $ExtractDirectory -Force | Out-Null   $ZipFile = [IO.Compression.ZipFile]::OpenRead($PathToZipFile) $ZipFile.Entries | … Continue reading

Posted in PowerShell | Leave a comment

Azure PowerShell: Copy All Files in Blob Storage to Local Directory

Here’s a Azure PowerShell script that downloads all blobs in a storage container to your local disk:   $storageAccountName = "mysuperstorage" $containerName = ‘my-blobs’ $destinationFolder = ‘C:\temp\my-blobs’   New-Item -ItemType Directory -Force -Path $destinationFolder   Login-AzureRmAccount   $storageAccountContext = (Get-AzureRmStorageAccount … Continue reading

Posted in Azure, PowerShell | Leave a comment