79412027

Date: 2025-02-04 14:29:08
Score: 0.5
Natty:
Report link

just trying to help out. Stack's like a 2nd code repo for me... :) Following will work for a bunch of servers working of FQDN of servers in AD env... Note:

  1. Assumes VM names are host part of FQDN. If not, you will have to modify below to get vm names. FQDN is needed for invoke-command (ICM) that pulls drive letters.

  2. Of course, powercli module and you have to have vcenter connections available to query. connect-viserver etc...

  3. You of course can add a bunch of properties beyond what I have below, but for my purposes, I wrote this due to some of our VMs having same size volumes and tix came in to modify one of them and I was guessing. You can modify to use invoke-vmscript and similar for linux/unix systems to match mountpoints. Powershell section should work on win 2016+

  4. Did search for this online and everyone seems to want to write giant modules or functions or classes for this. Way overkill for my simple purpose of closing tix. ;)

  5. Watch out copying and pasting from web pages. Some trixy fonts use oddball characters for single and double quotes etc...

    "fqdnserver2","fqdnserver1" | %{$vmDiskinfo = get-vm $.split(".")[0] | get-harddisk | %{New-Object -TypeName psobject -Property @{'sn/uuid' = $.extensiondata.backing.uuid.replace('-',''); 'filename' = $.filename.split(' ')[1]}}; $command = {param($p1) (get-disk | Where Serialnumber -eq $p1 | Get-Partition | Where DriveLetter -match '[A-Z]').DriveLetter}; foreach ($psobj in $vmDiskinfo) {$final = $psobj; $final | add-member -MemberType noteproperty -name driveLetter -Value (icm -cn $ -ScriptBlock $command -ArgumentList $psobj.sn); $final | add-member -MemberType noteproperty -name fqdn -Value $_ ; $final }}

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: sillywonka