Howtos / Articles

Display Total Folder Size with PowerShell and Sort by Size

The PowerShell command below can be used to display a list containing the total size (in MB) of all the files and folders (recursively) in the current directory, and sort them by total size. ls -Force | Add-Member -Force -Passthru -Type ScriptProperty -Name Length -Value {ls $this -Recurse -Force | Measure -Sum Length | Select -Expand Sum } | Sort-Object Length -Descending | Format-Table @{label=”TotalSize (MB)”;expression={[Math]::Truncate($_.Length / 1MB)};width=14}, @{label=”Mode”;expression={$_.Mode};width=8}, Name Sample Output: TotalSize (MB) Mode Name ————– —- —- 26499…

Read more [...]

PowerShell Command to Recursively Delete Thumbs.db

The PowerShell command below can be used to remove thumbs.db files from the current folder, and all sub folders. Make sure you change directory ‘cd’ into the folder you want the command to run from. Get-ChildItem -Path . -Include Thumbs.db -Recurse -Name -Force | Remove-Item -Force You can change the ‘-Include’ parameter to any wildcard you like, such as *.tmp or *.bak for example. Get-ChildItem -Path . -Include *.tmp -Recurse -Name -Force | Remove-Item -Force Remove the ‘Remove-Item’ statement to…

Read more [...]

PowerShell Command to Show Exchange Service Status

The “Get-Service” PowerShell command can be used to display the status of all services on a machine. To make this easier to read, and to narrow down the results to specific services, you can pipe the output to “Where” and filter the results. The following command displays a list of Microsoft Exchange related services, and their statuses. Get-Service | Where {$_.DisplayName -Like "*Exchange*"} | ft DisplayName, Name, Status Example output: This command can be modified easily to filter for another…

Read more [...]

View Exchange Mailbox statistics from the PowerShell

The “Get-MailboxStatistics” PowerShell command can be used to view statistics for a specified mailbox/user account. The only required parameter is the mailbox name, or the user identity. For example: Get-MailboxStatistics -Identity Administrator” Simply running the Get-MailboxStatistics as per the example above, you will only see a few of the columns that get returned (DisplayName, ItemCount, StorageLimitStatus, and LastLogonTime). To view all the available columns/values, you can pipe the Get-MailboxStatistics command to “fl”, which outputs the data in a Formatted List…

Read more [...]