Hello guys, I’m posting the scripts of webinar demos I’ve presented in conjunction with the MVP Josué Vidal of tips and tricks on Hybrid Cloud management at day 18/09. In case any doubts remain you can contact me through the blog’s contact form .
Webinar’s recording is avaliable through this link: HERE
Deallocating machines that are only turned off, not deprovisioned:
$AzureVMs = Get-AzureVM foreach($vm in $AzureVMs){ if($vm.Status -eq 'StoppedVM'){ Stop-AzureVM -Name $vm.Name -ServiceName $vm.ServiceName -Force } }
Configuring azure’s subscription on Powershell:
Add-AzureAccount Get-AzurePublishSettingsFile Import-AzurePublishSettingsFile -PublishSettingsFile "Caminho do arquivo Baixado" $Certificate = Get-Item Cert:CurrentUserMySubstitua_Pelo_Thumbprint_do_da_Subscription $SubscriptionId = "ID da sua Subscription" $SubscriptionName = "Nome da sua Subscription" $StorageAccountName = "Sua conta de storage" Select-AzureSubscription -SubscriptionName $SubscriptionName Set-AzureSubscription -SubscriptionId $SubscriptionId -CurrentStorageAccountName $StorageAccountName -SubscriptionName $SubscriptionName -Certificate $Certificate
Creating a Azure Virtual Machine through Powershell:
$ImageName = (Get-AzureVMImage | where { $_.label -eq "Windows Server 2008 R2 SP1, September 2014" }).ImageName $ServiceName = $VNetName = $VM = New-AzureVMConfig -Label 'guidooliveira' -Name 'guidooliveira' -InstanceSize Small -ImageName $ImageName ` | Add-AzureProvisioningConfig -Windows -Password 'P2ssw0rd' -AdminUsername 'PsTestAdmin' -DisableAutomaticUpdates:$true ` | Set-AzureSubnet -SubnetNames 'Subnet-1' ` | Add-AzureEndpoint -LocalPort 3389 -Name 'RDP' -Protocol tcp -PublicPort 50101 ` | Add-AzureEndpoint -LocalPort 5986 -Name 'Powershell' -Protocol tcp -PublicPort 54355 ` | Add-AzureEndpoint -LocalPort 1433 -Name 'MSSQLSERVER' -Protocol tcp -PublicPort 64222 ` | Add-AzureDataDisk -CreateNew -DiskSizeInGB (250Gb) -LUN 0 -MediaLocation "Brazil South" New-AzureVM -ServiceName $ServiceName -VMs $VM -VNetName $VNetName -Verbose
Bulk creating virtual machines on azure through Powershell:
"Chapatin","Chespirito","Chaves" -split "," | ForEach-Object -Process { New-AzureService -ServiceName $_ -Location "Brazil South" -Verbose $VMConfig = New-AzureVMConfig -Label $_ -Name $_ -InstanceSize Small -ImageName $ImageName ` | Add-AzureProvisioningConfig -Windows -Password 'P@ssw0rd!!' -AdminUsername 'PsTestAdmin' -DisableAutomaticUpdates:$true ` | Set-AzureSubnet -SubnetNames 'Subnet-1' ` | Add-AzureEndpoint -LocalPort 3389 -Name 'RDP' -Protocol tcp -PublicPort 50101 ` | Add-AzureEndpoint -LocalPort 5986 -Name 'Powershell' -Protocol tcp -PublicPort 54355 New-AzureVM -ServiceName $_ -VMs $VMConfig -VNetName 'VlanRecife' -Verbose }
Doubts? Suggestions? Comment!
Until next time!
1 Comments
up