VMware Cloud Community
KarthikeyanRam1
Contributor
Contributor

Set-annotation issues

Add-PSSnapin VMware.VimAutomation.Core

connect-viserver -server Vcenterserver

Add-PSSnapin VMware.VimAutomation.Core

    Function VM-Selection {

       $vms = @()

       Import-Csv C:\VMware\Annotations.csv |

       %{$vms += (Get-VM $_.VM | Set-Annotation -customattribute $_.Annotation -Value $_.Value)

       }

       return $vms

    }

VM-Selection

Disconnect-VIServer -Confirm:$false

csv: VM,Annotation,Value

all virtual machines name,annotations and Value are correct in csv file

Wenever im using the script, Im getting the below error, Please help me out.

Im having issues to import from csv file. watever modules i use for annotations im having issues in importing ALL THE VALUES values from csv file

Please let me know how to resolve this

Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

null or empty, and then try the command again.

At line:8 char:26

+        %{$vms += (Get-VM $_.VM | Set-Annotation -customattribute $_.A ...

+                          ~~~~~

    + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Tags (1)
0 Kudos
1 Reply
LucD
Leadership
Leadership

The error clearly states that the Get-VM cmdlet gets a $null or '' value on the Name parameter.

It looks like you might have an empty line in your CSV file.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos