我希望在生成CSV文件时跳过第一行的Name和Path。我不知道如何做到这一点,也没有头绪。
以下是我的代码:
function Get-Path{
param($Object)
$path = $object.Name
$parent = Get-View $Object.ExtensionData.ResourcePool
while($parent){
$path = $parent.Name + "/" + $path
if($parent.Parent){
$parent = Get-View $parent.Parent
}
else{$parent = $null}
}
$path
}
Get-VM | Select Name,
@{N="Path";E={(Get-Path -Object $_) -replace "^.*?Resources"}} | Export-csv C:\izaz\test.csv -NoTypeInformation