Posts
49
Comments
83
Trackbacks
0
October 2006 Entries
How to get DL membership in Exchange 2007

Abshishek reminded me of this with his post on how to figure out Security Group membership using PowerShell. But Distribution Groups are a whole different beast. So how do you do it? One way is to use the GUI: the awesome Exchange Management Console already shows you group membership. And on the cmdline you can do this in Exchange 2007:

Using server side filtering (faster):

   $filterid = (get-user Administrator).Identity get-group -filter { Members -eq $filterid }

Using client side filtering (slower):

   get-group | where { $_.Members -like '*Admin*' }

This can be adapted to do nested membership as well---I'll leave it to you to figure out how.

posted @ Sunday, October 22, 2006 11:10 PM | Feedback (3)
How to record your shell session

PS> Start-Transcript
PS> # do a bunch of stuff
PS> Stop-Transcript # or just quit the shell

This will create a file (by default in your My Documents folder) that is a verbatim copy of your shell session. No more copy and paste needed from the shell to notepad! A few other things of note:

  • This is the only way to capture verbose and warning information as those cannot be redirected from the shell like errors can (don't ask me why, but make sure to tell Jeffrey Snover about this)
  • You can start a transcript by default every time you start your shell by putting 'start-transcript' in your profile.ps1 file
  • There can change the location of the text file that is created. Look at get-help start-transcript for more details
Have fun! 
posted @ Sunday, October 22, 2006 11:10 AM | Feedback (0)
Looking for feedback on PowerShell and Exchange
Every once in a while its important to take a step back and see where we can improve---I already have a list of around ~150 things I'd like to improve in the Shell (Exchange and PowerShell), but I'd like to hear what you a) like about the shell and b) would like to see improved. You can leave comments, trackbacks on your own blogs, or mail me directly at (munging the address to defeat the spammers): vivek (at) thiswebpage'sdomainname.com   Here are some examples I found recently:
  • Devin comments on how easy it is to move databases through cmdline and wonders why it isn't easy to move queues as well.
  • Newsgroup commentary from a user on how much it rocks to use the Exchange cmdlets to do management, and why AD management from PowerShell isn't just as easy (I don't work for AD team, but rest assured, I'm still working hard on making this happen).
So let us know what you like (or like a lot) so we can continue making it better and what you would like to see improved / fixed / added so we can plan for our future releases or work up some cool community snippets (after all, that is one huge advantage of the shell). Remember, if you don't speak up, I can't hear you, and thus I can't do anything about any issues :)  
posted @ Friday, October 20, 2006 10:10 AM | Feedback (0)
A strict shell is sometimes a good shell

Sorry for yet another hiatus, times have been busy. To make up for it, here is one of my favorite improvements in PowerShell (BTW: this change was driven partly by REAL IT administrators at Microsoft---thanks folks, you rock!). So here goes. Do you know that in a normal session of PowerShell, unassigned variables are really "null" by default? This is an advantage for folks who love PERL and other Unix-y tools as they can use this assumption to their advantage. But, it also has potential pitfalls---let's say you make one minor mistake in a script and type $myvariabel instead of $myvariable. Well you can imagine the longer the script, the longer the debugging session. So, there is a mode available in PowerShell, thankfully, which lets you be more strict in how the shell treats unassigned variables. Note the behavior change: Default behavior:

PS> $foo
PS>
PS> $foo -eq $null
True

See the problem? No? Well, I'll let you write some complex scripts and get back to me on that one. Here's how you turn off this loose behavior:

PS> set-psdebug -strict
PS> $foo
The variable $foo cannot be retrieved because it has not been set yet. At line:1 char:4 + $foo <<<< PS> $foo "is the best variable!" The variable $foo cannot be retrieved because it has not been set yet. At line:1 char:4 + $foo <<<<

Use it to your advantage, but since it does change the way the shell interprets variables, learn to use it before turning it on everywhere. I recommend turning it on during scrip execution at first.

posted @ Saturday, October 14, 2006 8:10 PM | Feedback (0)
News
A little slow these days as I'm busy working on exchangelabs.com. I will try and post tidbits when I get some time. Enjoy the older posts till then!