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