Hi
I get the following error when trying to export vm folder locations.
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At D:\Export-vmlocations-CSV.ps1:29 char:2
8
+ $current = Get-View <<<< $_.Parent
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
-----------------------------------------------------------------------------------------------------------------------
The script works for all of my other datacenters with the exception of one.
Code:
-------
filter Get-FolderPath {
$_ | Get-View | % {
$row = "" | select Name, Path
$row.Name = $_.Name
$current = Get-View $_.Parent
$path = $_.Name
do {
$parent = $current
if($parent.Name -ne "vm"){$path = $parent.Name + "\" + $path}
$current = Get-View $current.Parent
} while ($current.Parent -ne $null)
$row.Path = $path
$row
}
}
#Export VM locations
$report = @()
$report = get-datacenter $DC -Server $Server | get-vm | Get-Folderpath
$report | Export-Csv $OutFile -NoTypeInformation
Being that the script works for all of the other datacenters could the cause be the name(s) of the vm in the datacenter that's encountering the error?
Has anyone else experienced this issue?
Regards,
Could it be that you get this error for VMs that are in the root of the datacenter in the VMs and Templates view ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think that's it. Is there a way around this other than moving the VMs?
Just did some more tests, and the path for VMs that are in the root of the datacenter do not cause the problem.
Do you know for which VMs you get the error ?
And where these are located in the VMs and Templates view ?
Another possibility, are you running in multi mode ?
And are you connected to multiple vSphere servers ?
Do a
Get-PowerCLIConfiguration
to check. And if yes, display the open connections with
$global:defaultviservers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc
I'm running the script in single mode.
There are a lot of vm in this datacenter so I'm not sure which VMs are causing the error.
I am still getting the error but I am getting an output file for some of the VMs in this datacenter
Try changing these 2 lines
filter Get-FolderPath {
$_ | Get-View | % {
into
filter Get-FolderPath {
$_.Name
$_ | Get-View | % {
That should display the name of each VM as it is passed to the filter.
That should show which VMs are causing the error messages.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference