Skip to content

Instantly share code, notes, and snippets.

View timothywarner's full-sized avatar

Tim Warner timothywarner

View GitHub Profile
function Get-ARMVM
{
$RGs = Get-AzureRMResourceGroup
foreach($RG in $RGs)
{
$VMs = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName
foreach($VM in $VMs)
{
$VMDetail = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName -Name $VM.Name -Status
$RGN = $VMDetail.ResourceGroupName
@timothywarner
timothywarner / install-chrome.ps1
Created February 22, 2018 14:23
Install Chrome browser with a PowerShell one-liner
$Path = $env:TEMP; $Installer = 'chrome_installer.exe'; Invoke-WebRequest -Uri 'http://dl.google.com/chrome/install/375.126/chrome_installer.exe' -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args '/silent /install' -Verb RunAs -Wait; Remove-Item -Path $Path\$Installer
# Thank you, nicolaigj!
@timothywarner
timothywarner / sync-ise-script.ps1
Created March 8, 2018 21:49
Synchronize ISE console location with current script
Set-Location -Path (Split-Path -Path $psISE.CurrentFile.FullPath)
@timothywarner
timothywarner / Reset-AzureRmVM.ps1
Last active April 20, 2018 21:28
Reset-AzureRMVM - Use with Azure Automation runbook to schedule VM startup and shutdown.
Workflow Reset-AzureRmVM
{
Param
(
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
[String]
$AzureSubscriptionId='',
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
[String]
$AzureVMList='',
@timothywarner
timothywarner / settings.json
Created April 16, 2019 15:24
Configure VSCode to launch multiple PowerShell versions (Windows)
{
// Set the default PowerShell engine for VSCode integrated terminal
"terminal.integrated.shell.windows": "c:/Program Files/PowerShell/6/pwsh.exe",
// Create Shell Launcher launch options
"shellLauncher.shells.windows": [
{
"shell": "c:\\Program Files\\PowerShell\\6\\pwsh.exe",
"label": "PowerShell Core"
},
@timothywarner
timothywarner / ps-service-principal-auth.ps1
Created April 17, 2019 14:38
Automate Azure PowerShell login with a service principal and self-signed certificate
$cert = New-SelfSignedCertificate -CertStoreLocation "cert:\CurrentUser\My" `
-Subject "CN=psauth1" `
-KeySpec KeyExchange
$keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
$sp = New-AzADServicePrincipal -DisplayName 'psauth1' `
-CertValue $keyValue `
-EndDate $cert.NotAfter `
-StartDate $cert.NotBefore
Start-Sleep -Seconds 20
@timothywarner
timothywarner / Get-AzServiceStatus.ps1
Created May 2, 2019 23:17
Get Azure global service status quickly and with no authentication needed.
# Thanks to Will Anderson for the inspiration (timw.info/rss)
Function Get-AzServiceStatus {
BEGIN {
Try {
Invoke-WebRequest -Uri 'https://azurecomcdn.azureedge.net/en-us/status/feed/' -OutFile "$env:TEMP\test.xml" -ErrorAction Stop
@timothywarner
timothywarner / unzip-files.ps1
Last active May 9, 2019 16:25
PowerShell one-liner to unpack all ZIPs in/to current directory.
Get-ChildItem -Path . -Filter *.zip | Expand-Archive -DestinationPath . -Force | Measure-Command
Get-ChildItem -Path . | Expand-Archive -Path .\*.zip -DestinationPath . -Force
@timothywarner
timothywarner / warner-az-blueprints.md
Last active May 28, 2020 15:58
Get Comfortable with Azure Blueprints

Get Comfortable with Azure Blueprints

Presenter

Azure Blueprint docs and tutorials