powerbox icon indicating copy to clipboard operation
powerbox copied to clipboard

Issue with Documentation on New-(someNbObject) and Set-(someNbObject)

Open RudolfAchter opened this issue 5 years ago • 0 comments

In my Project i ran Get-Help New-nbVirtualMachine -Full to see how i create a VirtualMachine Object

Example says:

PS C:\>$lookup = @{
    
    device_type='dcim/device-types'
        device_role='dcim/device-roles'
        site='organization/sites'
        status='dcim/_choices'
    }
    $VirtualMachine = @{
        name = 'example'
        serial = 'aka123457'
        device_type = 'dl380-g9'
        device_role = 'oracle'
        site = 'chicago'
        status = 'active'
    }
    New-nbVirtualMachine -lookup $lookup -object $VirtualMachine

So i did. I created a HashTable describing my virtual Machine and got errors back. After reviewing your code i saw that it expects a PowershellObject and NOT a HashTable.

So i ended up with something like this to get it work:

$nbVMCluster=Get-nbCluster -Query @{name=($o_vm | Get-Cluster).Name}

$nbVMObject= New-Object -Type PSObject -Property @{
	name=$o_vm.Name
	status="active"
	site=($o_vm | Get-Datacenter).Name
	cluster=$nbVMCluster.id
	role=(Get-nbRole -Query @{name="Server"}).id
	vcpus=$o_vm.NumCpu
	memory=$o_vm.MemoryMB
	disk=[int]$o_vm.ProvisionedSpaceGB
}
$nbVM=New-nbVirtualMachine -Object $nbVMObject

I think documentation should be edited here to avoiid misleading Cmdlet Users

RudolfAchter avatar Sep 03 '20 06:09 RudolfAchter