Home

Black Mountain

My Experiment on the Internet

powershell

Powershell related posts.

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.

reviewing text log entries

We use TDP for Exchange for our backup program. It's an interesting program and I will save my opinion of it for another time, but one of the things we've learned to do it to check the last 20 lines of the log file on each Exchange server daily for success/failure/issue of the backups. This process will work for checking multiple text files across several servers assuming the files are located in the same path.

I figured that the Get-Content cmdlet was the starting point I was looking for. Sure enough it got the log.

Get-Content "\\server001\c$\Program Files\Tivoli\TSM\TDPExchange\excsch.log

Big log, too much information.

Winning converts to PowerShell through VMWare

We recently upgraded to VMware 3.5. One of the reasons was Update Manager and it's ability to automate vmotion and patching. This was really cool. Turns out, there is a 'gotcha'. You can't automatically use update manager to vmotion a system that has the CD Rom drive connected. My co-worker discovered this on a update of a test environment and discussed this with support, their answer was to check all the systems. As I was going to be helping do this on a Saturday evening, late, I didn't like this answer so much on checking a hundred guest systems manually.

Setting up a PowerShell environment

Having really gotten excited about PowerShell, I have been getting more friends and co-workers to like and use it. So this post is links to downloads and instructions for setting up PowerShell and some of the tools I use so I don't have to repeat myself so much. I freely admit that I am still learning but this will at least get your environment setup quickly (and since we manage VMware servers where I work, links for them are provided).

Getting user display names

There I was with a list of user login id's and a need to turn them into Display Names. Hmmm..... get-qaduser seemed a likely choice.

Quest PowerShell extensions GET-QADGroupMember

Last year, I found a neat tool to list group members in PowerShell. Well, my co-worker asked me about it again and it's a good thing I blog as I couldn't remember what I told him.

Turns out, Get-QADGroupMember was the tool I was after. This time there was a slight twist. He wants to get the members of a distribution group that are nested in another one and weed out any duplicates.

Hmmm...... Probably not the prettiest way, but this seems to get us the information he needs. It will error if there are user accounts in the top level group.

# Requires Quest Active Directory Extension
# Get date for file name
$day = Get-Date -UFormat "%Y%m%d"

$count = 0
$groups = Get-QADGroupMember "Distribution list name"
foreach ($group in $groups)
  { $count++
    $members = Get-QADGroupMember $group.DisplayName
   }
$members | sort-object | select DisplayName | get-unique -asstring | Export-Csv -Path $day-members.csv

It could be improved by allowing input from the PoSH line. I may update tomorrow.

Syndicate content

Sometimes I get asked, so here it is ... My Amazon.com Wish List

Thought I'd see what this Technorati stuff does.

Login with your @drupal.org user id or your OpenID to leave unmoderated comments
contents copyright Steven Peck - powered by drupal logo