Skip to content

Instantly share code, notes, and snippets.

@stuartleeks
stuartleeks / ImportAzureVmsIntoRdcMan.ps1
Last active February 24, 2017 15:43
PowerShell script to create a Remote Desktop Connection Manager configuration file for all Windows Azure Virtual Machines in a subscription.Requires Azure PowerShell cmdlets: http://www.windowsazure.com/en-us/documentation/articles/install-configure-powershell/. See this blog post for more info: http://blogs.msdn.com/b/stuartleeks/archive/2014/0…
$rdcmanName = "Azure VMs"
$outputFileName = Get-Location | Join-Path -ChildPath "AzureVMs.rdg"
$xml = [xml]'<?xml version="1.0" encoding="utf-8"?>
<RDCMan schemaVersion="1">
<version>2.2</version>
<file>
<properties>
<name>blog</name>
<expanded>True</expanded>
@stuartleeks
stuartleeks / ImportAzureVmsIntoRdcMan-2.ps1
Last active June 3, 2022 19:53
PowerShell script to create a Remote Desktop Connection Manager configuration file for all Windows Azure Virtual Machines and PaaS role instances in a subscription.Requires Azure PowerShell cmdlets: http://www.windowsazure.com/en-us/documentation/articles/install-configure-powershell/. See this blog post for more information: http://blogs.msdn.c…
$rdcmanName = "Azure VMs"
$outputFileName = Get-Location | Join-Path -ChildPath "AzureVMs.rdg"
$xml = [xml]'<?xml version="1.0" encoding="utf-8"?>
<RDCMan programVersion="2.7" schemaVersion="3">
<file>
<credentialsProfiles />
<properties>
<expanded>True</expanded>
<name>Azure VMs</name>
Get-ChildItem -Directory |%{
cd $_.FullName
git pull
cd..
}
@stuartleeks
stuartleeks / baz
Last active August 29, 2015 14:16
dummy gist
baz
@stuartleeks
stuartleeks / APIM-backup.ps1
Last active February 4, 2019 10:43
Script to expose commands for backing up and restoring Azure API Management configuration. See http://blogs.msdn.com/b/stuartleeks/archive/2015/04/29/azure-api-management-backing-up-and-restoring-configuration.aspx
# This accompanies http://blogs.msdn.com/b/stuartleeks/archive/2015/04/29/azure-api-management-backing-up-and-restoring-configuration.aspx
#
# see http://azure.microsoft.com/en-us/documentation/articles/api-management-howto-disaster-recovery-backup-restore/
# Auth for ARM: https://msdn.microsoft.com/library/dn790557.aspx
function Get-ArmToken
{
# Somewhat dirty approach as it uses values not directly obtained from cmdlets! But it saves provisioning an Azure AD application!
[CmdletBinding()]
param (
@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>
@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 {
@stuartleeks
stuartleeks / dockerps.ps1
Last active August 29, 2015 14:25
PowerShell-friendly docker ps parsing
function PascalName($name){
$parts = $name.Split(" ")
for($i = 0 ; $i -lt $parts.Length ; $i++){
$parts[$i] = [char]::ToUpper($parts[$i][0]) + $parts[$i].SubString(1).ToLower();
}
$parts -join ""
}
function GetColumnInfo($headerRow, $propertyNames){
$lastIndex = 0
$lastName = $null
@stuartleeks
stuartleeks / CustomConfigurationManager.cs
Last active October 13, 2016 12:23
CustomConfigurationManager - pre ASP.NET 5 helper for working with environment variables for app settings
using System;
using System.Configuration;
public static class CustomConfigurationManager
{
private static CustomAppSettings _appSettings = new CustomAppSettings();
public static CustomAppSettings AppSettings { get { return _appSettings; } }
}
public class CustomAppSettings
{
@stuartleeks
stuartleeks / AzureRmAuth.ps1
Created November 5, 2015 21:01
Hack to get AccessToken for ARM from current PowerShell context
# Working on 1.0.0 preview of Azure PowerShell cmdlets
function GetAccessToken(){
$psContext = Get-AzureRmContext
$context = [Microsoft.Azure.Common.Authentication.Models.AzureContext] $psContext
$account = $context.Account
$environment= $context.Environment
$tenant = $context.Tenant
$authFactory = [Microsoft.Azure.Common.Authentication.AzureSession]::AuthenticationFactory