Skip to content

Instantly share code, notes, and snippets.

View pkirch's full-sized avatar

Peter Kirchner pkirch

View GitHub Profile
"--> Set for current storage account. Only necessary for 2nd example."
Set-AzureSubscription -SubscriptionName "MSFT MVA Stage" -CurrentStorageAccountName "storagesource"
"--> Get keys for storage accounts storagesource and storagedestination."
$keys1 = Get-AzureStorageKey -StorageAccountName storagesource
$keys2 = Get-AzureStorageKey -StorageAccountName storagedestination
"--> Create two storage contexts for storagesource and storagedestination."
$contextSource = New-AzureStorageContext -StorageAccountName $keys1.StorageAccountName -StorageAccountKey $keys1.Primary
$contextDestination = New-AzureStorageContext -StorageAccountName $keys2.StorageAccountName -StorageAccountKey $keys2.Primary
"--> Set current storage account."
Set-AzureSubscription -SubscriptionName "MSFT MVA Stage" -CurrentStorageAccountName "storagesource"
"--> Get blobs from containers 'source1' and 'source2' from current storage account (storagesource)."
Get-AzureStorageBlob -Container source1
Get-AzureStorageBlob -Container source2
"--> Copy all BLOBs with pattern '*.txt' from container 'source1' into 'source2'. The copy command shows processed BLOBs."
Get-AzureStorageBlob -Blob "*.txt" -Container source1 | Start-AzureStorageBlobCopy -DestContainer source2
"--> Set current storage account."
Set-AzureSubscription -SubscriptionName "MSFT MVA Stage" -CurrentStorageAccountName "storagesource"
"--> Get blobs from containers 'source1' and 'source2' from current storage account (storagesource)."
Get-AzureStorageBlob -Container source1
Get-AzureStorageBlob -Container source2
"--> Copy BLOBs from container 'source1' into 'source2'. Each copy command shows the copied BLOBs."
"--> Copy BLOB 'Test1.txt'."
Start-AzureStorageBlobCopy -SrcBlob "Test1.txt" -SrcContainer source1 -DestContainer source2
@pkirch
pkirch / Get-AzureVMImageWinSvr2012R2.ps1
Created March 30, 2015 09:28
This sample shows how to get the latest VM image for the image family "Windows Server 2012 R2 Datacenter" via PowerShell in Azure.
$images | Where-Object -Property ImageFamily -eq "Windows Server 2012 R2 Datacenter" | Format-List -Property ImageName, Label, PublishedDate
<# Output
ImageName : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201410.01-en.us-127GB.vhd
Label : Windows Server 2012 R2 Datacenter, October 2014
PublishedDate : 28.10.2014 08:00:00
ImageName : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201411.01-en.us-127GB.vhd
Label : Windows Server 2012 R2 Datacenter, November 2014
@pkirch
pkirch / Get-AzureVMImageGroupImageFamily.ps1
Created March 30, 2015 09:23
This sample shows Azure VM images grouped by ImageFamily.
$images | Group-Object -Property ImageFamily | Sort-Object -Property Name | Format-Table -Property Count, Name -AutoSize
<# Output
Count Name
----- ----
7
2
2 Barracuda NG Firewall 5.4
3 Barracuda Web Application Firewall (WAF) 7.8
@pkirch
pkirch / Get-AzureVMImageGroupPublisherNameSample.ps1
Created March 30, 2015 09:21
This sample shows Azure VM images grouped by PublisherName.
$images | Group-Object -Property PublisherName | Sort-Object -Property Name | Format-Table -Property Count, Name -AutoSize
<# Output
Count Name
----- ----
5 Barracuda Networks, Inc.
4 Bitnami
72 Canonical
1 Cloudera
@pkirch
pkirch / Get-AzureVMImageSample.ps1
Created March 24, 2015 12:21
This sample shows the output of the a single image returned by Get-AzureVMImage in PowerShell.
$images[0]
<# Output
ImageName : 03f55de797f546a1b29d1b8d66be687a__Team-Foundation-Server-2013-Update4-WS2012R2
OS : Windows
MediaLink :
LogicalSizeInGB : 128
AffinityGroup :
Category : Public
@pkirch
pkirch / VNetSample.xml
Created March 12, 2015 18:29
Sample XML configuration of an Azure virtual network configuration.
<?xml version="1.0" encoding="utf-8"?>
<NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.m
icrosoft.com/ServiceHosting/2011/07/NetworkConfiguration">
<VirtualNetworkConfiguration>
<Dns>
<DnsServers>
<DnsServer name="DC1" IPAddress="10.0.0.4" />
</DnsServers>
</Dns>
<VirtualNetworkSites>
@pkirch
pkirch / Get-AzureVNetSiteSample.ps1
Created March 12, 2015 18:24
This sample shows the output of the PowerShell command Get-AzureVNetSite.
Get-AzureVNetSite
<# Output
AddressSpacePrefixes : {10.0.0.0/8}
Location : West Europe
AffinityGroup :
DnsServers : {DC1}
GatewayProfile :
GatewaySites :
@pkirch
pkirch / Get-AzureStorageAccountSelectSample.ps1
Created February 27, 2015 12:59
This short PowerShell sample shows how to select only the storage account names of all storage accounts in an Azure subscription.
Get-AzureStorageAccount | Select-Object -Property StorageAccountName
<# Output
StorageAccountName
------------------
pkstoragesample1
pktest1
#>