Archive

Archive for April, 2011

Making AD Changes using PowerShell

April 21, 2011 Leave a comment

Note – This post deals with making bulk changes to Active Directory. If you’re not careful you could really screw things up. Always test in a lab before making such changes in production.

I recently had a situation where I had to change the numeric value of the Department attribute in Active Directory then move it to extensionAttribute1 attribute. Below are the steps I went through to accomplish this.

Note – Some of these might seem weird but they were things I had to do that were specific to the environment.

You will need to install the Quest ActiveRoles Management Shell for Active Directory. (http://www.quest.com/powershell/activeroles-server.aspx)

All the values in the Department field were between 10000 and 10999. I needed to add 1000 to each one to make the values between 11000 and 11999. Before I did anything I wanted to export the current values. I opened ActiveRoles Management Shell for Active Directory & ran the following command.

Get-QADUser -SizeLimit 0 -IncludedProperties extensionAttribute1 -LdapFilter '(|(department=*)(extensionAttribute1=*))' | select name,samAccountName,dn,department,extensionAttribute1 | Export-Csv C:\Temp\export.csv

I did a little spot checking in the CSV file just to make sure all the data looked good. Then I ran the following script to add 1000 to each value. (You’ll need to save this to a .ps1 file & run it.)

Get-QADUser -SizeLimit 0 -LdapFilter '(department=10*)' | Foreach-Object{
if($ea1 = $_.department -as [int])
{
Set-QADuser -Identity $_ -ObjectAttributes @{department=($ea1+1000)}
}
}

To make sure there were no more numbers in the 10000s I ran the following command which returned no results as expected.

Get-QADUser -SizeLimit 0 -LdapFilter '(department=10*)' | select name,department,extensionAttribute1

Next I needed to copy the values from the Department attribute to extensionAttribute1. I ran the following script.

Get-QADUser -SizeLimit 0 -IncludedProperties extensionAttribute1 -LdapFilter '(department=11*)' | Foreach-Object{
if($ea1 = $_.department -as [int])
{
Set-QADuser -Identity $_ -ObjectAttributes @{extensionAttribute1=$ea1}
}
}

Finally I removed the values from the department attribute by running the following script.

Get-QADUser -SizeLimit 0 -LdapFilter '(department=11*)' | Foreach-Object{
if($ea1 = $_.department -as [int])
{
Set-QADuser -Identity $_ -ObjectAttributes @{department=''}
}
}
Advertisements

ScriptLogic Error on Login

April 15, 2011 2 comments

I received reports from users that they were getting ScriptLogic errors when logging in. The first one said:

ScriptLogic Notice
ScriptLogic has encountered a critical error while “Defining OS-Specific Variables…”.

They would click OK then get another error.

KiXtart
ERROR : expected ‘)’!
Script C:\Users\USERNA~1\AppData\Local\Temp\17\~TMFB74.tmp
Lince : 15605

Looking in the Event Viewer there was a corresponding entry.

Log Name:      Application
Source:        KIXTART
Date:          4/14/2011 3:34:30 PM
Event ID:      1
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      SERVER1.abc.com
Description:
The description for Event ID 1 from source KIXTART cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
ERROR : expected ‘)’!
Script: C:\Users\USERNA~1\AppData\Local\Temp\17\~TMFB74.tmp
Line  : 15605
 Error : Incorrect function. (0x1/1)

So I go to the folder mentioned in the error & look in the Desktop Authority folder. I open the SLAgent_Logon.txt file & find a ton of entries that say, “SLStart still in memory, waiting…” & “Entering OnTaskbarRestarted”. Thinking maybe the SciptLogic services are acting up I go to restart both ScriptLogic CBM Service & ScriptLogic Service. Before doing so I check to make sure I don’t stop any other services on accident. When I click the Dependencies tab I get the following error, “Service Dependencies. WMI: Not found”. Spot checking a few other services I get the same error.

As another test I run MSINFO32 since it also uses WMI to gather info. I get an error that says, “Can’t Collect Information. Cannot access the Windows Management instrumentation software. Windows Management files may be moved or missing.”  Searching around for that error leads me to KB323209 which basically says to make sure the Event Log, Windows Management Instrumentation, and Remote Procedure Call (RPC) are running, which they are.

Looks like a WMI repair is in order. I run winmgmt /salvagerepository but get the following error:

WMI repository salvage failed
Error code:     0x8007041B
Facility:       Win32
Description:    A stop control has been sent to a service that other running services are dependent on.

The ScriptLogic CBM Service would be the one it stopped. I run the command again & this time get a message that says, “WMI repository has been salvaged”. I switch back over to the Services MMC & open up a service to check its dependencies & don’t get an error! I then start the ScriptLogic CBM Service back up. I have the users log back in & they don’t receive any errors.

References – http://sites.google.com/site/zenarstudio/home/kb/windows-server-2008—howto—repair-wmi, http://msdn.microsoft.com/en-us/library/aa394525(v=vs.85).aspx, http://windowsxp.mvps.org/repairwmi.htm

Categories: Computers Tags: , ,

Import NK2 file into Outlook 2010

I’m going throught a little Office 2010 upgrade at work & I ran into a situation where I needed to import a user’s Outlook Autocomplete cache (the nickname file or NK2). Found a nice little KB article that did the trick.

http://support.microsoft.com/kb/980542

Categories: Computers Tags:
%d bloggers like this: