玩命加载中 . . .

PowerCLI Scirpt: list_used_fiber.ps


Overview

This script is used to find fibre card for each VM on vCenter.

Usage:

pwsh list_used_fiber.ps -server 10.1.2.3 -user user1 -pwd password -fibre_name *Fibre*

Scripts of list_used_fiber.ps

# This script is used to find fibre card for each VM on vCenter.
# Usage: pwsh list_used_fiber.ps -server 10.1.2.3 -user user1 -pwd password -fibre_name *Fibre*

param (
    [string] $server = "",
    [string] $user = "",
    [string] $pwd = "",
    [string] $fibre_name= "*Fibre*"
)

If (-Not ($server -and $user -and $pwd)) {
    Write-Host "Please input vCenter IP, user name and password to conect to vCenter:$server"
    Write-Host "Usage: pwsh list_used_fiber.ps -server 10.1.14.3 -user user1 -pwd password -fibre_name *Fibre*" -ForegroundColor green
    exit
}

$output = ""

Connect-VIServer -Server $server -Protocol https -force -User $user -Password $pwd
$vm_name = Get-VM

Write-Host    "`n`nStart to search which VM used fibre card...`n"
#Write-Host "VM | PCI Device"
$output += "VM | PCI Device`n"
foreach($vm in $vm_name)
{
    $device=Get-PassthroughDevice -Type pci -VM $vm -name $fibre_name
    If ($device) {
	    #Write-Host "$($vm) | $($device)"
	    $output += "$($vm) | $($device)`n"
    }
}

Write-Host $output


文章作者: Gavin Wang
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Gavin Wang !
  目录