vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
743 stars 601 forks source link

New-HVPool / Set-HVPool Network Settings Instant Clone Powershell Script #262

Open cradkins opened 5 years ago

cradkins commented 5 years ago

Good Morning,

We have a script that will create Instant Clone Desktop Pools in our environment. We're able to alter all of the settings within this script so far, with the exception of the Networks the pool uses. When you deploy an Instant Clone Pool manually, you can either have it default to use the Parent VM's Network, or you can choose as many networks that you want that pool to randomly pick from and assign to the VM's it creates.

Has anyone else run into this, and if so is there a way to use powershell to change the Network Setting within the desktop pool to randomly select from multiple networks?

I did see the -Nic Parameters for the New-HVPool:

-Nics <DesktopNetworkInterfaceCardSettings[]> desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterNetworkingSettings.nics.

I would imagine that I could do a Set-HVPool with the -key parameter to use the desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterNetworkingSettings.nics listed above. However, I guess my next question would be would this add multiple Network Cards to each VM, or would it just add multiple networks that the pool can choose from to assign to each VM?

jackwmc4 commented 5 years ago

You cannot add multiple nics to a desktop or to a pool, you can only add one. This setting is used to just set the network to be something other than the default of the master image.

From: cradkins notifications@github.com Reply-To: vmware/PowerCLI-Example-Scripts reply@reply.github.com Date: Thursday, February 7, 2019 at 9:24 AM To: vmware/PowerCLI-Example-Scripts PowerCLI-Example-Scripts@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [vmware/PowerCLI-Example-Scripts] New-HVPool / Set-HVPool Network Settings Instant Clone Powershell Script (#262)

Good Morning,

We have a script that will create Instant Clone Desktop Pools in our environment. We're able to alter all of the settings within this script so far, with the exception of the Networks the pool uses. When you deploy an Instant Clone Pool manually, you can either have it default to use the Parent VM's Network, or you can choose as many networks that you want that pool to randomly pick from and assign to the VM's it creates.

Has anyone else run into this, and if so is there a way to use powershell to change the Network Setting within the desktop pool to randomly select from multiple networks?

I did see the -Nic Parameters for the New-HVPool:

-Nics <DesktopNetworkInterfaceCardSettings[]> desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterNetworkingSettings.nics.

I would imagine that I could do a Set-HVPool with the -key parameter to use the desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterNetworkingSettings.nics listed above. However, I guess my next question would be would this add multiple Network Cards to each VM, or would it just add multiple networks that the pool can choose from to assign to each VM?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/vmware/PowerCLI-Example-Scripts/issues/262, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABK9jJT6pKV-OE-cH6aYv2NGWJ8lUazVks5vLFNUgaJpZM4anqAG.

cradkins commented 5 years ago

Good Morning Jack,

We're not trying to add multiple nic's per VM, just have the Instant Clone Pool have 4 potential networks and assign one randomly to each VM.

image

Basically - is there a way to have powershell automatically do what is in the screenshots above that we can do manually? When we use our script, it automatically selects the check box for "use network from current Parent VM Image"

jackwmc4 commented 5 years ago

You would need a pool for each network in that case.

From: cradkins notifications@github.com Reply-To: vmware/PowerCLI-Example-Scripts reply@reply.github.com Date: Thursday, February 7, 2019 at 9:38 AM To: vmware/PowerCLI-Example-Scripts PowerCLI-Example-Scripts@noreply.github.com Cc: Jack McMichael github@jackmac.net, Comment comment@noreply.github.com Subject: Re: [vmware/PowerCLI-Example-Scripts] New-HVPool / Set-HVPool Network Settings Instant Clone Powershell Script (#262)

Good Morning Jack,

We're not trying to add multiple nic's per VM, just have the Instant Clone Pool have 4 potential networks and assign one randomly to each VM.

[Image removed by sender. image]https://user-images.githubusercontent.com/47366106/52426541-2bea9680-2acc-11e9-8217-56435616f8c8.png

[Image removed by sender. image]https://user-images.githubusercontent.com/47366106/52426600-402e9380-2acc-11e9-93a1-8b09245560ed.png

Basically - is there a way to have powershell automatically do what is in the screenshots above that we can do manually? When we use our script, it automatically selects the check box for "use network from current Parent VM Image"

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/vmware/PowerCLI-Example-Scripts/issues/262#issuecomment-461502640, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABK9jIWCXUr28imE8aip84yckVT3R1CXks5vLFaHgaJpZM4anqAG.

CajunBard commented 5 years ago

@cradkins The module is not currently equipped to handle this operation. In order to set multiple network labels on a pool, we have to build an object of the type VMware.Hv.NetworkLabelAssignmentSpec assigned to the key desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterNetworkingSettings.networkLabelAssignmentSpecs.

This object contains many nested properties that must be set per network label. (name: type)

You could use the -Key and -Value parameters, so long as the value is a properly created object of the type VMware.Hv.NetworkLabelAssignmentSpec

More information from the API DesktopNetworkCardSettings - contains information about how the network label assignment is performed when this feature is enabled.

DesktopNetworkLabelAssignmentSpec - Contains the information needed to create the DesktopNetworkLabelAssignmentSpec[] object.

Magneet commented 5 years ago

If you change a pool with the json file it is possible for instant clones to select multiple portgroups. I have created a script that uses the networklabelassignment spec in a blogpost: https://www.retouw.nl/powercli/multi-vlan-network-for-horizon-view-using-powercli-apis/ that method should work for both instant and linked clones

bfett20 commented 4 years ago

We have the same issue with New-HVPool when only a single network port group has been selected. The json file dumped for an existing pool does contain the network information, but it is not restored when using that same file to restore a pool.

Christosvv commented 2 years ago

Whats wrong in below foreach

csv

pool desktop
tst1 rtyui
tst2 dfgty

$test = import-csv C:\Users\tst\Desktop\pool.csv

$test1=@($test)

foreach($ts in $test1)

{ New-HVPool -InstantClone -PoolName "$ts.pool" -PoolDisplayName "$ts.pool" -Description "create testpoolps" -UserAssignment FLOATING -Vcenter vc.tst.com -ParentVM 'testvm' -SnapshotVM '12' -VmFolder 'Desktops' -HostOrCluster '11a' -ResourcePool 'Desktops' -NamingMethod PATTERN -D00893TB' -NamingPattern "$ts.desktop" -NetBiosName eentst -DomainAdmin root

}

Exception calling "Desktop_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidArgument ErrorMessage : Invalid value for member ParameterName : base.name" At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:4986 char:7

dsharma0814 commented 1 month ago

Hi Guys, I am trying to change the port group of my instant clone pool using powershell script but unable to do so. It takes the same portgroup as that of parent image. I really need help in this.