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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / ListEntitlementsAndPrincipals.ps1
Created July 25, 2016 14:49
List all entitlements and associated principals with PowervRA
Get-vRAEntitlement | Select Name, @{Name="Principals"; Expression={$_.Principals.ref}}
@chelnak
chelnak / RenameCustomObjectType.ps1
Last active July 26, 2016 19:26
Rename a custom object and add a default output for the new type
$Object = [PSCustomObject]@{
Id = "1"
Name = "VM01"
Description = "A virtual machine"
Location = "UK"
IPAddress = "10.0.0.1"
}