vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
753 stars 603 forks source link

new-hv pool with _ in the name #445

Closed wesllleyyy closed 3 years ago

wesllleyyy commented 3 years ago

Hello.

I'am trying to automate oure pool creatin through powershell. Now i think i am on th right track:

variable

$poolname = 'Wesley_Test' $pooldisplayName = 'Wesley_Test' $parentvm = 'W10_1909.2_Test' $snapshotvm = 'Linked-Clone-1' $naming = 'W10-P-{n:fixed=3}' $ou = 'OU=Virtueel,OU=Clients,OU=PT,OU=Organisaties'

New-HVPool -spec 'C:\temp\Test_wesley.json'-PoolName $poolname

but i can`t fix this error : Exception calling "Desktop_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidArgument.

When i Delete the _ then everything seems fine.

variable

$poolname = 'WesleyTest' $pooldisplayName = 'WesleyTest' $parentvm = 'W10_1909.2Test' $snapshotvm = 'Linked-Clone-1' $naming = 'W10-P-{n:fixed=3}' $ou = 'OU=Virtueel,OU=Clients,OU=PT,OU=Organisaties'

Is there something i can do to make it work with the _ in the names?

CajunBard commented 3 years ago

@wesllleyyy can you share the contents of your test_wesley.json?

wesllleyyy commented 3 years ago

I made an export of a existing pool. And without the _ in the name it works

{ "Base": { "accessGroup": "Root", "description": null, "name": "Test_w10_PIT1", "displayName": "Test windows 10 PIT1" }, "DesktopSettings": { "Enabled": true, "Deleting": false, "ConnectionServerRestrictions": null, "LogoffSettings": { "PowerPolicy": "TAKE_NO_POWER_ACTION", "AutomaticLogoffPolicy": "AFTER", "AutomaticLogoffMinutes": 120, "AllowUsersToResetMachines": false, "AllowMultipleSessionsPerUser": false, "DeleteOrRefreshMachineAfterLogoff": "DELETE", "RefreshOsDiskAfterLogoff": "NEVER", "RefreshPeriodDaysForReplicaOsDisk": null, "RefreshThresholdPercentageForReplicaOsDisk": null, "EmptySessionTimeoutPolicy": null, "EmptySessionTimeoutMinutes": null, "LogoffAfterTimeout": null, "PreLaunchSessionTimeoutPolicy": null, "PreLaunchSessionTimeoutMinutes": null }, "DisplayProtocolSettings": { "SupportedDisplayProtocols": [ "BLAST", "PCOIP", "RDP" ], "DefaultDisplayProtocol": "BLAST", "AllowUsersToChooseProtocol": true, "PcoipDisplaySettings": { "Renderer3D": "MANAGE_BY_VSPHERE_CLIENT", "EnableGRIDvGPUs": true, "VGPUGridProfile": "grid_m10-1b", "VRamSizeMB": null, "VRamSizeKB": null, "MaxNumberOfMonitors": null, "MaxResolutionOfAnyOneMonitor": null }, "EnableHTMLAccess": true, "EnableCollaboration": false }, "FlashSettings": { "Quality": "NO_CONTROL", "Throttling": "DISABLED" }, "MirageConfigurationOverrides": { "OverrideGlobalSetting": false, "Enabled": null, "Url": null }, "CategoryFolderName": null, "ClientRestrictions": false, "ShortcutLocations": null, "AllowMultipleSessionsPerUser": false, "SupportedSessionType": "DESKTOP", "CloudManaged": false, "CloudAssigned": false, "DisplayAssignedMachineName": false }, "Type": "AUTOMATED", "AutomatedDesktopSpec": { "virtualCenterProvisioningSettings": { "EnableProvisioning": true, "StopProvisioningOnError": true, "MinReadyVMsOnVComposerMaintenance": 2, "VirtualCenterProvisioningData": { "datacenter": "/VxRail-MER1", "parentVm": "W10_1909.2_Test", "hostOrCluster": "/VxRail-MER1/host/VxRail-Virtual-SAN-MER1", "resourcePool": "/VxRail-MER1/host/VxRail-Virtual-SAN-MER1/Resources", "snapshot": "Linked-Clone-1", "vmFolder": "/VxRail-MER1/vm", "template": null }, "VirtualCenterStorageSettings": { "Datastores": { "storageOvercommit": "CONSERVATIVE", "datastore": "/VxRail-MER1/host/VxRail-Virtual-SAN-MER1/VxRail-Virtual-SAN-Datastore" }, "UseVSan": true, "ViewComposerStorageSettings": { "UseSeparateDatastoresReplicaAndOSDisks": false, "ReplicaDiskDatastore": null, "UseNativeSnapshots": false, "SpaceReclamationSettings": { "ReclaimVmDiskSpace": false, "ReclamationThresholdGB": null }, "PersistentDiskSettings": { "RedirectWindowsProfile": false, "UseSeparateDatastoresPersistentAndOSDisks": false, "PersistentDiskDatastores": null, "DiskSizeMB": null, "DiskDriveLetter": null }, "NonPersistentDiskSettings": { "RedirectDisposableFiles": false, "DiskSizeMB": null, "DiskDriveLetter": null } }, "ViewStorageAcceleratorSettings": { "UseViewStorageAccelerator": true, "ViewComposerDiskTypes": "OS_DISKS", "RegenerateViewStorageAcceleratorDays": 7, "BlackoutTimes": [ { "Days": [ "FRIDAY" ], "StartTime": "08:00", "EndTime": "10:00" }, { "Days": [ "THURSDAY" ], "StartTime": "08:00", "EndTime": "10:00" }, { "Days": [ "WEDNESDAY" ], "StartTime": "08:00", "EndTime": "10:00" }, { "Days": [ "TUESDAY" ], "StartTime": "08:00", "EndTime": "10:00" }, { "Days": [ "MONDAY" ], "StartTime": "08:00", "EndTime": "10:00" } ] } }, "VirtualCenterNetworkingSettings": { "Nics": null }, "AddVirtualTPM": false }, "userAssignment": { "UserAssignment": "FLOATING", "AutomaticAssignment": true, "AllowMultipleAssignments": false }, "customizationSettings": { "CustomizationType": "QUICK_PREP", "DomainAdministrator": "", "AdContainer": "OU=Virtueel,OU=Clients,OU=PIT,OU=Organisaties", "ReusePreExistingAccounts": false, "NoCustomizationSettings": null, "SysprepCustomizationSettings": null, "QuickprepCustomizationSettings": { "PowerOffScriptName": null, "PowerOffScriptParameters": null, "PostSynchronizationScriptName": null, "PostSynchronizationScriptParameters": null }, "CloneprepCustomizationSettings": null }, "virtualCenter": "172.30.21.110", "vmNamingSpec": { "namingMethod": "PATTERN", "patternNamingSettings": { "NamingPattern": "VPT3PIT1{n:fixed=3}", "MaxNumberOfMachines": 10, "NumberOfSpareMachines": 3, "ProvisioningTime": "UP_FRONT", "MinNumberOfMachines": null }, "specificNamingSpec": null }, "provisioningType": "VIEW_COMPOSER", "virtualCenterManagedCommonSettings": { "TransparentPageSharingScope": "VM" } }, "ManualDesktopSpec": null, "RdsDesktopSpec": null, "GlobalEntitlementData": null }

CajunBard commented 3 years ago

Try modifying one of the example .json files here https://github.com/vmware/PowerCLI-Example-Scripts/tree/master/Modules/VMware.Hv.Helper/Json/Pool

I'd also modify your code so that you only call the -spec parameter. As-is, you are specifying the Pool's name in two places, once in the spec file, and again in the -poolname parameter.

wesllleyyy commented 3 years ago

@freythman But thats not the isseu. The json file works when i don`t put a _ in the name. Want i want to acchieve is a powershell script where i just change some variables. Its not really user friendly to scroll all the way in the json file to search for everything you want to change.