0

I'm looking for a method to check what the SCSI hardware of a VM is and identify any servers that have virtualbuslogic. I'm trying via PowerCLI to make this happen although I'm not sure how to specify that I want to see just the servers with virtualbuslogic and to display the name of each server. At the moment when I run my code it gets me what SCSI hardware each VM is using but it doesn't specify the name of the VM.

Get-VM | Foreach-Object {Get-ScsiController -VM $_ }

What could I do in order to make this code specify the name of the servers and only display ones that have virtualbuslogic? That or is there any other way that may be built into vSphere that I'm not aware of to view the type of SCSI hardware for each VM (without manually going through each server in the edit hardware settings)?

Valrok
  • 330
  • 3
  • 11

1 Answers1

1

I've not tried, but

Get-VM | Foreach-Object {
$vm = $_
    Get-ScsiController -VM $vm | Where-Object { $_.Type -eq "VirtualBusLogic" } | Foreach-Object {
        Write-Host $vm.Guest.VmName
    }
}

...initially springs to mind.

jimbobmcgee
  • 2,645
  • 4
  • 24
  • 40
  • Works perfect, I'll be adding this little code snippet to what I'm working on. Thanks! Out of curiosity, do you think that the results can further be piped to where I can get the OS system of each VM that gets outputted? – Valrok Oct 17 '13 at 17:23
  • I would guess `Write-Host $vm.Guest.OSFullName` -- the [PowerCLI reference](http://www.vmware.com/support/developer/PowerCLI/PowerCLI51/html/) is your friend... – jimbobmcgee Oct 17 '13 at 17:36
  • And, depending on how PowerCLI fetches the guest information when `$vm.Guest` is called, you *might* want to do `$guest = $vm.Guest` once after `$vm = $_` and then query `$guest.VmName` and `$guest.OSFullName` (and any others)... – jimbobmcgee Oct 17 '13 at 17:43
  • Once you have the VM in a variable, and you're doing this with more than a single-line query, you can play with it however you want. Yes, read the PowerCLI docs. – mfinni Oct 18 '13 at 19:04