Windows PowerShell's Get-PSDrive
This cmdlet is not only useful for researching the local disk structure, but it also gives us an insight into how PowerShell views the registry as a drive.
Topics for PowerShell's Get-PSDrive Cmdlet
This is how to enumerate PowerShell's 'Providers'. It is interesting to see how Microsoft designed PowerShell to view the registry, functions and variables as 'drives'.
Note 1: I added a tiny amount to $Drive.free to swerve the divide by zero error for blank drives.
Note 2: You could create labels at line 3 by adding:
An Alternative Method Using Format Table
This script also lists the disk drives with their capacity in GB (gigabytes) and % freespace, but it uses a slightly different approach.
Note 3: Measure-Command reveals little difference in the speed of my two Get-PSDrive techniques. However for this task, Get-WmiObject is much faster. See WMI disk method.
SolarWinds' Network Performance Monitor will help you discover what's happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Let us used the trusted PowerShell research cmdlet with an alias of GM (Get-Member).
# Investigate Get-PSDrive's Properties and Methods
Note 4: This is how I discovered a useful ScriptProperty called .free and another called .used.
Here is a script which could delete files in your recycle bin that are older than 100 days.
Key point: you need to understand the difference between Get-Item and Remove-Item -recurse before it will deliver it's potential, and actually zap files in the recycle bins in the various drives.
# PowerShell script to list files in the Recycle bin, which are
older than 100 days
Note 5: Replace Get-Item with 'Remove-Item -recurse, but only make the change if you understand the implications.
Note 6: You may wish to adjust the value for .AddDays(-100).
Note 7: Once you understand that this script can clean-up the recycle bin, you may consider adding to a Scheduled Task.
SolarWinds' Config Generator is a free tool, which puts you in charge of controlling changes to network routers and other SNMP devices. Boost your network performance by activating network device features you've already paid for.
Guy says that for newbies the biggest benefit of this free tool is that it will provide the impetus for you to learn more about configuring the SNMP service with its 'Traps' and 'Communities'. Try Config Generator now - it's free!
Most of my examples focus on the FileSystem, however you can employ Get-PSDrive to interrogate the Registry, the Environment, PowerShell's Aliases or Variables, the secret is to specify with -PSProvider.
Note: You could substitute Alias, or Variable for 'Registry'.
The Truth! Forget Get-PSDrive, Get-ChildItem is all you need. Just remember that colon at the end of the PSProvider, thus:
Research Similar PowerShell Cmdlets
# PowerShell PSDrive Nouns and Similar
Summary of PowerShell Get-PSDrive
This cmdlet has a useful parameter called -PSProvider, it enables us not only to research the local disk structure, but also gives us an insight into how PowerShell accesses the registry as a drive.
If you like this page then please share it with your friends
See more Windows PowerShell examples of variables
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.