Personal website of Steven Peck. Focusing on Microsoft technologies (most notably PowerShell), and other random bits I think to write.
9
Jul

PowerShell: A simple menu

Playing with PowerShell and VMware is a lot of fun. We have multiple VMware environments at work, so I longed for a simple menu to stick in front of some scripts I used for various reports against those environments. After some searches, I came up with the Windows PowerShell Tip of the Week archives under 'User Input' from the Script Center. It had some interesting suggestions, some fancy, some to simple for my use. I longed for the old text base menus that were simple to toss together and easy for neophytes to understand.

I had this vague recollection of select .. case in VBScript so on the VBScript to Windows PowerShell Conversion Guide I followed the link to VBScript commands and then to Select .. case.

Here I found a nice little, short article on switch. It looked simple enough and a quick check in my PowerShell console showed that Get-Help About_Switch had some more stuff. I still have to play with it some more but now I have my nice, simple menu to authenticate to the different environments with one script.

12
Jun

Reading Help Files

One of my earliest uses of PowerShell was to get information through WMI queries on our Exchange 2003 servers. It worked and gave us the information I needed. Recently I came across a post from Don Jones on reading the PowerShell help files more closely. He's right you should.

The new script seems faster as well. I should probably look at those performance test cmdlets the MVPs all run from time to time to see if it's a real performance kick or subjective.

# Gets data through WMI from specified Exchange mailbox servers
$computers = "server001","server002"
Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computers | sort-object -desc MailboxDisplayName | select-object MailboxDisplayName,StorageGroupName,StoreName,Size

Compare it to my original code.

Of course, it probably helps if you're a better script writing then I am and have a better understanding of all the jargon you're reading, but this is why I like the blogs, you generally learn something often enough that really helps out later.

Tags:
6
Jun

The value of digging through an SDK

SDKs are really for programmers but have value for scriptor writers as well. A while ago I found a script to returns the version of VMware tools on guest systems (I didn't write it and wish I'd kept the source link but it does what I needed).

$date=get-date -uformat "%Y%m%d-%H%M%S"; get-vm | % { get-view $_.ID } | select Name, @{ Name="hostName"; Expression={$_.guest.hostName}}, @{ Name="ToolsStatus"; Expression={$_.guest.toolsstatus}}, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}} | sort-object name | Export-Csv vmtoolsver_$date.csv

Recently my co-worker did some upgrades to our clusters and ran the script and noted that a large portion of our VMware Tools were behind a version or two. He noted that several of our guest systems did not have the option checked in Edit Settings > Options > VMware Tools Check and upgrade Tools before each power-on' so he sent an email for people to manually check at the next opportunity. I figured there must be a PowerShell script way.

5
Jun

PowerShell tutorial series

There are a lot of blog posts and books about PowerShell and with the blogging about CTP for PowerShell v2 going on, it can get even more confusing. Having succeeded in getting another co-worker seriously interested in PowerShell I sent him one of my recent tutorial finds and dug out an older one from my delicious bookmarks. To make it easier for me to give the links to friends, here are the links to both series. Each has a different approach that provides some significant value.

Tags:
28
May

Contributing is about giving

Contributing is about giving. People do so for many reasons but at it's core it is about giving.

For me, it is not now nor has it ever been about 'getting back'. It has not been about reputation, karma, fame. It has been about solving my needs and helping others solve theirs in a way that encouraged them to share so I too could learn in kind.

Tags:
13
May

export-activeLCSusers

This applies to LCS 2005sp1 environments but should also work on OCS2007 environments.

The challenge was to generate a list of LCS enabled users that were not disabled. I have a WMI query that will generate a list of LCS users, but I really wanted to be able to filter out the disabled users.

Get-WmiObject msft_sipesusersetting -filter "Enabled = true" | Select-Object DisplayName

As I had some other needs at the time, I added the telephone information as well to the query. Using get-member you can find a number of other different pieces of useful information to gather as well.

Syndicate content