Showing posts with label virtual machines. Show all posts
Showing posts with label virtual machines. Show all posts

Sunday, March 1, 2015

Azure Virtual Machines (VMS) Powershell Remote (WinRM), function that skips the CA validation. 


Function Enter-AZSession ($VMRM){ if ($VMRM.status -ne "ReadyRole") {Write-Error "VM Status is not ReadyRole";break} else { Write-Host “Connecting to hostname: " -ForeGroundColor Yellow -NoNewLine; $($VMRM.VM.RoleName) Enter-PSSession -ConnectionUri ($VMRM|Get-AzureWinRMUri) -Credential (Get-Credential) -SessionOption (New-PSSessionOption -SkipCACheck:$true)} }

#powershell
#azure
#iaas
#virtual machines
#remote
#powershell
#winrm
#CA
#PSSession
#VM

Saturday, September 6, 2014

Deploy 10 Virtual Machines in Azure

 

Prompts for ServiceName, also securely passes Admin/Pass to Add-AzureProvisioningConfig

Creates 10 Servers hostname: Thing#

 

<#

 

.NOTES

Author: Drew Robinson

Last Updated: 9/2/2014

#>

 

 

# Change color to yellow, prompt human for Servicename, reset color back to default

[console]::ForegroundColor = "yellow"

 

$Servicename = Read-Host -Prompt "Please Enter Servicename for this deployment: (servicename is the internet facing name, [name].cloudapp.net)"

 

[console]::ResetColor()

 

# Get Credentials (secure)

$Cred=Get-Credential -Message "Please Enter the Administrator Username and Password for the VMs, note: you can't use Admin/Administrator, password must be complex"

 

# Get-VM Images and filter Windows Server 2012 R2

$VMImages=Get-AzureVMImage |Where-Object {($_.PublisherName -ilike "Microsoft*" -and $_.ImageFamily -ilike 'Windows Server 2012 R2 Datacenter') }

 

# 1..10 = array of of 10 things, $_ = put array # here

 

1..10 |ForEach {$VMName = "thing$_"

New-AzureVMConfig -Name $VMName -InstanceSize "ExtraSmall" -ImageName $vmimages[1].ImageName |Add-AzureProvisioningConfig -Windows -AdminUsername $cred.UserName -Password $Cred.GetNetworkCredential().password -TimeZone "Central Standard Time" -Verbose |Add-AzureDataDisk -CreateNew -DiskSizeInGB '15' -DiskLabel "disk 1" -LUN '0' |New-AzureVM -location 'South Central US' -servicename $Servicename -Verbose

}