Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RudolfAchter opened this issue Sep 3, 2020 · 0 comments

Comments

@RudolfAchter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant