Archive for category powercli

Get Active Network Adapter

Recently I had the need to create a script to find out what was the active network adapter in our server, so after some ideas from the web, I came up with a one line PowerShell script that helped me achieve my goal.

Note: Get-NetAdapter is a PowerShell commandlet that’s present on Windows 8 and Windows Server 2012 R2. This command will not work on Windows 7.

Get-NetAdapter | Where-Object {($_.LinkSpeed -eq “1 Gbps”) -and ($_.Status -eq ‘Up’)}

In this line, I’m basically getting the adapter with status ‘Up’ and with a linkspeed equals to ‘1 Gbps’. One can change LinkSpeed property to match your server’s network adapter speed(s).

Leave a comment

List All Disks (VMDKs) In A Virtual Machine (ESXi)

Using VMware PowerCLI, PowerShell, there’s a nifty way to get a list of all VMDKs associated with a virtual machine(s).

Here’s the command:

Get-Vm | Get-Harddisk | Select Parent, StorageFormat, Filename, CapacityGB, Name | Export-Csv -Path C:\SomeFolder\SomeOutputFile.csv –NoTypeInformation
This command lists all VMDKs for all virtual machines in your VMware cluster.

For this sample, I chose to output the following fields:
Parent, StorageFormat, Filename, CapacityGB and Name

This sample code will provide you something like this:



Leave a comment