Wednesday, 27 August 2008

Get-Scripting Podcast Episode 1

Welcome to Episode 1 of the Get-Scripting podcast! Tune in to listen to us talk and interview people about Powershell.

Download it here , subscribe in iTunes or via a different feed reader.

In this epsiode we have part 2 of an interview with James O'Neill from Microsoft - we talk about Cmdlets v Providers, V2 CTP and the Powershell Community.

Blog note links:

Ways to learn Powershell:


Powershell Step by Step - Ed Wilson is available as a free eBook. (Look on the Special Offers tab)


------------------------------------------------------------------------------------------------


Update 29/08: A helpful listener Brad Bruce has pointed out the above link no longer has the ebook available. I checked it out and he is correct. :-( It was there last week when I prepared the show and has been for around the last year, unfortunately I never got round to downloading it myself - if anyone has it can they please get in contact and I can then pass it around to anyone who wants it.


Maybe they removed it because so many people tried to get it after listening to the podcast!


------------------------------------------------------------------------------------------------


2008 Scripting Games

Interview

James O'Neill's blog

OCS Powerpack for Powergui. Authors blog


Eureka Scripts

Check Active Directory Latency - Brandon Shell

Exporting Virtual Infrastructure Information to MS Word - Alan Renouf


Selling Powershell to IS Management

Don Jones / Jeffrey Snover video


Powershell Event / Usergroup in Sweden

Sign up here

Richard's Blog post about it


Send us feedback at

get [dash] scripting [at] hotmail [dot] co [dot] uk

or leave a comment here on the blog

Tuesday, 26 August 2008

Exchange 2003, WMI and Powershell - Part 4.5 (Counting Users in Storage Groups and Mailbox Stores)

OK, so this wasn't going to be in the original series I was writing, but an issue came up at work where I needed to quickly find the total number of users in each Storage Group.

Naturally I turned to Powershell for the solution.

Just supply the names of the Storage Groups in a text file, use Powershell to open the text file and for each of the Storage Groups use the Exchange_Mailbox class and filter on the Storage Group name. Use the feature .count to just return the number of users rather than any properties and write to the screen the result.

$StorageGroups = Get-Content c:\Scripts\StorageGroups.txt
foreach ($SG in $StorageGroups){
$Total = (Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName -filter "StorageGroupName = '$SG'").count
Write-Host $SG ":" $Total "users"
}


Which produces something along the lines of:

Storage Group 01 : 152 users
Storage Group 02 : 373 users
Storage Group 03 : 259 users
Storage Group 04 : 220 users


Taking this one step futher you can drill down into the Mailbox Stores with similar code (this time with the names of the Mailbox Stores in a text file) and find how many users on each store:

$MailboxStores = Get-Content c:\Scripts\MailboxStores.txt
foreach ($Store in $MailboxStores){
$Total = (Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName -filter "Storename = '$Store'").count
Write-Host $Store ":" $Total "users"
}

Which gives you the result:

Mailbox Store 01 : 23 users
Mailbox Store 02 : 32 users
Mailbox Store 03 : 41 users
Mailbox Store 04 : 30 users
Mailbox Store 05 : 26 users
Mailbox Store 06 : 39 users
etc.............

Friday, 8 August 2008

Exchange 2003, WMI and Powershell - Part 4 (Disconnected Mailboxes)

In parts 1 , 2 , 3 we looked at retrieving mailbox information from Exchange 2003 using WMI and Powershell.

In part 4 we're going to take another look at this topic area for something slightly more advanced - how to get a list of all mailboxes which have been deleted, but are still in the time frame for 'Keep Deleted Mailboxes for: x days'.

A typical scenario might be a mailbox has been deleted incorrectly and you need to re-connect it to an AD account; however, since the AD account has gone, how do you know which Mailbox Store was the home for the mailbox?

In the Exchange management GUI you would need to browse through each mailbox store looking for mailboxes marked with the red cross. Not too bad a job if you only have one mailbox store, but if that number is in the 10's of Mailbox Stores then its a pretty tedious task.

Step forward Powershell!

Again use the Exchange_Mailbox class and this time look for the DateDiscoveredAbsentInDS value. This value gets populated after the mailbox has been marked for deletion. We look for a value which begins with "2", i.e. the mailbox has been deleted sometime after the year 2000 (there may be a better way to do this), and return info about each mailbox in this state, including the Servername and Mailbox Store Name so that you can easily track the mailbox down.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName | where { $_.DateDiscoveredAbsentInDS -like '2*' } | sort-object MailboxDisplayName | ft MailboxDisplayName,ServerName,StorageGroupName,StoreName,Size,DateDiscoveredAbsentInDS


Update 12/08/08:

Thanks to Shay Levy who has come back with a better way to do this!

"Using a -filter parameter which makes your query run on the server and return only the relevant mailbox objects". You should find that this significantly improves the speed of the query. Check the comments for this post for full details.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName -filter "DateDiscoveredAbsentInDS is not null" | sort-object MailboxDisplayName | ft MailboxDisplayName,ServerName,StorageGroupName,StoreName,Size

Get-Scripting Podcast - how frequent?

A few people have asked "how often we are going to release new episodes of the podcast"?

We hope to record one every month, so all being well look for Episode 1 in the week beginning Monday 25th August.........

Tuesday, 29 July 2008

Get-Scripting Podcast Pilot Episode

Welcome to the pilot episode of the Get-Scripting podcast! Tune in to listen to us talk and interview people about Powershell.

Download it here , subscribe in iTunes or via a different feed reader.

In the first epsiode we have part 1 of an interview with James O'Neill from Microsoft - we talk about Powershell, and in particular the work he has done with Hyper-V.

(It's a pilot OK, so bear with us as we get to grips with things like editing and publishing podcasts :-) )

Blog note links:

Ways to learn Powershell:

Download Powershell

Powershell Getting Started Guide

Interview

James O'Neill's blog

Hyper-V functions on Codeplex

Send us feedback at

get [dash] scripting [at] hotmail [dot] co [dot] uk

or leave a comment here on the blog

Friday, 25 July 2008

Exchange 2003, WMI and Powershell - Part 3 (Mailboxes Over 2GB)

In parts 1 and 2 we looked at retrieving mailbox information from Exchange 2003 using WMI and Powershell.

In part 3 we're going to take another look at this topic area for another potential common request along the lines of 'can you give me a list of all mailboxes over 2GB?'

Again we use the MicrosoftExchangeV2 WMI namespace and the Exchange_Mailbox class and this time use the where-object cmdlet to only return results where the size of the mailbox is greater than 2GB - obviously you can change this value to your own needs. (Note: the value is specified in KB)

Once again very simple to achieve a really effective result.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName | where-object { $_.Size -gt 2097152 } | sort-object MailboxDisplayName}

Thursday, 24 July 2008

Exchange 2003, WMI and Powershell - Part 2 (Top 10 Largest Mailboxes Per Server)

In part 1 I looked at how to retrieve mailbox information from Exchange 2003 using WMI and Powershell.

Taking this on one step further along the lines of your manager asks for a list of the biggest Exchange mailboxes, we can use a similar command to get the mailbox info, sort the list by size and then use the -First parameter of the Select-Object cmdlet to bring back only the top 10 say.

Its as easy as that. Of course you could then output the data to a csv file using an additional pipeline so that the info is easy to forward on.

Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName | sort-object Size -Descending | select-object -First 10 MailboxDisplayName,Servername,StorageGroupName,StoreName,Size | export-csv c:\scripts\top10.csv