Powershell – HyperV – Create/Resize Virtual Hard disks

Two very useful commands l use to create a Virtual machines VHDX virtual disk, and resize an existing VHDX virtual hard drive. These were used on a Windows 2012 R2 Server running Microsoft Hyper-v

Import-Module Hyper-V

New-VHD –Path C:\ClusterStorage\Volume2\HyperV\MyServer\MyServer1_Drive_C.vhdx –Fixed 207GB

resize-vhd –Path C:\ClusterStorage\Volume2\HyperV\MyServer\MyServer1_Drive_D.vhdx –sizebytes 507GB

Click here for much more Hyper-V powershell commands

 

 

Powershell – Stopping a Microsoft Windows Service

In this example, l will attempt to get and stop a windows service for say, SQLdefragmanagementservice.
First open a windows powershell console, using the run as administrator below.
Use the get-process to get the process id.
Use the stop-process to kill the windows process/service.
Then run the code shown in the screenshot below, modify as applicable.

getstopprocess