Share via


Start-AzureCloudService

Here's a function I use quite a lot. Now, I know it's old-world (ASM rather than ARM) in terms of Azure, but I still have a lot of old-world, cloud services. In fact, a lot of them were built by the following script and the function should be considered as partner code.

 

Build an Active Directory Forest in Microsoft Azure (IaaS)

110ec3a

 

 
function Start-AzureCloudService {

    #Define and validate mandatory parameters
    [CmdletBinding()]
    Param(
          #The Cloud Service name, e.g. IANCLOUD
          [parameter(Mandatory,Position=1,ValueFromPipeLine)]
          [ValidateScript({Get-AzureService -ServiceName $_})] 
          [String]$ServiceName,

          #Just start the DCs
          [switch]$DcOnly
          )


        Get-AzureVM -ServiceName $ServiceName | Where-Object {$_.Name -like "*DC0*"} | Start-AzureVM

        if (!$DcOnly) {
            Get-AzureVM -ServiceName $ServiceName | Where-Object {$_.Name -notlike "*DC0*"} | Start-AzureVM
        }
}

 
You need to supply the cloud service name and whether you want to start just the DCs in the cloud service or all of the VMs. The way the DCs are found (and the fact the cloud service contains DCs) is the reason why this is a complementary function.