Get-EmptyFolder

A quicky

Hyper-V clustered hosts. Storage of some VMs migrated from one host to another. On rare occasions migration failed. Reason is now irrelevant. But after this – there are some empty folders left on Clustered Shared Volumes:

\\SomeHVHost\c$.

───Planned Virtual Machines

───Snapshots

───Virtual Hard Disks

└───Virtual Machines

There are also other situation where there are bunch of empty folders left (testing, installations, migrations etc).

I was looking for a neat solution and found this post by Jeffery Hicks – Link.

After a few minutes I’ve got a working function that:

  1. Can query local system
  2. Can query remote system (using Invoke-Command)
  3. Can use Credential parameter for remote sessions
  4. And thanks to the above – works also from PS Core:)

Here’s the code:

And here’s the output:

  • Local run:

  • Remote run with credential parameter

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s