Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Getting error when trying to export VM folder locations

$
0
0

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


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>