Daniel
Daniel

Reputation: 590

PowerCLI - Get VM Disk Partition Type

I'm looking to conduct an audit on our virtual environment to get the disk partition types (MBR, GPT) of our VMs. I haven't found any documentation in PowerCLI to get the partition type. Any ideas how I can go about this? Thanks!

Upvotes: 0

Views: 1163

Answers (2)

Daniel
Daniel

Reputation: 590

Thanks @Kyle Ruddy!

This was what I did:

$vmName = "VM NAME"

$output = Invoke-VMScript -ScriptText {Get-Disk | select Number, @{name='Size (GB)';expr={[int]($_.Size/1GB)}}, PartitionStyle} -VM $vmName -GuestUser $Username -GuestPassword $Password

$output.ScriptOutput | FT -AutoSize

Upvotes: 0

Kyle Ruddy
Kyle Ruddy

Reputation: 2121

That sort of information is normally not known at the VM object level and instead known at the Guest-OS level. If the VMs you're working with have VMware Tools (or Open VM Tools), you can still use PowerCLI to run scripts against them to pull that information with Invoke-VMScript (docs), but you'll still need to write your own code to pass to the guest OS to pull partition type.

If they're windows systems, you may be able to do something as simple as:

Invoke-VMScript -ScriptText {Get-Partition | select DriveLetter, Type} -VM VMName -GuestCredential $guestCredential

Upvotes: 1

Related Questions