How to Find Large Files on Your Computer Using PowerShell

When the system warns you that free area on your native drive is working out, the very first thing that the administrator does is making an attempt to discover all massive information that occupy a lot area. To seek for new information, you need to use Windows Explorer (there are a number of pre-defined templates of looking out by measurement), your favourite file supervisor or third-party instruments. However, in contrast to PowerShell, all these instruments require set up. Let’s think about the instance of fast looking out massive information on your native laptop drive utilizing PowerShell.

You can use the Get-ChildItem cmdlet to record the information in a particular listing (together with subfolders) and their sizes.The cmdlet can search information throughout your entire disk or in a particular folder (for instance, in consumer profiles and some other folders).

Let’s record the 10 largest information on disk C::

Get-ChildItem c: -r| type -descending -property size | choose -first 10 identify, Length

Depending on the disk measurement and the variety of information on it, it might take a while to full the command.

The –r (Recurse) key implies that all subfolder will likely be searched recursively. You can limit the examine to a sure depth stage utilizing –Depth parameter. If you don’t specify the trail, all subfolders of the present listing will likely be searched.

using Get-ChildItem to find top 10 large file on a computer

As you’ll be able to see, we obtained the record of ten largest information on the disk sorted within the descending order.

Tip. When accessing some directories even with the administrator privileges, the Get-ChildItem cmdlet can return an entry denied error:

Get-ChildItem : Access to the trail 'C:WindowsCSC' is denied.
At line:1 char:1
+ Get-ChildItem c: -r| type -descending -property size | choose -fir ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:WindowsCSC:String) [Get-ChildItem], UnauthorizedAccessException
+ FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

To suppress such errors, use the -ErrorAction SilentlyContinue parameter.

Use the -Force choice to show hidden and system information that aren’t accessible to the consumer.

Get-ChildItem : Access to the path is denied

As you’ll be able to see, the file measurement is displayed in bytes. For comfort, they are often transformed into megabytes. You may show the folder, wherein the discovered file is saved:

Get-ChildItem c: -r -ErrorAction –Force SilentlyContinue |type -descending -property size | choose -first 10 identify, ListingName, @

Script to find 10 largest files on a windows server or pc

The ensuing desk will be transformed right into a handy graphic desk utilizing the Out-GridView cmdlet:

Get-ChildItem c: -r|type -descending -property size | choose -first 10 identify, ListingName, @ | Out-GridView

Get-ChildItem folder size Out-GridView

Similarly, you’ll find all information which can be bigger than a sure measurement, for instance, 500 MB:

GCi C: -recurse -ErrorAction –Force SilentlyContinue | where-object | Sort-Object size | ft fullname

You can export the record of information right into a CSV file as follows:

GCi C: -recurse | where-object | Sort-Object size | ft fullname | Export-Csv c:laptopLargeFiles_Report.csv

If you want to calculate the dimensions of all information in a particular listing, learn the article Calculating Folder Size in PowerShell.

Check Also

How to Enable and Configure MPIO on Windows Server 2016/2012R2?

In this text we’ll contemplate how to set up and configure MPIO on Windows Server …

Leave a Reply

Your email address will not be published. Required fields are marked *