Skip to content

Instantly share code, notes, and snippets.

@stuartleeks
stuartleeks / Visual Studio Code - Dark.ps1xml
Created July 1, 2015 12:44
Powershell ISE theme - VS Code Dark
<?xml version="1.0" encoding="utf-16"?>
<StorableColorTheme xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Keys>
<string>ErrorForegroundColor</string>
<string>ErrorBackgroundColor</string>
<string>WarningForegroundColor</string>
<string>WarningBackgroundColor</string>
<string>VerboseForegroundColor</string>
<string>VerboseBackgroundColor</string>
<string>DebugForegroundColor</string>
#!/bin/bash
############################################################################################
#
# Script used testing access to an Azure storage account with a private endpoint
#
############################################################################################
#
# Argument parsing
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateSet("Top", "Bottom")]
[string]
$Position
)
# 0 - Left (doesn't work well)
# 1 - Top
function OutputStatus($message){
try {
[Console]::SetCursorPosition(0,0)
Write-Host $message.PadRight([Console]::BufferWidth)
}
catch [System.IO.IOException] {
## IO Exception when unable to set position
}
}
$messages = @()
@stuartleeks
stuartleeks / GenerateTemplateParameters.ps1
Created January 14, 2016 21:05
Generate parameters for Azure Resource Manager template
param(
$templateFile,
[switch] $includeParametersWithDefaults
)
$template = Get-Content $templateFile | ConvertFrom-Json
function getDefaultValue($type){
switch ($type){
"bool" {'false'}
"int" {0}
@stuartleeks
stuartleeks / GetDeploymentOperationSummary.ps1
Created November 13, 2015 10:00
ARM deployment operations - PowerShell, CLI
param($resourceGroupName)
# note that this requires jq: https://stedolan.github.io/jq/download/
$deploymentName=$(azure group deployment list $resourceGroupName --json | jq "[.[] | {name:.name, timestamp: .properties.timestamp } ] | sort_by(.timestamp) | reverse | .[0].name" --raw-output)
azure group deployment operation list --resource-group $resourceGroupName --name $deploymentName --json | jq '[.[] | .properties | { provisioningState : .provisioningState, timestamp: .timestamp, resourceType:.targetResource.resourceType,resourceName:.targetResource.resourceName}] | sort_by(.timestamp)'
@stuartleeks
stuartleeks / GetDeploymentErrors.ps1
Created November 11, 2015 14:04
ARM deployment operation utils
# gets information for non-succeeded deployment operations for the last deployment for the resource group specified in $resourceGroupName
Get-AzureResourceGroupDeployment -ResourceGroupName $resourceGroupName | sort -Descending -Property Timestamp | select -First 1 | Get-AzureResourceGroupDeploymentOperation | ?{ $_.Properties.ProvisioningState -ne "Succeeded" } | select -ExpandProperty Properties | ConvertTo-Json
@stuartleeks
stuartleeks / Find-InPath.ps1
Created July 2, 2015 14:06
Find-InPath.ps1 - simple PowerShell Script to find files in the PATH
[CmdletBinding()]
param (
[string] $filename
)
$matches = $env:Path.Split(';') | %{ join-path $_ $filename} | ?{ test-path $_ }
if ($matches.Length -eq 0){
"No matches found"
} else {
$env:HOME="" # avoid conflicts with devcontainers across OSes
$env:GIT_SSH="C:\Windows\System32\OpenSSH\ssh.exe" # set git to use the OpenSSH install and pick up keys from the SSH Agent (avoiding prompting for passphrases)
function Get-KeyState([uint16]$keyCode)
{
$signature = '[DllImport("user32.dll")]public static extern short GetKeyState(int nVirtKey);'
$type = Add-Type -MemberDefinition $signature -Name User32 -Namespace GetKeyState -PassThru
return [bool]($type::GetKeyState($keyCode) -band 0x80)
}
$VK_SHIFT = 0x10
function OutputStatus($message){
try {
[Console]::SetCursorPosition(0,0)