How to Discover Unused Mailboxes

May 31, 2010

In Exchange 2007, and later, we can use the Get-MailboxFolderStatistics cmdlet to retrieve information about the folders in a specified mailbox, including the number and size of items in the folder, the folder name and ID, and other information. If we add the IncludeOldestAndNewestItems switch parameter, Get-MailboxFolderStatistics will also return the dates of the oldest and newest items in each folder. Using that information we can determine the last time a message was sent from a mailbox. Using the script below, we can get all user mailboxes that did not sent an email in...

QuickTip: How to validate a UNC path

May 27, 2010

The System.Uri class provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI. One of its properties is IsUnc . IsUnc gets whether the specified Uri is a universal naming convention (UNC) path and returns a Boolean value that is True if the Uri is a UNC path or False otherwise.   #Requires -Version 2.0 function Test-UNC {     param(                         ]$Path     )...

PowerShell freenode IRC channel (WPF client)

May 24, 2010

The PowerShell IRC chat room (or the PowerShell ‘Virtual User Group’ as Jaykul likes to call it) on freenode, is one of the places where you can get answers to your PowerShell questions. There are plenty of PowerShell gurus in there to help you, and with Connect-PSVUG you can connect to the chat room without installing an IRC client. The Connect-PSVUG (Connect PowerShell Virtual User Group) function is a WPF window that hosts a free open source (web based) IRC client. Just run Connect-PSVUG,  wait for the window to show, choose yourself a nickname (the channel name...

How to get the default parameter values of a cmdlet

May 19, 2010

PowerShell’s help is the first place we check for detailed descriptions of cmdlet parameters. We can find if a parameter is required or not, if it’s a named parameter or positional, if it has a default value, and so on. Let’s take a look at the help for Get-WMIObject’s NameSpace parameter:   PS > Get-Help Get-WMIObject -Parameter NameSpace-Namespace <string> When used with the Class parameter, this parameter specifies the WMI repository namespace where the referenced WMI class is located. When used with the List parameter, it...
one comment

QuickTip: Additional PowerShell Registry drives

May 16, 2010

Windows PowerShell provides access to the system registry via two PowerShell drives: HKLM and HKCU, which maps to the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER registry hives respectively. PS > Get-PSDrive -PSProvider RegistryName Used (GB) Free (GB) Provider Root CurrentLocation---- --------- --------- -------- ---- ---------------HKCU Registry HKEY_CURRENT_USERHKLM ...

Going back in time

May 11, 2010

Did it ever happen to you to spend a decent amount of time working on a piece of code in the console, making it work and then closing the shell thinking to yourself: Oh cool, I found a solution! 5 minutes later you try to recreate what you did and something is not working? You bang your head against the wall wishing that time travel was possible so you could go back in time and take just a sneak peak at what you wrote. Time travel is not possible. At the moment. But...

Teaching PowerShell

May 5, 2010

I’m pleased to announce that I’ve joined the ranks of John Bryce Training – The Leading IT Education center in Israel and by the end of the month I am going to start teaching PowerShell. My first (3-day) PowerShell 2.0 class (private class for a large local company, sorry you can’t join) is already booked. I’m so excited :)

Get-Parameter – Learn more about your cmdlets

May 3, 2010

Back in 2007 I wrote a function as a learning tool to discover cmdlet parameters and their attributes. Since then the function has evolved and has much more information to offer. In my day-to-day scripting this is the function I use the most. It gives me a quick view of all I need to know about any cmdlet parameters, and much much more. Here’s how the result of Get-Parameter looks when you query the Select-Object cmdlet (gprm is an alias for Get-Parameter). PS > gprm Select-Object ParameterSet: DefaultParameter Name ...