Created
April 14, 2015 12:22
Revisions
-
pkirch created this gist
Apr 14, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 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" ) # Get the Azure connection asset that is stored in the Automation service based on the name that was passed into the runbook $AzureConn = Get-AutomationConnection -Name $SubscriptionName # Get the Azure management certificate that is used to connect to this subscription $Certificate = Get-AutomationCertificate -Name $AzureConn.AutomationCertificateName # Set the Azure subscription configuration Set-AzureSubscription -SubscriptionName $SubscriptionName -SubscriptionId $AzureConn.SubscriptionID -Certificate $Certificate # Select the Azure subscription. Select-AzureSubscription -SubscriptionName $SubscriptionName $matchingCloudServices = Get-AzureService | Where-Object -Property ServiceName -ilike "$NamePrefix*" foreach -Parallel ($service in $matchingCloudServices) { Write-Warning "Removing $($service.ServiceName)" Remove-AzureService -ServiceName $service.ServiceName -DeleteAll -Force } $matchingStorageAccounts = Get-AzureStorageAccount | Where-Object -Property StorageAccountName -ilike "$NamePrefix*" foreach -Parallel ($storage in $matchingStorageAccounts) { Write-Warning "Removing $($storage.StorageAccountName)" Remove-AzureStorageAccount -StorageAccountName $storage.StorageAccountName } }