Wednesday, September 26, 2012

Import users into SBS 2011 console after a migration.

 

After doing a SBS migration to SBS2011, I found that the users were not displaying in the Small Business Server console.

I came across Brian Fahrenholtz’s script on his website http://blog.coretech.dk and it works pretty well.

' // ***** Script Header *****
' //
' // Solution: SBS Console
' // File: AddUsersToSBSConsole.vbs
' // Author: Brian Fahrenholtz, Coretech A/S. http://blog.coretech.dk
' // Purpose: Add Active Directory user accounts to the SBS Console
' //
' // Usage: AddUsersToSBSConsole.vbs
' //
' //
' // CORETECH A/S History:
' // 1.0.0 BFA 27/01/2011 Created initial version.
' //
' // Customer History:
' //
' // ***** End Header *****
' //***************************************************************************
' //----------------------------------------------------------------------------
' // Main routines
' //---------------------------------------------------------------------------- 
' Defines the OU location for user accounts
' Remember to define the user location before running the script
' Default adds users located in SBSUsers
strSearchOU = "OU= import users,DC=contoso,DC=local"
' Create the ADO Recordset Object
Set rs = CreateObject("ADODB.Recordset")
' Open the Record Set based on the arguments
rs.Open "<LDAP://"& strSearchOU & ">;(&(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2)));adspath;subTree", "provider=ADsDSOObject"
Do Until rs.EOF
 'Create an instance of a user object from AD
 Set oUser = GetObject(rs.Fields("adspath"))
 'Update the local property cache value using the Put method
 oUser.Put "msSBSCreationState", "Created"
 'Write the local property cache back to AD
 oUser.SetInfo
 rs.MoveNext
Loop
'//----------------------------------------------------------------------------
'// End Script
'//----------------------------------------------------------------------------



Make sure to put a test user in an OU “Imported Users” to test the script out.


Make changes specific to your environment on the line

strSearchOU = "OU= import users,DC=contoso,DC=local"

No comments: