Thursday, January 13, 2011

HOWTO: Allow Powershell to run unsigned scripts

To allow you to run unsigned Powershell scripts you need to change Powershell's security setting.

WARNING: Please do this at your own risk and use with caution.

From a PowerShell command prompt type: Set-ExecutionPolicy Unrestricted

For more info check out http://technet.microsoft.com/en-us/library/dd347628.aspx

ERROR: The term 'Get-QADUser' is not recognized as the name of a cmdlet, function, scr ipt file, or operable program.

Scenario:

You have installed Powershell + Quest ActiveRoles Management for AD. When you try to run a command that uses Quest cmdlet you get the below error:

The term 'Get-QADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Resolution:

Run the command: Add-PSSnapin Quest.ActiveRoles.ADManagement

You may receive the warning below which you can ignore.

Add-PSSnapin : Windows PowerShell snap-in "Quest.ActiveRoles.ADManagement" is l
oaded with the following warnings: The following error occurred while loading.....


Re-run your initial command.

HOWTO: PowerShell to manage AD user TS settings

Tip: Install PowerGUI as well the the QuestActiveRoles Management Shell for Active Directory modules. This provides the cmdlets like QADUser which we will be using below.

Setting TS attributes

Example: Set-QADUser mbailinovski -TsHomeDirectory "\\server\users$\mbailinov" -TsHomeDrive "W:"

Getting TS attributes
Retrieving terminal services properties is easy. You just execute Get-QADUser and the objects retrieved will have the corresponding properties – for your convenience, all starting with Ts.

Get-QADUser "Mitch Bailinovski" | format-list Ts*

TsProfilePath : \\server\users$\mbailinovski
TsHomeDirectory : \\server\users$\mbailinovski
TsHomeDrive : W:
TsAllowLogon : True
TsRemoteControl : 0
TsMaxDisconnectionTime : 00:00:00
TsMaxConnectionTime : 00:00:00
TsMaxIdleTime : 00:00:00
TsReconnectionAction : 1
TsBrokenConnectionAction : 0
TsConnectClientDrives : True
TsConnectPrinterDrives : True
TsDefaultToMainPrinter : True
TsWorkDirectory :
TsInitialProgram :

Important: Terminal services properties are only available when AD cmdlets are run on Windows Server 2003 or 2008 or when the Windows 2003 Server Administration Tools are installed.

Source: http://dmitrysotnikov.wordpress.com/2008/02/13/managing-terminal-services-attributes-with-powershell/

Windows 7 User Tile Automation

Useful link for automating the replacement of user tiles for different user accounts in Windows 7.

Tuesday, January 11, 2011

Windows could not parse or process the unattend answer file

During Sysprep the following error message appears:

"Windows could not parse or process the unattend answer file for pass [specialize]. The settings specified in the answer file cannot be applied. The error was detected while processing settings for component [Microsoft-Windows-Shell-Setup]"

The error is
generated by the CopyProfile setting in the unattend file not being able to copy the customized profile settings to the default user profile.

One solution would be to remove this setting from the answer file and allow the build process to complete successfully. Note that the default user profile will now not receive the custom settings you want to save.

Before sysprep is run, make sure only one local account exists i.e. Administrator

Remove any other local accounts from Computer Management > Local Users and Groups.

Browse to C:\Users and delete any profile directories for the local accounts that have been removed.

The final step is to clear the ProfileList in Windows registry (scroll to bottom of this article). Browse to HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList and make sure that profiles exists only for SYSTEM, LocalService, NetworkService and Administrator.

Run sysprep and capture a new image. the CopyProfile setting will now apply and save your custom settings to the Default User profile.

Mitch

Monday, January 10, 2011

A fatal error occurred while trying to Sysprep the machine

This message appears during Sysprep on a Windows 7 client when the Rearm program has run more than 3 times in a single Windows image (see here).

It is possible to workaround the problem by adding the SkipRearm setting to the Generalize pass in your unattend XML file.

Not sure if there is anyway around this if you are using KMS as it affects the client count on the KMS host. :(

Mitch

Friday, January 7, 2011

Export Outlook 2003/2007 calendar appointments to CSV file

This VBScript must be run as the logged on user. It will output all your Outlook calendar appointments to a CSV file for importing into Microsoft Excel.

I needed a way to report on what calendar appointments our users had to see whether they have more than one entry for a bank holiday.

Option Explicit

Const olFolderCalendar = 9
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim WshShell, WSHFileSystem, objOutlook, objNamespace, objCalendar, oReport

Set WshShell = CreateObject("WScript.Shell")
Set WSHFileSystem = CreateObject("Scripting.FileSystemObject")
Set oReport = WSHFileSystem.CreateTextFile("C:\Support\CalendarAppointments.csv", ForWriting, True)
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)

ProcessCalendar(objCalendar)

Sub ProcessCalendar(objCalendar)
Dim colItems, colItems2, itm
Set colItems = objCalendar.Items
Set colItems2 = colItems.Restrict("[Start] > '01/1/2011' And [Start] < '12/31/2012'")

For Each itm In colItems2
oReport.WriteLine itm.Subject & "," & itm.Start
'wscript.Echo itm.Subject & "," & itm.Start
Next
End Sub

oReport.Close