Posts
47
Comments
55
Trackbacks
0
Tuesday, August 19, 2008
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 include them and give you due credit.

Thanks again Richard!

 

del.icio.us Tags: ,

Technorati Tags: ,
posted @ Tuesday, August 19, 2008 7:52 PM | Feedback (0)
Sunday, August 17, 2008
Quick Post: live.com is actually kind of nice...
Technorati Tags: ,

Just upgraded the blog so apologies for any downtime. Anyway, quick post to exclaim: live.com is really quite useable! I know, I know, I work for Microsoft so that's why I'm saying live.com is worth visiting... right?

No, not really. I don't do PR... :) Here is why I'm recommending it:

  • The background picture is entertaining and often leads me to keep in touch with latest news (like the latest results from the Olympics) 
  • Search results are really consistent with what I expect to see (YMMV)
  • Its FAST - the background image comes up fast, the search results are fast!
  • Image search is really fun to use (try searching for "Lolcatz")
  • Ever searched for "Rumour"? Its a misspelling (in US), live.com automatically corrects it. A bunch of other auto-correct features are subtle but useful.

Of course, I wish some other things should be fixed:

  • There are links on the page to "MSN", "Live Search" and "Windows Live". Huh?
  • Related searches returns wacky results sometimes (I ego-searched and got back a random list of people). At least explain how those were generated.
  • This is a nit for the map feature: it doesn't render the UI usefully in my 1024 x 768 Lenovo. I guess mapping is a high-res feature!

So try out live.com. Oh yeah, I heard they have a cashback scheme--haven't tried it personally so can't comment on that.

posted @ Sunday, August 17, 2008 10:27 PM | Feedback (0)
Sunday, February 10, 2008
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 be on the top of the list.

 

 

Here's to more books, fame and fortune from these fine authors!

posted @ Sunday, February 10, 2008 5:30 PM | Feedback (0)
Friday, October 12, 2007
ExchangeLabs will pwn you!

So its been a long time since I last posted (last December actually!). A lot has happened since then: Exchange 2007 has shipped, Vista has shipped, Office 12 has shipped... and I've been working on, well, new stuff. Since Terry unveiled on the team blog that we have a program called Exchange Labs, I might as well reveal that http://exchangelabs.com also happens to be the new stuff that I'm working on.

I can't totally mention specifics, except that we are enabling a service at ** *** *, which by itself is really cool. And that's just the begining, we're also going to work on *******, *****, ***, **, ***, **, ***** ** ****, *** ****, and not to mention ******* **** *******! Apologies for ****'ing out some words, the censors around here are totally unreasonable :-) Given the new focus, I'll be posting more service and services related stuff on the blog. 

But I still love and use powershell, so I'll continue to sprinkle odds and ends on the blog as well. Evan actually is a good guy to watch for more powershell goodies. Thanks for reading the blog and posting comments, I appreciate it very much!    BTW: The title is a side-effect of me spending lots of time with Halo 3. Here is the wikipedia entry for 'pwn'.

posted @ Friday, October 12, 2007 1:10 AM | Feedback (0)
Thursday, December 21, 2006
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 started, put everything in a directory (d:\scripts or something), and run generate. You need datafiles and you need to customize initvars.ps1. If you don't, the demo pack won't work.

Or you can just take a look at the scripts and learn from the bits and pieces that interest you.

Note: These are Microsoft copyrighted samples, are provided as-is and confer no warranties or rights.

Script Pack Contents: 

  • addfakeservers.ps1 and removefakeservers.ps1

    NOT standalone. Makes it looks like your demo setup has more than one server. We use a very useful feature of Exchange 2007 setup to make this work. Basically we use the /provisionedserver switch to create pre-provisioned servers (AD objects). The admin interface detects these as servers, even though the hardware has not been installed yet. This enables server delegation and pre-provisioning in  Exchange topologies.

  • balancemailboxes.ps1

    Standalone. This script shows how you can use PowerShell to easily load balance mailboxes by size across servers. Key thing is the use of get-mailboxstatistics and move-mailbox.

  • cleanup.ps1 and generate.ps1

    NOT standalone. Cleanup.ps1 completely restores your demo environment to a basic-just-installed-Exchange state. New car smell not included. Generate kicks off everything else to generate the demo environment. 

  • initvars.ps1

    NOT standalone. Standard variables shared by all the scripts. Called by generate.ps1. MAKE SURE TO EDIT THIS FILE to customize this for your environment.

  • mailstorm.ps1 and mailstorm2.ps1

    Standalone with caveats. What's a demo Exchange enviroment without some email? BTW: this is the one script that is likely to not just work automatically in your environment. This is because we assume some basic auth settings to make the Hub server accept mail. This step is done in generate.ps1 so make sure you do that if you plan to use this script by itself.

  • multi-matrix.ps1

    Standalone. Totally totally useless. But cool damnit. This is the matrix unloaded ... er... powershelled.

  • out-email.ps1

    Standalone, with caveats. Just like the name implies, sends content over mail. You can pipe text to it. get-content c:\sometext.txt | out-email -to jimmy@crackcornandidontcare.com -subject "Report". It uses the "from" from initvars.ps1 so make sure to copy those lines as needed to make it standalone.

  • out-html.ps1 and out-ie.ps1

    Standalone. I already posted these to http://www.viveksharma.com/techlog earlier.

The datafiles are politician names, committees, standard drafts of the European Union. We've used US congress / house data in the past too---anything goes, it was publicly available data so it works great for demos.

The scripts (and their latest versions) can always be found at: http://www.viveksharma.com/techlog.

-Mihai Jalobeanu and Vivek Sharma

posted @ Thursday, December 21, 2006 6:12 PM | Feedback (10)
Sunday, October 22, 2006
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 (1)
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)
Friday, October 20, 2006
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)
Saturday, October 14, 2006
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)
Tuesday, September 19, 2006
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 | select -first 10 | move-mailbox -target Server2\DataBase2

For 2003, its a bit more complicated as we don't have cmdlets for 2003, but fortunately you can use the excellent WMI compatability in PowerShell to read Exchange information. For example:

 get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName MyServer | sort Size

This will return a list of mailboxes, which is then sorted, then you can apply the same tricks as before. The one big difference is that since we're dealing with WMI objects (as compared to get-mailboxstatistics objects as in Exchange 2007), you'll have to tweak the pipeline to make things work for moves:

get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName MyServer | sort Size -desc | select -first 10 | foreach { move-mailbox $_.LegacyDN -targetdatabase server2\database2 }

Now, a caveat.... I believe this should work but having upgraded all my servers to 2007, I can't quite test it :) Also, please refer to this post by Glen for more information. I believe I've given enough data to point you all in the right direction, so give it a shot and play around with it. Remember, you can always use -whatif and -validate in move-mailbox, which means you can run the commands without any fear :)

posted @ Tuesday, September 19, 2006 5:09 AM | Feedback (1)
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!