TEC 2010 – Advanced Training on Microsoft Active Directory and FIM

Today I registered for TEC 2010 which will be in Los Angeles this year. I have never attended TEC before but last year I was right down the road at TechED. I am still waiting to hear if I will be attending TechEd 2010 as well.

I am excited to see some focus around Active Directory and Forefront Identity Manager at a conference especially since Forefront Identity Manager was just released to manufacturing. One of my fears in attending this conference this year was that FIM would be released after TEC 2010 and covered in greater detail at TechED 2010, now with the release of FIM I hope that is not the case. I have already seen some vendors providing extensions to FIM so this may be the best year to go to TEC so far.

I definitely will be posting some more information and pictures during the event. Feel free to email me with any suggestions around the conference or questions you would like to be asked. ITNotes@gmail.com


PowerShell – ProperCase Function

Change any case to Proper Case (‘ITNOTES DoT net’ to ‘Itnotes Dot Net’):
This is very useful for us during scripted user creations when the usernames and such from the source were in random cases. This script could also be useful with auto user provisioning with ILM/FIM 2010 from another datasource, we were using a VBScript that is much longer.

This script basically converts everything to lowercase then capitalizes the first letter of each word.

function ToProperCase ([String]$in)
 $in = $in.Tolower()
 $textInfo = [System.Threading.Thread]::CurrentThread.CurrentCulture.TextInfo  
 return $textInfo.ToTitleCase($in)

Example of use:

Itnotes Dot Net

Complete Script

function ToProperCase ([String]$in){
 $in = $in.Tolower()
 $textInfo = [System.Threading.Thread]::CurrentThread.CurrentCulture.TextInfo
 return $textInfo.ToTitleCase($in)

As noted by Lee, here is a oneliner contributed by Jonathan Noble at http://www.jonoble.com/. Thanks Lee.

(Get-Culture).TextInfo.ToTitleCase(“THIS IS MY STRING”.ToLower())

I am always in favor of shorter scripts nevertheless I also favor functions, so here is a much shorter function:

function ToProperCase ([String]$in){
return (Get-Culture).TextInfo.ToTitleCase($in.ToLower())

New Role – Active Directory / Identity Management Engineer

I was recently promoted to our company’s Security Team as an Active Directory / Identity Management Engineer. So most of my future posts will be aimed towards those technologies and Group Policy. I will also continue to post some hopefully helpful VBScripts and PowerShell Scripts. I still have a few draft posts that I plan to publish eventually that maybe helpful in the Windows Installer and Packaging Space however no new findings will be posted in this expertise.

Thanks for reading!


Windows XP Favorites Folder Redirection via GPOs

Per [MS-GPFR] – In Windows 2000 Server, Windows XP, and Windows Server 2003, a constant list of exactly five user profile folders can be redirected, including My Documents, My Pictures, Desktop, Start Menu, and Application Data.

[MS-GPFR]: Group Policy: Folder Redirection Protocol Extension documentation can be downloaded here.

So in other words folder redirection for Favorites and others file folders in not supported until Vista or later.

So using Folder Redirection for My Documents only I created two Group Policy objects. One GPO being the standard Folder Redirection Policy pointing serveral groups to various MyDocuments stores. With a second Group Policy object I added the following script to the logon process. The script sleeps for 30 seconds allowing time for other group policy objects to complete processing and then using special folders the script gets the MyDocuments location and appends \Favorites to the end and then populates the appropriate registry value to redirect Favorites. I additionally added a three minute timeout to the script incase the scripts hangs, not that it would, but you wouldn’t want it to hang indefinitely.

Simple Favorites Folder Redirection using Special Folders for MyDocuments

On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

WScript.Timeout 180
WScript.Sleep 30000
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
strValueName = "Favorites"
strValue = WshShell.SpecialFolders("MyDocuments") & "\Favorites"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

Re-Usable VBScript Functions – Part I

In this Multi-Part Series I will post lists on VBScript Functions and Subs that I have either found or written. I am a big fan of turning any useful code into a functions and adding it to my default VBScript Template, it saves a ton of time on the next scripting task. By no means am I claiming I wrote all of  these, most were just re-purposed into reusable functions. I hope you find these useful. In the later part of the series I will include my template I use to begin all my scripts.

Determine if the computer is a laptop:

Function IsLaptop(strComputer)
    On Error Resume Next
    Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
    Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , 48 )
    IsLaptop = False
    For Each objItem in colItems
        IsLaptop = True
    If Err Then Err.Clear
    On Error GoTo 0
End Function

Example of use

If IsLaptop( "." ) Then
    WScript.Echo "Laptop
    WScript.Echo "Desktop or server
End If

Shell out a command line with switches:

Sub RunSwch(ByVal strRunCmd, strRunSwitch)
Dim objWshShell
    Set objWshShell = CreateObject("WScript.Shell")
    objWshShell.Run Chr(34) & strRunCmd & Chr(34)& " " & strRunSwitch, 1, True
    Set objWshShell = Nothing
End Sub

Example of use

RunSwch "C:\Program Files\ApplicationX\Start.exe","/S /X /Log C:\log.log"

Shell out a command line without switches:

Sub Run(ByVal strRunCmd)
Dim objWshShell
    Set objWshShell = CreateObject("WScript.Shell")
    objWshShell.Run Chr(34) & strRunCmd & Chr(34), 1, True
    Set objWshShell = Nothing
End Sub

Example of use

Run "C:\Program Files\ApplicationX\Start.exe"

Windows 7 Ultimate Signature Edition

I received my copy of Windows 7 Ultimate Signature Edition today in the mail. I thouhgt I would share an image of it. The DVD itself is just a promotional disc with the Product Key inside the case. The only thing special is the outside of the case itself. Well here it is  (It was impossible with my photography skills to get rid of the glare)

Windows 7 Ultimate Signature Edition

Windows 7 Ultimate Signature Edition

Host a Windows 7 House Party!

What a cool idea, host a Windows 7 House Party and get free stuff! Apply online to host a Launch Party. Choose a day from October 22-29 and if you’re selected, you’ll not only receive a special Signature Edition of Windows® 7 Ultimate but your very own Windows® 7 Party Pack.

All Hosts will receive:

  • One limited Signature Edition Windows 7® Ultimate
  • One Deck of Playing Cards with Windows 7® Desktop Design
  • One Puzzle with Windows 7® Desktop Design
  • One Poster with Windows 7® Desktop Design
  • Ten Tote Bags with Windows 7® Desktop Design for hosts and guests

Also included in USA party packs:

  • One package of streamers for decoration
  • One package of balloons for decoration
  • One table top centerpiece for decoration
  • One package of Windows 7® napkins

Also a drawing of 64 eligible entrants who are hosts of a Windows® 7 Launch Party will win a mini-notebook laptop personal computer.

To Apply and find more details from the source: http://www.houseparty.com/splash/windows7usa

See above website for exact details, blog post is for informational purposes only, so be sure to read the rules and details from the source. We will not be responsible for any inaccuracies found on ITNotes.net.

Simple Script to find MSI errors

Here’s a simple PowerScript to pull out MSI errors out of the EventViewer and the MSI logs.

Baiscally the script first clears the log file then clears everything out of the Temp directory. Next the script prompts for the admin to start the installation, once you are done installing the program click ok to continue. The script will then collect the error messages from the MSI logs and the last three windows installer entries from the EventViewer. If there are no errors then it will return sucessful installs entries from the Event Viewer and nothing from the logs. In short this script is just a time saver from having to dig though the event logs and the temp directory for the msi logs and then having to go through those long MSI logs. Troubleshooting the error codes will still need to happen outside of the script.

Be sure to enable Windows Installer logging before beginning. This can be set with the following PowerShell command line.

Set-ItemProperty -path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer” -name “Logging” -value voicewarmup

Here’s the final code:


Clear-Content errors.txt
get-Childitem $env:Temp | remove-Item -force
$a = new-object -comobject wscript.shell
$b = $a.popup("Please run installation and click ok once installation is complete",0,"Waiting for MSI Installation and User Input",1)
Get-EventLog Application | ? {$_.Source -eq "MSIInstaller" } |  Select-Object TimeGenerated,Source, EntryType, Message -First 3| Format-List | out-file errors.txt
#-and $_.EntryType -eq "Error"
filter finderrors { if ($_.contains("Error")) {$_}}
Get-Content $env:temp\MSI*.log | finderrors | Out-File -Append errors.txt | notepad errors.txt

PowerShell 2.0 Release Candidate for Windows Vista and Server 2008

Still waiting for PowerShell 2.0 for Windows XP and Server 2003, but this is a good start.

Read more from the source: http://blogs.msdn.com/powershell/archive/2009/08/14/powershell-2-0-for-windows-vista-and-windows-server-2008-release-candidate.aspx

Download here: https://connect.microsoft.com/windowsmanagement/Downloads