Skip to content

Commit

Permalink
Add SHM VM shutdown scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
martintoreilly committed Aug 9, 2019
1 parent 58524dc commit bb12e8d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
20 changes: 20 additions & 0 deletions safe_haven_management_environment/Shutdown_SHM_Deployment_VMs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
param(
[Parameter(Position=0, Mandatory = $true, HelpMessage = "Enter DSG ID (usually a number e.g enter '9' for DSG9)")]
[string]$shmId
)

Import-Module Az
Import-Module $PSScriptRoot/../new_dsg_environment/dsg_deploy_scripts/DsgConfig.psm1 -Force

# Get SHM config
$config = Get-ShmFullConfig($shmId)

# Temporarily switch to SHM subscription
$prevContext = Get-AzContext
$_ = Set-AzContext -SubscriptionId $config.subscriptionName;

Write-Host "===Stopping all Deployment Servers==="
Get-AzVM -ResourceGroupName "RG_SHM_DEPLOYMENT_POOL" | Stop-AzVM -Force -NoWait

# Switch back to original subscription
$_ = Set-AzContext -Context $prevContext;
23 changes: 23 additions & 0 deletions safe_haven_management_environment/Shutdown_SHM_IAAM_VMs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
param(
[Parameter(Position=0, Mandatory = $true, HelpMessage = "Enter DSG ID (usually a number e.g enter '9' for DSG9)")]
[string]$shmId
)

Import-Module Az
Import-Module $PSScriptRoot/../new_dsg_environment/dsg_deploy_scripts/DsgConfig.psm1 -Force

# Get SHM config
$config = Get-ShmFullConfig($shmId)

# Temporarily switch to SHM subscription
$prevContext = Get-AzContext
$_ = Set-AzContext -SubscriptionId $config.subscriptionName;

Write-Host "===Stopping NPS Server==="
Stop-AzVM -ResourceGroupName $config.nps.rg -Name $config.nps.vmName -Force -NoWait
Write-Host "===Stopping AD DCs==="
Stop-AzVM -ResourceGroupName $config.dc.rg -Name $config.dc.vmName -Force -NoWait
Stop-AzVM -ResourceGroupName $config.dc.rg -Name $config.dcb.vmName -Force -NoWait

# Switch back to original subscription
$_ = Set-AzContext -Context $prevContext;
20 changes: 20 additions & 0 deletions safe_haven_management_environment/Shutdown_SHM_Mirror_VMs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
param(
[Parameter(Position=0, Mandatory = $true, HelpMessage = "Enter DSG ID (usually a number e.g enter '9' for DSG9)")]
[string]$shmId
)

Import-Module Az
Import-Module $PSScriptRoot/../new_dsg_environment/dsg_deploy_scripts/DsgConfig.psm1 -Force

# Get SHM config
$config = Get-ShmFullConfig($shmId)

# Temporarily switch to SHM subscription
$prevContext = Get-AzContext
$_ = Set-AzContext -SubscriptionId $config.subscriptionName;

Write-Host "===Stopping all Mirror Servers==="
Get-AzVM -ResourceGroupName "RG_SHM_PKG_MIRRORS" | Stop-AzVM -Force -NoWait

# Switch back to original subscription
$_ = Set-AzContext -Context $prevContext;

0 comments on commit bb12e8d

Please sign in to comment.