Skip to content

Instantly share code, notes, and snippets.

View chelnak's full-sized avatar
👀
What's cooking?

Craig Gumbley chelnak

👀
What's cooking?
View GitHub Profile
@chelnak
chelnak / ListBusinessGroupsAndMembers.ps1
Created July 25, 2016 14:48
List all Business Groups and their members with PowervRA
Get-vRABusinessGroup | Select Name, @{Name="GroupManagers"; Expression={$_.GroupManagerRole.Name}}, @{Name="SupportUsers"; Expression={$_.SupportUserRole.name}}, @{Name="BuisinessUsers"; Expression={$_.UserRole.name}}
@chelnak
chelnak / GetResourcesAndReservation.ps1
Created July 25, 2016 14:47
Get all resources and show their reservation with PowervRA
Get-vRAConsumerResource -WithExtendedData | ? {$_.ResourceType -eq "Infrastructure.Virtual"} | Select ResourceId, Name, @{Name="Reservation"; Expression={$_.Data.MachineReservationName}} | Sort-Object -Property Reservation, Name
@chelnak
chelnak / GetAllMachinesInReservation.ps1
Created July 25, 2016 14:46
Get all machines in a reservation with PowervRA
$ReservationName = "Reservation1"
$CatalogResources = Get-vRAConsumerResource -WithExtendedData | ? {($_.ResourceType -eq "Infrastructure.Virtual") -and ($_.Data.MachineReservationName -eq $ReservationName)}
$CatalogResources | Select ResourceId, Name, @{Name="Reservation"; Expression={$_.Data.MachineReservationName}}
@chelnak
chelnak / RequestACatalogItem.ps1
Created July 25, 2016 14:45
Request a catalog item using a template and wait for completion with PowervRA
(Get-Content .\code\vRO\CatalogItem1.json -raw) | Request-vRAConsumerCatalogItem -Verbose -Wait
@chelnak
chelnak / TailInProgressRequest.ps1
Created July 25, 2016 14:43
Tail a request that is in progress with PowervRA
while($true) {(Get-vRAConsumerRequest -RequestNumber 2397).State; sleep 5}
@chelnak
chelnak / GetRequestTemplatesByName.ps1
Created July 25, 2016 12:25
Get request template for all Catalog items that match a certain string with PowervRA
Get-vRAConsumerCatalogItem | ? {$_.Name -like "*LIKE*"} | Select Id, Name | % {Get-vRAConsumerCatalogItemRequestTemplate -Id $_.Id | Out-File -FilePath ".\Data\$($_.Name).json"}
@chelnak
chelnak / DRSGroup-Example.js
Last active July 20, 2016 13:10
Example for determining DRS group based off storage. Pass cluster, vm_group and vms to the Library workflow Add virtual machines to DRS group
//Get the first datastore in the array
var dataStores = vcVirtualMachine.datastore;
var dataStore = dataStores[0].name;
System.log("Found first datastore in array: " + dataStore);
//Get datastore prefix
@chelnak
chelnak / RequestExample.ps1
Last active July 3, 2016 18:36
PowervRA - Populate custom properties Request-vRAConsumerCatalogItem
# --- Convert the JSON string to an object
$Object = (Get-vRAConsumerCatalogItemRequestTemplate -Name "A Catalog Item" | ConvertFrom-JSON)
# ---Build the request
$RequestProperties = $Object.data.VM.data
$RequestProperties.Hostname = "MyHostname"
$RequestProperties.cpu = 2
$RequestProperties.memory = 2048
# ---- Submit the request
@chelnak
chelnak / PowervRA-RequestBuilder.ps1
Created June 27, 2016 08:17
Example script to demonstrate how to submit multiple vRA catalog item requests with PowervRA from a predefined list. The example submits each request as a seperate PSJob. The status of each job can be monitored via the vRA web console and by using Get-Job.
<#
Example script to demonstrate how to submit multiple vRA catalog item requests
from a predefined list.
The example submits each request as a seperate PSJob. The status of each job can be
monitored via the vRA web console and by using Get-Job.
#>
@chelnak
chelnak / Create a vCloud Air reservation.ps1
Last active September 27, 2016 15:34
Creating reservations with PowervRA - This gist contains examples for creating vSphere and vCloud Air reservations
# --- Create a vCloud Air Reservation
# --- Get the compute resource id
$ComputeResource = Get-vRAReservationComputeResource -Type "vCloud Air" -Name "uk-slough-1-6 - VDC1 (vCloud Air)"
# --- Get the network definition
$NetworkDefinitionArray = @()
$Network1 = New-vRAReservationNetworkDefinition -Type "vCloud Air" -ComputeResourceId $ComputeResource.Id -NetworkPath "isolated-network"
$NetworkDefinitionArray += $Network1