Skip to content

Instantly share code, notes, and snippets.

View pkirch's full-sized avatar

Peter Kirchner pkirch

View GitHub Profile
# Microsoft Virtual Academy
# Automatisierte Konfiguration in Azure im Überblick
# 203 - http://aka.ms/mva-1505-203
#region Create VM
# Settings
$subscriptionName = "MSFT MVA Live" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "mvaconfig203"
# Microsoft Virtual Academy
# Automatisierte Konfiguration in Azure im Überblick
# 202 - http://aka.ms/mva-1505-202
#region Create VM
# Settings
$subscriptionName = "MSFT MVA Stage" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "mvaconfig204"
# Microsoft Virtual Academy
# Automatisierte Konfiguration in Azure im Überblick
# 201 - http://aka.ms/mva-1505-201
#region Create VM
# Settings
$subscriptionName = "MSFT MVA Stage" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "mvaconfig202"
# Microsoft Virtual Academy
# Automatisierte Konfiguration in Azure im Überblick
# 200 - http://aka.ms/mva-1505-200
# Settings
$subscriptionName = "MSFT MVA Live" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "mvaconfig200"
$storageAccountName = $serviceName
$adminUsername = "adm_demo"
# 101
# Settings
$subscriptionName = "MSFT MVA Stage" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "mvaconfig101"
$storageAccountName = $serviceName
$adminUsername = "adm_demo"
$adminPassword = "Azureisttoll!"
$imageFamily = "Windows Server 2012 R2 Datacenter"
@pkirch
pkirch / CreateSnapshot.ps1
Created April 28, 2015 08:57
Create a snapshot of an Azure BLOB via PowerShell.
# step 1: get file
$blobFile = Get-AzureStorageBlob -Container source | Where-Object -Property Name -eq "version.txt"
# step 2: create snapshot
$cloudBlob = $blobFile.ICloudBlob
$cloudBlob.CreateSnapshot()
# step 3: get snapshots
$snapshot = Get-AzureStorageBlob -Container source | Where-Object -Property SnapshotTime
@pkirch
pkirch / Stop-ITCampManagementVMs.ps1
Created April 14, 2015 12:22
PowerShell Workflow script for Azure Automation to remove a bulk of VMs. (For production use you should add some error handling.)
workflow Stop-ITCampManagementVMs
{
Param (
# Name of the target Azure subscription.
[Parameter(Mandatory=$True)]
[String]$SubscriptionName = "MSFT IT Camp Stage",
[Parameter(Mandatory=$False)]
[String]$NamePrefix = "itc0203"
)
@pkirch
pkirch / Start-ITCampManagementVMs.ps1
Created April 14, 2015 12:19
PowerShell Workflow script for Azure Automation to create a bulk of VMs. (For production use you should add some error handling.)
workflow Start-ITCampManagementVMs
{
Param (
# Name of the target Azure subscription.
[Parameter(Mandatory=$True)]
[String]$SubscriptionName = "MSFT IT Camp Stage",
[Parameter(Mandatory=$False)]
[String]$AdminUsername = "adm_camp",
[Parameter(Mandatory=$False)]
[String]$AdminPassword = "Azureisttoll!",
Get-AzureStorageBlobCopyState -Blob copy2.vhd -Container destination
<# Output
CopyId : 0c61d2d2-5cc8-4936-8800-1690b17d71f3
CompletionTime : 05.01.2015 15:53:08 +00:00
Status : Success
Source : https://pkdestination.blob.core.windows.net/backup/fixedvhd2.vhd
BytesCopied : 20972032
TotalBytes : 20972032
# Get all BLOBs from source container and start copy operation asynchronously for all files based on $fileFilter.
Get-AzureStorageBlob -Context $sourceStorageContext -Container $sourceStorageContainer -Blob $fileFilter |
Start-AzureStorageBlobCopy -DestContext $destinationStorageContext -DestContainer $destinationStorageContainer
# Check copy state in destination container.
$waitTime = 5 # Initial wait time.
do {
# Wait some time before refresh of copy state, except on first iteration.
if ($copyState) {
Write-Host "Refresh in $waitTime seconds."