Posts
49
Comments
83
Trackbacks
0
PowerShell
Running scripts that only work under 32bit cleanly in 64bit PowerShell

The scenario is as following: you have some script that can only work in 32bit powershell (the COM objects it calles only work in 32 bit for example) but you are used to running 64bit powershell. So what to do you do? Easy, just write your script to check if its being called from a 32bit process and if not, spawn a copy of 32bit powershell to run itself! Tha way you never have to think about calling 32bit powershell explicitly. Here is the snippet: ...

posted @ Wednesday, December 03, 2008 12:08 AM | Feedback (1)
Emacs powershell-mode.el updated to v0.5

Here is the updated file. The old v0.4 version can still be downloaded as well. Many thanks to Richard Bielawski for taking the time to update some things and fix bugs. Change list from Richard's diff: Indenting fixed on <tab> Elseif keyword added Support standard comment func Bug fixed when visiting files in major mode I didn't do a thorough test, simply used it in the following scenarios: visiting file, auto-load, colorization, indenting via <tab> and editing. Apologies for the dastardly delay--but if you have improvements and suggestions / snippets, I'd be happy to...

posted @ Tuesday, August 19, 2008 7:52 PM | Feedback (8)
PowerShell Book Recommendations

Someone asked me to recommend a few books, so here they are: 1) Windows PowerShell Cookbook by Lee Holmes (from PS Team) 2) Windows PowerShell in Action by Bruce Payette (from PS Team) 3) For Exchange specific stuff, I actually haven't tried any (makes sense as we were writing code most of the time :). Here are a few I dug up on the web, they look promising: In fact, a few guys I know wrote a very nice book that should definitely...

posted @ Sunday, February 10, 2008 5:30 PM | Feedback (1)
Announcing the Exchange 2007 PowerShell Scriptacular demo pack!

  Dear Exchange 2007 Enthusiast(s), I'd like to announce the Exchange 2007 PowerShell Scriptacular (download zipfile) demo pack. What is it you ask? Well... this collection of Exchange PowerShell scripts was developed by Mihai Jalobeanu and Vivek Sharma while they (we) developed the Exchange Management Shell. We had a lot of fun writing these scripts, and we used them to showcase the innovations in Exchange 2007 System Management--we also promised that when Exchange 2007 is released to the wild, that we'd make our favorite scripts available to everyone. So here they are! If you want our exact demo setup: to get...

posted @ Thursday, December 21, 2006 6:12 PM | Feedback (13)
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...

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...

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...

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...

posted @ Saturday, October 14, 2006 8:10 PM | Feedback (0)
Sorting top users and then moving them (2003/2007)

Brian asked in the comments: "... I am looking for a monad scipt/command that will allow me to sort user on e2k3 by size then move either the top or bottom X number of users..." Try this on Exchange 2007, for 2003, you can use get-wmiobject cmdlet to read Exchange 2003 information using WMI. This is how you would get the top X users per server (you can optionally do this per database by passing in -database to get-mailboxstatistics): get-mailboxstatistics -server Myserver | sort TotalItemSize -desc | select -first 10 Then you can move this list directly using move-mailbox: get-mailboxstatistics -server Myserver | sort TotalItemSize -desc |...

posted @ Tuesday, September 19, 2006 5:09 AM | Feedback (1)
Community Run Scripting Contest

Thanks to Josh for organizing this. In addition to the offical Microsoft One-Liner contest for Exchange 2007, Josh has started his own scripting contest for PowerShell and Exchange. The best part about it is, that the winner gets a signed copy of the upcoming PowerShell book from Bruce Payette, one of the leading designers of PowerShell! Wow, nice job Jeffrey and Josh. So go forth and submit some scripts to both the official contest and Josh's. To sweeten the deal, if you end up winning either contest, I'll put your name, company, winning entry etc. on the official team blog (2 million readers per...

posted @ Saturday, September 16, 2006 2:09 PM | Feedback (2)
Full PowerShell Archive
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!