PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
Start-HVPool -Recompose Failure
Hello, guys.
As a newbie to powercli and api, I am struggling to write this simple script for automating regular scheduled snapshot and corresponding recomposing the linked clone pool based on the image.
After hours of searching, I landed on hv.helper module and managed to work on the simple script.
However, I faced the seemingly last but not the least obstacle.
I face the below error message which seems related to the module of hv.helper judging from it saying that I am having some parameter exception and missing.
Anyone could help me? Any help would be appreciated.
My Script
`Connect-VIServer -Server -User -Password
###############
#Day values for snapshot name $Today = (Get-Date).ToString(“yyyy-MM-d”) $Yesterday = (Get-Date).AddDays(-1).ToString(“yyyy-MM-d”)
###############
$vm = Get-VM -Name $vmName
#Create snapshot for today New-Snapshot -VM '1809_templete' -Name $Today -Description "$Today daily snapshot"
#Delete snapshot from the previous day Get-Snapshot -VM $vm | Where-Object {$_.name -contains $Yesterday} | Remove-Snapshot -Confirm:$false
Import-Module VMware.VimAutomation.HorizonView
Import-Module VMware.Hv.Helper
Connect-HVServer -Server -User -Password
Start-HVPool -Pool 'link01' -Recompose -LogoffSetting FORCE_LOGOFF -ParentVM '1809_templete' -SnapshotVM '$Today' -StopOnFirstError $false`
The resulting error message
Exception calling "Desktop_Recompose" with "3" argument(s): "ExceptionType : VMware.Hv.MethodFault
ErrorMessage : Missing value for non-optional field snapshot" At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:6993 char:13
-
$desktop_helper.Desktop_Recompose($services,$item,$spec)
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [], MethodInvocationException
- FullyQualifiedErrorId : VimException
Get-MapEntry : Cannot bind argument to parameter 'Value' because it is null. At C:\Program Files\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:6998 char:146
- ... ettings.virtualCenterProvisioningData.snapshot' -value $spec.Snapshot
-
~~~~~~~~~~~~~~
- CategoryInfo : InvalidData: (:) [Get-MapEntry], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-MapEntry