WordPress.com



# PowerShell code- Deepak Kaushik# Do Not continue in case of an error$ErrorActionPreference = "Stop" # Connect to a connection to get SubscriptionId & TenantId$Connection = Get-AutomationConnection -Name "AzureRunAsConnection"$TenantId = $Connection.TenantId$SubscriptionId = $Connection.SubscriptionId # Get the Credentials for the automation account. $SPCredential = Get-AutomationPSCredential -Name "AzureDWHAutomation" # Login to Azure ($null is to prevent output)Write-Output "Login to Azure using automation account 'AzureDWHAutomation'."$null = Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $SubscriptionId -Credential $SPCredential # Select the correct subscriptionWrite-Output "Selecting subscription '$($SubscriptionId)'."$null = Select-AzureRmSubscription -SubscriptionID $SubscriptionId # Get variables $ResourceGroupName = Get-AutomationVariable -Name 'ResourceGroupName'$ServerName = Get-AutomationVariable -Name 'ServerName'$DatabaseName = Get-AutomationVariable -Name 'DatabaseName' # Check old status (for testing/logging purpose only)$OldDbSetting = Get-AzureRmSqlDatabase -DatabaseName $DatabaseName -ServerName $ServerName -ResourceGroupName $ResourceGroupName$OldStatus = $OldDbSetting.Status #Write-Output "Resuming $($DatabaseName). Current status: $($OldStatus)" #$null = Resume-AzureRmSqlDatabase -DatabaseName $DatabaseName -ServerName $ServerName -ResourceGroupName $ResourceGroupName Write-Output "Pausing $($DatabaseName). Current status: $($OldStatus)"$null = Suspend-AzureRmSqlDatabase -DatabaseName $DatabaseName -ServerName $ServerName -ResourceGroupName $ResourceGroupName # once finished Write Output Write-Output "Done" ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download