Strange, the datacenter itself should not be in the VIPath.
Can you check with
Import-Clixml-Path C:\Temp\datacenters.xml | Select Name, VIPath
When I calculate the VIPath on the export, I get the path up to the datacenter, but not including the datacenter
Check with
Get-Datacenter| Select Name,@{N='VIPath';E={$_.ExtensionData|Get-VIPath}}
Are you sure you are using the Get-VIPath function as I included it in my earlier file1.ps1?
It should look like this, and the returned path should not include the datacenter itself
<#
.SYNOPSIS
Retrieve the full path of an inventory object
.DESCRIPTION
This function retrieves the full path of the given
inventory object
.NOTES
Source: Automating vSphere Administration
.PARAMETERinputObject
The inventory object to retrieve the full path from
.PARAMETERchildPath
Optional parameter used by the function when calling itself
recursively
.EXAMPLE
(Get-Datacenter DC01).ExtensionData | Get-VIPath
#>
Param(
[parameter(valuefrompipeline=$true,mandatory=$true,`
HelpMessage='Enter an inventory object entity')]
$InputObject
)
Begin{
$exclude='Datacenters','vm','host',`
'datastore','network'
$excludePattern=($exclude|%{"^$_$"})-join"|"
}
process{
if($InputObject-is[VMware.Vim.ManagedEntity]){
$obj=$InputObject
}
else{
$obj=$InputObject.ExtensionData
}
$path=@()
while($obj.Parent){
$obj=Get-View-Id $obj.Parent-Property Name, Parent
$path+=$obj.Name
}
$path=$path|Select-String-Pattern $excludePattern-NotMatch
if($path){
[array]::Reverse($path)
$path-join'/'
}
}
}