Hyper-V 2012-R2 – PowerShell commands to remember

I just want to put them all together as I don’t use it on daily basis so it’s quite difficult to hold them in my internal memory (yes, I do mean my brains 😉 ).

To run PowerShell in a new window:

> start powershell

To get detailed network interfaces information:

> Get-NetAdapter | select InterfaceDescription,LinkSpeed
InterfaceDescription LinkSpeed
-------------------- ---------
Hyper-V Virtual Ethernet Adapter #2 10 Gbps
Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #41 100 Mbps
Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #43 0 bps
Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #44 0 bps
Broadcom BCM5709C NetXtreme II GigE (NDIS VBD Client) #42 100 Mbps

To display advanced NIC property:

Get-NetAdapterAdvancedProperty P*1

To display possible Advanced NIC property parameters:

Get-NetAdapterAdvancedProperty P*1 | ft DisplayName, DisplayValue, ValidDisplayValues

To disable firewall:

netsh advfirewall set allprofiles state off

To start wincmd:

> C:\totalcmd\TOTALCMD64.EXE

To get disk information similar to df -h in linux:

> Get-Volume
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining Size
----------- --------------- ---------- --------- ------------ ------------- ----
            System Reserved NTFS       Fixed     Healthy      89.2 MB      350 MB
D                           NTFS       Fixed     Healthy      96.3 GB 744 GB
C                           NTFS       Fixed     Healthy      54.1 GB 271.91 GB
E                                      Removable Healthy      0 B     0 B
F                                      CD-ROM    Healthy      0 B     0 B

Initialization of a new disk:

Get-Disk | Where partitionstyle -eq 'raw’ | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "disk2" -Confirm:$false

Create a partition at the end of the disk and format it:

New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume

Get version of all VM’s Integration Services:

Get-VM | ft Name, IntegrationServicesVersion, State

Disable TCP Chimney on (Broadcom) network adapter

netsh int tcp set global chimney=disabled

Disable VMQ on a specific (Broadcom) network adapter

Disable-NetAdapterVmq –Name “Ethernet 2”

Set NTP client on Hyper-V:

w32tm /config /manualpeerlist:ntp.cznic.cz /syncfromflags:MANUAL
Stop-Service w32time
Start-Service w32time

To check NTP client status:

w32tm /query /status

To get network interfaces’ IP’s:

Get-NetIPAddress

 

Leave a Reply