Manage your AzureVMs

If you are handling by first time the Azure subscription, you can put the face as sitting in the millennial falcon… what this button stands for??

don’t worry, Azure is bringing so much that is simply impossible to afford all in a month. you keep learning all the time about it.

The Azure team, and the Office 365 got a plan, and they bring new capabilities every couple of weeks. as MCT we get a message directly from corp. where we was clearly advised to handle this courses with the actual material, and this MOC will be updated more frequently, than regular ones.

so, get back to the intention of this post. how can I manage my remaining U$200 of my trial, and stretch it so much as I can. well. first, if you’re patient, use the GUI and turn on/off your machines every time you’re gonna use them. if you don’t, try installing the Azure PowerShell module, https://azure.microsoft.com/en-us/downloads/ and then run the following  script to start your AzureVMs.

——————————————————-
Start-AzureVM -ServiceName CloudDemo001 -Name BOGDC01
——————————————————-
Import-module azure
Import-AzurePublishSettingsFile -PublishSettingsFile ‘c:\users\fcamp\Downloads\MSDN-11-5-2015-credentials.publishsettings’
Param(
[string]$servicename,
[string]$name,
[string]$userName,
[string]$password
)
$servicename = ‘CloudDemo001’
#get-AzureVM -ServiceName CloudDemo001 |ft
$name = ‘BOGDC01’
$userName = ‘admin’
$password = “WarMachineIsTheBest”
$vm = Get-AzureVM -ServiceName $servicename -Name $name
If ($vm.InstanceStatus -ne ‘ReadyRole’)
{
Write-Host (“VM is not running. InstanceStatus:” + $vm.instancestatus)
}
Else
{
$port = ($vm.VM.ConfigurationSets.Inputendpoints | Where { $_.LocalPort -eq 5986 }).Port
$vip = ($vm.VM.ConfigurationSets.Inputendpoints | Where { $_.LocalPort -eq 5986 }).Vip
$uri = (‘https://’ + $vip + ‘:’ + $port)

$Credential = New-Object System.Management.Automation.PSCredential($username, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
$SessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -NoMachineProfile
$PSSession = New-PSSession -ConnectionUri $uri -Credential $Credential -SessionOption $SessionOption

Enter-PSSession $PSSession
}

——————————————————-
Stop-AzureVM -ServiceName CloudDemo001 -Name BOGDC01
——————————————————-
Function Get-Uptime {
<#
.SYNOPSIS
Displays Uptime since last reboot
.PARAMETER  Computername
.EXAMPLE
Get-Uptime Server1
.EXAMPLE
“Server1”, “Server2″|Get-Uptime
.EXAMPLE
(Get-Uptime Sever1).”Time Since Last Reboot”
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True,ValueFromPipeline=$true,Position=0)]
[STRING[]]$Computername
)

Begin {Write-Verbose “Version 1.00”}

Process {
$Now=Get-Date
$LastBoot=[System.Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject win32_operatingsystem -ComputerName $computername).lastbootuptime)
$Result=@{ “Server”=$($Computername);
“Last Reboot”=$LastBoot;
“Time Since Reboot”=”{0} Days {1} Hours {2} Minutes {3} Seconds” -f ($Now – $LastBoot).days, `
($Now – $LastBoot).hours,($Now – $LastBoot).minutes,($Now – $LastBoot).seconds}
Write-Output (New-Object psobject -Property $Result|select Server, “Last Reboot”, “Time Since Reboot”)
}
}

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s