Comments on: 10 Awesome Hyper-V Cmdlets https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/ Hyper-V guides, how-tos, tips, and expert advice for system admins and IT professionals Wed, 31 Mar 2021 06:28:56 +0000 hourly 1 By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3792 Tue, 24 Nov 2020 21:13:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3792 In reply to Matthias.

I’d suggest installing the Hyper-V Management tools on your desktop.Then use the VMConnect utility.

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3791 Tue, 24 Nov 2020 20:57:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3791 In reply to David.

I think you need to move the $snapshot=… line into the foreach loop. You are looping through and resetting the value of $snapname every time. This isn’t a good place for code debugging. If you are still stuck, I encourage you to use the forums at PowerShell.org.

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3790 Tue, 24 Nov 2020 20:51:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3790 In reply to Jabir.

Did you try? You might also try: $VHD | Remove-VMHardDisk

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3789 Tue, 24 Nov 2020 20:50:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3789 In reply to nass.

Get-VMSnapshot -VMName MYVM| Sor-object -property CreationTime | Select-Object -first 1 | Remove-VMSnapshot

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3788 Tue, 24 Nov 2020 20:48:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3788 In reply to John.

First, read the help and examples for Stop-VM. You should be able to to feed in parameter values to a command like: Stop-VM -name VM1 -computername VMSERVER1

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3787 Tue, 24 Nov 2020 20:45:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3787 In reply to Daniel Brada.

Did you try: Stop-VM MYVM -force

]]>
By: Jeffery Hicks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3786 Tue, 24 Nov 2020 20:43:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3786 In reply to Soumen.

Not sure I completely follow but would something like this work: get-vm MYVM| get-vmsnapshot | Get-VMHardDiskDrive | select VMName,Path

]]>
By: Symon Perriman https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-3633 Tue, 28 Apr 2020 09:27:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-3633 In reply to Rafi.

Hi Rafi,
There are a few ways you could implement this by running a PowerShell script. One way would be to query every VM and create a list of VHD files associated with every VM. Compare this list with all VHDs to find those which are not used. You could also check when each VHD file was last changed to ensure that it has not recently been accessed.
Thanks,
Symon Perriman
Altaro Editor

]]>
By: Rafi https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-1485 Sun, 09 Feb 2020 19:50:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-1485 Hi Jeffery , 10x alot gr8 info, I’m looking for away to find all vhd files thats not used
in order to free space from my Lune.

thanks in advanced.

]]>
By: ricks https://www.altaro.com/hyper-v/10-awesome-hyper-v-cmdlets/#comment-2957 Thu, 06 Feb 2020 14:58:00 +0000 http://hub.altaro.com/hyper-v/?p=2745#comment-2957 I use this function to quickly check our 7 VM servers and the VMs on them. It’s part of my profile.ps1 and already has an array built of $VM_SERVERS to iterate.

Function checkVMs
{Write-Output “Virtual Machine Server Statuses:”
invoke-command -computername $VM_SERVERS -ScriptBlock {get-vm|select ComputerName,Name,Uptime,CPUUsage,Status}|select ComputerName,Name,Uptime,CPUUsage,Status|sort ComputerName,Name|ft -AutoSize
Write-Output “Virtual Machine Snapshot Statuses:”
invoke-command -computername $VM_SERVERS -ScriptBlock
{get-vmsnapshot *|select ComputerName,VMName,SnapshotType,Name}|select ComputerName,VMName,SnapshotType,Name|sort Computername,VMName|ft -Autosize}

]]>