Another quick one-liner I’ve just figured out. This will get the 20 largest folders in the mailbox sorted into descending order of size. There was a big gotcha I needed to figure out which I go into after the break.
Continue reading “PowerShell: Get Largest Mailbox Folders, One-Line Command”
I mentioned in the last part that you should be able to get the sizes of sub-folders within a folder with Measure-Object and Group-Object. So I had a bit of a tinker as an intellectual exercise and I worked up a one-liner that works. Ish. As I mentioned previously, this won’t automatically add the size of each sub-folder to the parent folder (so in the results you’d get C:\Source as 10 KB and C:\Source\Sub as 100 MB, for example).
Still, it was pretty interesting to hack it together. The command and a brief explanation follows.
Continue reading “PowerShell : Get Folder Size on Disk, One-Line Command”
Following on from the “What is Recursion?” post it’s time for a concrete example with PowerShell; a script to calculate the sizes of all sub-folders within a folder. The script (and description) follows.
Continue reading “Recursion in PowerShell : Getting the Size of Folders on a Hard Disk”
Hi. I meant to go into this in a bit more detail after using it in some of my scripts. Recursion is a pretty interesting idea and it’s used quite a bit in scripting. I’ll describe it below and then I’ll jump into an example using PowerShell in the next post.
Continue reading “What is Recursion?”
The final functions are done (in the last part) now it’s just the main body of the script. This will bring all the code together and produce the output we want. The full script can be found here.
Continue reading “Powershell Archiving Script, Part 8 (Final Part)”
We’re on the home straight now. In the last part we dealt with the last major workhorse of the script (actually moving objects to and from the archive with Move-ArchiveObject) and in this part we deal with some of the formatting / presentation functions. The full script can be found here.
Continue reading “Powershell Archiving Script, Part 7”
In the last part we looked at the Get-FolderInformation function, which returns an object describing a folder so the user can tell if they want to process it or not. This part is going to focus on the Move-ArchiveObject function which will actually perform the archive (or return from archive) process on a chosen folder. The full script can be found here.
Continue reading “Powershell Archiving Script, Part 6”
Continuing on from the last part where I defined the Get-FolderSize function the next function to be defined is Get-FolderInformation. This gets the relevant information about all the folders that could be processed and outputs that information as objects. The full script can be found here.
Continue reading “Powershell Archiving Script, Part 5”
In the last part we wrote out the Powershell to handle the parameters (including some crude validation) and for the skeleton of the rest of the script. In the next few parts we’ll define the functions the script will use. The full script can be found here.
Continue reading “Powershell Archiving Script, Part 4”
In this part we’ll start writing some Powershell. Initially we’ll write about the function call and function structure (see below). The full script can be found here. Continue reading “Powershell Archiving Script, Part 3”