The 25 largest files with Powershell

All we have encountered more than once out of space in our hard disks, usually at the most inopportune moment, and we had to dedicate ourselves to delete something to continue working.

Here I present a small script in Powershell which one we will find your largest files on your disk. Accepts two parameters:

  • The path where we want to check the size of the files. It can be an entire drive such as c:\ or, which is often more effective, a specific path such as the path where we keep our documents. The script searches recursively in the specified folder and its subfolders.
  • The second parameter is the number of files to display, starting with the largest. Normally between 25 or 50 largest usually left over something.

To use the script copies the following code (without the line numbers):

$Ruta = Read-Host 'Please, enter the route'
$NumFicheros = Read-Host 'Number of files to return'

Get-ChildItem -Path $Ruta -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -Recurse -Force -File | `
 Select-Object @{Name='Ruta';Expression={($_.FullName)}},@{Name='Tamaño';Expression={($_.Length/1MB)}} | `
 Sort-Object -Property Tamaño -Descending | `
 Select-Object -First $NumFicheros | Format-table Ruta, {$_.Tamaño.ToString("000000.00")} -HideTableHeaders 

Inside an empty text file and name it 25Ficheros.ps1

The important thing is to have the extension ps1. We have to have Powershell installed on our system. If we have Windows 10 installed, we have it already. If not, install it from following this link.

To execute it, you must click with the right mouse button on the file created with the script and select the option Run with Powershell.


If this is the first time you execute a Powershell script, it will tell you if you want to change the execution policy, as by default the scripts executions are not allowed. You will indicate yes, and you are requested for the two execution parameters.


Write both data and press ENTER after each item. The script will begin its work and after a moment (the more generic route to search in, the longer it takes) you will obtain the results in two columns. To the left, the file name with full path, and on the right the megas occupying the file.


For example, for my directory C:\Windows\System32 (and all subfolders), these are my top 25 files:


Press Enter again to close the window.

I hope you find it useful the script. For any comments do not hesitate to contact via links on social networks or email.


Assign OneDrive for business folder to a removable drive

OneDrive, the Microsoft storage unit in the cloud currently offers in its enterprise edition 1Tb of storage. It is a high quantity for a regular use. However, unlike his personal version, it is not allowed to change the local folder to a removable drive. By default, the business version is in the user path or if you modify it, in a path in a non-removable drive. In the personal version, during the installation process, you can either select a folder within or without a removable drive for the local files.

In the words of Microsoft, the two OneDrive are different products really, who share the name, hence the different behavior.

It might not seem like a problem at first, but with a terabyte of possible storage, devices such as Windows tablets, with 32Gb or 64Gb storage units, take 10 or 20 gigas, that could be in a memory card, can mean the difference between being able or not to use the system.

In such cases, have an SD card always inserted in the tablet is essential as a support unit. And it is ideal for local OneDrive storage unit.

The following solution allows this operation, but we must clarify that although functional, is not an official Microsoft solution, with all that involve. I’m not responsible for any problems that may arise, either.

The first step is to create a folder in a non-removable drive of our system. For example, at the root of C, called SD:




The folder must be empty to continue, so we should not copy anything inside. Now we open the Disk Manager and look for the removable drive. Press the right button on it and select the option to change the drive letter:


Click on the option to add route:



And select the folder created at first and then press accept:



Now the folder is a mount point of the removable unit. We just have to unlink OneDrive, if we have it linked, and relink, changing during the initialization process the local path, using the folder (not the removable drive). We observe that it does not put any constraint on the use of that folder and it begin normally synchronization. Files are sent to the removable drive, not taking space in non-removable drive.

If we want to remove the drive, we must unlink the OneDrive account first.

Changing SSH and XRDP ports in a Azure Linux virtual machine


A basic safety recommendation is to change the default connection ports of a system for the various available communications services. Let’s see how to change the ssh and xrdp ports on a Azure Linux virtual machine.

Change ssh port

Immediately after creating the virtual machine, the default port is 22. You can connect to the machine through its public IP or DNS with a client like Putty through that port. Edit the configuration file with nano for example:

sudo nano /etc/ssh/sshd_config

And we change where it says port 22 by the value we want (eg I put 40167):


Now to restart the ssh service, run:

sudo service ssh restart

We close the remote session that we are running, that still go through the port 22. Now we need to edit the security rule in the control panel of the virtual machine to reflect the change in port. To do this, we look for the machine in our Azure subscription, for example, in my case it is called f23uh4733:


Click on the entry safety rules option:


And we double click on the current rule for port 22:


And you must modify the value of the port 22 to port defined in the configuration file:


Pressing save after modification. The rule will take a few seconds to be applied.

Installing a remote desktop and xrdp port change

Now we will install a remote desktop. This will be necessary if Linux is a server image for example. Keep in mind that xrdp since Ubuntu 12.04LTS does not support Gnome Desktop, so we’ll use xfce.

First we install xrdp, executing the following command at the terminal:

sudo apt-get install xrdp


After the installation of xrdp, we must install xfce, running the command:

sudo apt-get install xfce4


The next step is to configure xrdp to use xfce. Run the following command:

echo xfce4-session >~/.xsession


Once installed the desktop, we will change the default port for remote connection. We use an editor, for example nano, to modify the xrdp configuration file. Run the command:

sudo nano /etc/xrdp/xrdp.ini

And modify the port with the desired value, in this case for example the port 40168:


We record the changes and restart the xrdp service to take effect, using the following command:

sudo service xrdp restart


Once you have configured the port, as before, we need to create the security rule that allows us to access. To do this we return to the list of rules of entry, and click the add button:


And we add a rule indicating the destination port that we have set in the previous step:


Press save button and wait for the rule to apply. After, we can open a remote desktop connection to the machine by the port:


We have to identify us with a UNIX user. If you have not created any, the administrator user serve us:


And we access the Linux desktop machine: