powershell SNIP | VMware - VM - 获取迁移详细信息(名称,数据存储,路径等)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell SNIP | VMware - VM - 获取迁移详细信息(名称,数据存储,路径等)相关的知识,希望对你有一定的参考价值。

Function Lints-VM-Get-MigrationDetails {
  [CmdletBinding()]
  Param(
    [parameter(
        Mandatory=$true,
        ValueFromPipeline=$true)]
    [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$vms
  ) 

  Begin {
    $paths = @()
  }

  Process { 
    foreach ($v in $vms) {
      $Path = ""
      
      $CurrentFolder = $v.Folder

      if ($CurrentFolder -eq $null -and $v.VApp -ne $null) {
        $Path = $v.VApp.Name + "\"
        $CurrentFolder = Get-Folder -ID (Get-VApp $v.VApp).ExtensionData.ParentFolder
      }

      While ($CurrentFolder.name -ne "vm") {
        $Path = $CurrentFolder.Name + "\" + $Path
        $CurrentFolder = $CurrentFolder.Parent

        if ($CurrentFolder.count -gt 0 ){ 
          $CurrentFolder = $CurrentFolder[0]
        }
      }

      $Path = ($v |Get-Datacenter).Name + "\" + $Path

      $v_temp = new-object PSObject
      $v_temp | add-member -type NoteProperty -Name VMName -Value $v.Name
      $v_temp | add-member -type NoteProperty -Name PowerState -Value $v.PowerState
      $v_temp | add-member -type NoteProperty -Name DataStore -Value (($v.ExtensionData.Config.Files.VmPathName -split " ")[0] -replace "\[",'' -replace "\]",'')
      $v_temp | add-member -type NoteProperty -Name Path -Value ($Path -replace ".$")
      $v_temp | add-member -type NoteProperty -Name PortGroup -Value ($v | Get-NetworkAdapter).NetworkName
      $v_temp

    }
  }
}

以上是关于powershell SNIP | VMware - VM - 获取迁移详细信息(名称,数据存储,路径等)的主要内容,如果未能解决你的问题,请参考以下文章

powershell SNIP | VMware - 数据存储 - 获取空间信息

powershell SNIP | VMware - VM - 重命名VM

powershell SNIP | VMware - 主机 - 获取HBA WWN

powershell SNIP | VMware - 主机 - 获取用户SATP规则

powershell SNIP | VMware - 主机 - 重新登录FC适配器

powershell SNIP | VMware - 主机 - 获取/设置主机的NTP详细信息