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