Welcome to MSDN Blogs Sign in | Join | Help

Using a Logon Script to Install the SMS Advanced Client

One of my customers has an extensive lab environment with multiple forests, domains and workgroup computers.  SMS 2003 was deployed to help manage the configuration of all these different systems.  Between the locked down security settings (no C$, ADMIN$ shares!) and the number separate forest/domains/workgroups involved the ability to "push" the advanced client to desktops is no longer an option.  After meeting with the client last week we decided to configure a logon script to install the SMS client.  The script and associated files (CCMSETUP.EXE, CLIENT.MSI, SMSCLIENT.VBS) were placed in a folder named SMS in the NETLOGON share of the Domain Controllers.  We then configured the LOGON SCRIPT properties of the Domain Administrator account to run the SMSSTARTUP.VBS script shown below to install the client.

Now for a quick run through of the code. 

  • Declare our variables and create the objects we will be working with. 
  • Determine the path to the NETLOGON \SMS folder we are using.
  • Check to see if the SMS client is installed (Set oSMSClient ... If Err.Number....)
  • Display a timed popup message with a Cancel button
  • Copy install files to local computer.
  • Run installation script (SMSCLIENT.VBS)
  • Set commands in the RunOnce registry key to delete the SMSCLIENTINSTALL folder the next time someone logs in.

SMSSTARTUP.VBS

'**********************************************
'  SCRIPT: SMSStartup.VBS
'  AUTHOR:
'  DATE:   10/16/2008
' VERSION: 2.0
' PURPOSE: Check for thr presence of the SMS client,
'                   if not installed, copy files from the
'                   network to c:\smsclientinstall and install
' USAGE:     SMSStartup.vbs
'                             
'REVISION: 10/17/2008 added check
'                  to make sure files and folders exist
'                  before moving to next step in script
'         
'**********************************************
OPTION EXPLICIT
On Error Resume Next

Dim oSMSClient, intButton,objWshShell,sFolder, objFSO, sCurrentPath
Dim oExec

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set oSMSClient = CreateObject ("Microsoft.SMS.Client")

'Folder to copy SMS install files to
sFolder = "C:\SMSCLIENTINSTALL"

WScript.Sleep 15000

'Build path to SMS files
sCurrentPath = objWshShell.ExpandEnvironmentStrings("%LOGONSERVER%")
sCurrentPath = sCurrentPath & "\NETLOGON\SMS"

 

 

If Err.Number <> 0 Then 'change to zero when testing complete
     'Clear error buffer
     err.clear
    objWshShell.LogEvent 2, "SMS Client is not installed, installing now."
    intButton=objWshShell.Popup("Installaing SMS Client software on this computer in the background",5,"SMS Client Software Installation",1)
    'wscript.echo intbutton
    If intButton = 2 Then
        objWshShell.LogEvent 1, "SMS Client installation was cancelled by the user"
        wscript.quit
    End If

 'copy files to local computer and begin client installation
 Do While objFSO.FolderExists(sFolder) <> TRUE
  CreateFolder sFolder
  WScript.Sleep 10000
 Loop

 'copy files
 'Check for files before continuing to next file
 Do While objFSO.FileExists(sFolder & "\SMSCLIENT.VBS") <> TRUE
  objFSO.CopyFile sCurrentPath & "\SMSCLIENT.VBS", sFolder & "\", TRUE
  wscript.sleep 2000
 Loop
 
 Do While objFSO.FileExists(sFolder & "\Client.msi") <> TRUE
  objFSO.CopyFile sCurrentPath & "\client.msi", sFolder & "\", TRUE
  wscript.sleep 2000
 Loop
 
 Do While objFSO.FileExists(sFolder & "\ccmsetup.exe") <> TRUE
  objFSO.CopyFile sCurrentPath & "\ccmsetup.exe", sFolder & "\", TRUE
  wscript.sleep 2000
 Loop
 
    'now run sms client install
    Set oExec = objWshShell.Exec("wscript.exe " & sFolder & "\SMSCLIENT.VBS")

    Do While oExec.Status = 0
      WScript.Sleep 1000
    Loop

 'delete the folder by adding command to the Runonce key
 'CMD.exe /c "RD /s /q c:\SMSCLIENTINSTALL"
 objWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\SMS", "CMD.EXE /c " & CHR(34) & "RD /s /q C:\SMSCLIENTINSTALL" & CHR(34), "REG_SZ"

Else
    'Computer has client, quit
 wscript.quit
End If

Function CreateFolder(folder)
   Dim ofso, f
   Set ofso = CreateObject("Scripting.FileSystemObject")
   Set f = ofso.CreateFolder(folder)
   CreateFolder = f.Path
End Function

Sub DeleteAFolder(filespec)
   Dim ofso
   Set ofso = CreateObject("Scripting.FileSystemObject")
   ofso.DeleteFolder filespec,TRUE
End Sub

 

Posted by MuadDib | 0 Comments
Filed under: , ,

Configuring SMS to Work on Workgroup Computers and Computers in Other Domains (LMHOSTS)

As described in the previous post the lab environment includes multiple forests, domains and workgroup computers.  One of the nice things about SMS 2003 is the fact that once the SMS Client has been installed on a system, you "own" that system and can manage it from that day forward.  In the previous post, we discussed how to use a logon script to install the SMS Advanced Client.  In this post we will discuss how to configure computers that are not located within the same domain as the SMS server to be able to find the SMS Management Point (MP) and Server Locator Point (SLP).

All Windows operating systems since Windows 2000 rely on DNS for name resolution.  A clients still have WINS installed to support some legacy applications but most do not.  An LMHOSTS file is similar to a HOSTS file.  A HOST files is used to map DNS hosts names to IP addresses.  An LMHOSTS file is used to map NetBIOS names to IP addresses.   NetBIOS names differ from DNS names because you can have different types of NetBIOS names (e,g, domain, workstation service etc.).  The LMHOSTS files is placed in the same folder as the HOSTS file (%WINDIR%\System32\Drivers\Etc).

An example of the LMHOSTS file is shown below.  Copy the code below into Notepad and save the file as LMHOSTS (no extension) to the "%WINDIR%\System32\Drivers\Etc" folder.  Customize the entries to match your environment.  When you see the pound (#) sign in an LMHOSTS file it is usually followed by a comment unless it is followed by one of the special directives such as PRE< DOM, INCLUDE etc.  The PRE directive loads the entires into the NetBIOS name cache on startup.  The DOM directive is used to indicated a domain name.  The INCLUDE directive is used to include another LMHOSTS file.

In the sample file below the first three lines are comments.  The fourth line pre-loads the domain name where the SMS servers is located and provides the IP address of a DC in that domain.  The next line provides the name and IP address of the SMS server (SMSSERVER1).  The next line provides the name of the SMS Server Locator Point (SMS_SLP) and the line that follows defines the Management Point (MP_C01).  Notice the entries for the SLP/MP look very different from the others.  The "\01xa" is a NetBIOS suffix and there must be exactly 15 characters between the the first quote and the backslash.  For the SMS_SLP line on change the IP address to the IP of the computer hosting the SMS SLP role.  For the MP, change the IP and change the SMS site code in the file from C01 to the site code of your SMS site.

<------------------------------ BEGIN LMHOSTS ----------------------------------->

# LAB LMHOSTS File
#REVISION: 2
#DATE: 10/17/2008
192.168.101.143     DC01         #PRE #DOM:LABDOMAIN1  # Lab Domain DC
192.168.101.141    SMSSVR1 #PRE
192.168.101.141   "SMS_SLP        \0x1A" #PRE
192.168.101.141   "MP_C01         \0x1A" #PRE  

<------------------------------    END LMHOSTS ----------------------------------->

 When you start using LMHOST files you quickly realize that trying to manage the content of these files on multiple computers because a big pain real fast.  If you need to make a change, you need to update every file with the change.  Fortunately the #INCLUDE directive discussed earlier enables you to use a centralized LMHOSTS file.  In our lab environment we created a share on the SMS server named "SMSLMHOST" and placed the first LMHOSTS file shown above there.  The LMHOSTS file shown below was placed on the computers that needed a LMHOSTS.  There are two entries shown.  The first one provides the name/IP of the SMS server and the second directs the client to read the master LMHOSTS file stored on the server.

 <------------------------------   BEGIN LMHOSTS ----------------------------------->


192.168.101.141 SMS1 #PRE
#INCLUDE \\SMSSVR1\SMSLMHOSTS\lmhosts

<------------------------------    END LMHOSTS ----------------------------------->

REFERENCE

NetBIOS Suffixes (16th Character of the NetBIOS Name)
http://support.microsoft.com/default.aspx/kb/163409/

HOWTO: Assign SMS Advanced Client to the Isolated Secondary Site
http://support.microsoft.com/kb/555853

LMHOSTS File Information and Predefined Keywords
http://support.microsoft.com/kb/102725

Domain Browsing with TCP/IP and LMHOSTS Files
http://support.microsoft.com/kb/150800

Chapter 10 - Using LMHOSTS Files
http://www.microsoft.com/resources/documentation/windowsnt/4/server/reskit/en-us/net/sur_lmh.mspx?mfr=true

Posted by MuadDib | 0 Comments

Who's in the Local Administrators Group?

I was organizing files this weekend and ran across a script I created for a customer recently.   They we trying to determine the membership of the local Administrators group on each computer on their network.  The had determined that non-admin users were being added to the local Administrator group and needed to know how widespread the problem was.  Once they determine that I recommended they use Group Policy, Restricted Groups to fix the problem.

The VBScript below follows my standard script format that starts with an input file (INPUT.TXT) with a list of computers and automatically creates a tab-separated (for analysis in Excel) output file based on the name of the input file and appends RESULTS.TXT to the name.  Once we open the input for to read,  and the output file for writing we start the loop.  The real work happens in the DO WHILE loop.  First thing we do is run a Function named Get ComputerStatus.  Since we are connecting to a remote computer, I use this function to determine if a computer is online by pinging it.  If it is online we continue, if not we write "Computer Could Not Be Contacted" to the log and get the next computer in the list.  The EnumGroup function is used to get the membership of the local Administrators group and write it to the log file.  Once we finish the files are closed and the log file is opened in notepad.

To use this script, copy the contents to notepad and save the file with a VBS extension.  Create an input file with computer nameon each line.  You can run the script by double clicking it but I prefer to run it from a command prompt using cscript so that I only have a single command prompt instead of a command prompt for every "ping".  If anyone uses this script and finds it useful leave me a comment and/or a rating.
 

LocalAdminGroupMembership.vbs

'**********************************************
'  SCRIPT: LocalAdminGroupMembership.vbs
'  AUTHOR: Muaddib :-)
'  DATE: 08/21/08
' VERSION: 1.0
' PURPOSE: Used to Query remote computers and enumerate memebers of
'          local admin group
'   USAGE: 1. List computers to be queried in input.txt (other text file)
'          2. LocalAdminGroupMembership.vbs
'          3. Output file, results.txt will show status
'Revision:
'         
'
'**********************************************

Option Explicit

'ON ERROR RESUME NEXT 'Do Not Uncomment until script is ready for production

Dim oWshShell, oFSO, oFileName1, oFilename2, objWMIService, colItems, sProtocol, sSearch, sNWStatus, sDate, iErrNumber
Dim objItem, strComputer, oExec, strPingStdOut, sStatus, bComputerOnline, aComputers, Computer, sOutPutFile, sInPutFile, sComputerStatus
Dim arrFileNAme, sOutPutFileName,objGroup, strOffset

CONST ForReading = 1
CONST ForWriting = 2
CONST ForAppending = 8


'Prompt for name of input file
sInPutFile = INPUTBOX("Enter name of input file.  Input file must exist in the script folder.", "Enter Input File Name","input.txt" )
IF sInputFile = "" THEN
   wscript.echo "Operation was cancelled"
   wscript.quit
END IF  

'Trim extension from sInputFile1  
arrFileNAme = Split(sInPutFile, ".")
sOutPutFileName = UCASE(arrFIleNAme(0))
'Prompt for name of output file
sOutPutFile = INPUTBOX("Enter name of output file.  Output file will be placed in script folder.", "Enter Output File Name",sOutPutFileName & "_RESULTS.TXT" )
IF sOutPutFile = "" THEN
   wscript.echo "Operation was cancelled"
   wscript.quit
END IF  

Set oWshShell = Wscript.CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

'Open input file and read
Set oFilename1 = oFSO.OpenTextFile(".\" & sInPutFile, ForReading, False)
iErrNumber = err.number
  'Check for missing file
  IF iErrNumber = 53 THEN
     Wscript.echo "Error - " & sInPutFile & " file was not found."
     wscript.quit
  END IF

Set oFilename2 = oFSO.OpenTextFile(".\" & sOutPutFile, ForWriting, True)

' OPTIONAL LOG HEADER
'Get date and write it to log
'sDate = Now()
'oFilename2.writeline "Log Started " & sDate
'oFilename2.writeblanklines 1

'Read external list of computers and check their status
DO While oFilename1.AtEndOfStream <> True
    strComputer = oFileName1.ReadLine
   
    IF GetComputerStatus(strComputer) = 1 Then
        'sComputerStatus = "Online"
        Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
        sComputerStatus = EnumGroup(objGroup, "")
      Else
        sComputerStatus = "Computer Could Not Be Contacted"
    End IF
       
    oFilename2.writeline strCOmputer & vbTab & sComputerStatus
Loop

'OPTIONAL LOG FOOTER
'sDate = Now()
'oFilename2.writeblanklines 2
'oFilename2.writeline "Log Completed " & sDate

'Close input file
oFilename1.close
'Close Log file
oFilename2.close

'Wscript.echo "Finished Scanning Computers" 'open log file
oWshShell.run "notepad.exe .\" & sOutPutFile, 5, FALSE

Set oWshShell = Nothing
Set oFSO = Nothing
Set oExec = Nothing
Set oFilename1 = Nothing
Set oFilename2 = Nothing

Function GetComputerStatus (strComputer)
  'Function Returns a 1 if computer is available
  'Used to determine if a computer is online before
  'attempting WMI connection
  'IP Address or computer name can be used
  Dim sStatus
  sStatus = 0
'   wscript.echo "Echo strCOmputer - " & strcomputer
  Set oWshShell = Wscript.CreateObject("Wscript.Shell")
  Set oExec = oWshShell.Exec("ping -n 2 -w 1000  " & strComputer)
  strPingStdOut = oExec.StdOut.ReadAll
    If InStr(1,strPingStdOut, "reply from ",1) <> 0 Then
      sStatus = 1
    Else  
      sStatus = 0
    End IF
    GetComputerStatus = sStatus
 END FUNCTION      
 
Function EnumGroup(objGroup, strOffset)
   Dim objMember, strMembers
   For Each objMember In objGroup.Members
      strMembers = strmembers & strOffset & objMember.Name &  ", "
   Next
  EnumGroup = strMembers
End Function

Sample INPUT.TXT     

Computer1
Computer2
Computer3
Computer4

Sample Input_RESULTS.TX

Computer1 Computer Could Not Be Contacted
Computer2 Administrator, Administrator, Domain Admins, SMS_ADMIN,
Computer3 Administrator, Domain Admins, Administrator, SMS_ADMIN,
Computer4 Administrator, Domain Admins, Administrator, SMS_ADMIN,

Posted by MuadDib | 2 Comments
Filed under: ,

Sub-Select Query - The Holy Grail of SMS Collections

Learned a cool trick this week for building SMS/SCCM collections that will return a list of computers that "do not have something".  Building a collection that returns a group computers with a particular file or program on them is easy enough.  You create a query that returns the systems you want and then import the query when you are defining the collection. 

How do you build a collection of systems that do not have have something.  If you build a query that says "give me every computer that does not have Adobe Reader installed" the query will return every computer listed in your database.  This will occur because every system will have at least one entry (actually dozens) in Add Remove Programs that does not match "Adobe Acrobat".  Therefore every system evaluates as true and is selected as part of your query. 

What you really need is a query that says "I need every computer that is not in the 'Computers with Adobe Reader' collection".  What you need is a Sub-Select query.  Lets take an example:

My customer needed to deploy Microsoft Office Infopath 2003 on systems that did not have the product installed.  The first thing we did was create a query that showed us all the systems that had InfoPath installed.  Easy enough:

select SMS_R_System.NetbiosName from  SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = "infopath.exe" and SMS_G_System_SoftwareFile.FileVersion like "12.0.62%"

When we defined the query and named it "Computers with InfoPath".  We only had it return the computer name (SMS_R_System.NetbiosName ) and the Criteria was the file name and the version.  Click apply to save you changes then click Edit Query Statement > Show Query Language and copy the code out and paste it into Notepad for now.

Next step is to create a second query and name it "Computers without InfoPath.  Again we only selected the computer name for display.  For Criteria we do something different.  For Criterion Type field, select "SubSelected Values", for the Operator field, select "is not in" and for the Subselect field, paste the code pasted into Notepad in the step above.  Click OK twice and click apply to save you changes.  Now click Edit Query Statement > Show Query Language and you should have a query that looks like this:

select SMS_G_System_SYSTEM.Name from  SMS_R_System inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name not in (Select SMS_G_System_SYSTEM.Name From SMS_R_System Inner join SMS_G_System_SYSTEM On SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId Inner join SMS_G_System_SoftwareFile On SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId Where SMS_G_System_SoftwareFile.FileName = "infopath.Exe" And SMS_G_System_SoftwareFile.FileVersion LIKE "12%") and SMS_R_System.Client = 1

Notice the code in blue above is from our original query of "Computers with InfoPath" and the new query says "return every computer who's name is not in the following query".

Posted by MuadDib | 1 Comments
Filed under: , ,

Query Individual Properties of the "userAccountControl" Active Directory User property

I was working with a customer this week who was asking me how to query Active Directory for valid, active users accounts that were not service accounts.  I made a couple of assumptions; an active account would not be disabled and only service accounts would be set to PASSWORD NEVER EXPIRES.   Initially I tried to query the valueuserAccountControl property of the user object using operators like > and < but soon realized there were too many exceptions.  I then discovered it was possible to query the individual bits of the userAccountControl property which yielded the query below.

The following LDAP query can be used in Active Directory Users and Computers to query specific details of the userAccountControl property in AD.  The query below will return all active user accounts that are not set to PASSWORD NEVER EXPIRES

(&(objectCategory=person)(objectClass=user)(mail=*)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!userAccountControl:1.2.840.113556.1.4.803:=65536)(!userAccountControl<=600))

I'll describe the query in more detail:

(objectCategory=person)(objectClass=user)(mail=*) - All user objects with a value in the mail field (no contacts)

(!userAccountControl:1.2.840.113556.1.4.803:=2) - Filters out disabled accounts

(!userAccountControl:1.2.840.113556.1.4.803:=65536) - Filters accounts set to PASSWORD NEVE EXPIRES

(!userAccountControl<=600)) - Filters out Exchange Organization Mailboxes

REFERENCE

How to use the UserAccountControl flags to manipulate user account properties

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

How to query Active Directory by using a bitwise filter

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

Posted by MuadDib | 1 Comments
Filed under:

Modifying Security on Active Directory Objects using a script

I was working with a customer this week and we found some user objects in Active Directory had incorrect security settings.  I put together a list of commands for the customer to use.  I thought a few of the FOR command examples below were useful so here you go... 

These command can also be used in a script.  Keep in mind the FOR command syntax changes slightly (FOR /?) when used within a batch file.  

DUMP CNs for all users in an OU 
   DSQUERY USER "ou=test accounts, dc=contoso,dc=local"

Show security for an object in Active Directory
   DSACLS "cn=Jane doe1,ou=test accounts, dc=contoso,dc=local"

Show security for the SELF security principle on an object in Active Directory
   DSACLS "cn=Jane doe1,ou=test accounts, dc=contoso,dc=local" | find /i "self"

Use DSACLS on list of users in a file
   FOR /F "tokens=* usebackq"  %i in (`type users.txt`) DO dsacls %i
         (NOTE ` is a back quote found on same key as ~)

Use DSACLS on output of DSQUERY USERS <OU  DN>
   FOR /F "tokens=* usebackq"  %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i
         (NOTE ` is a back quote found on same key as ~)

   FOR /F "tokens=* usebackq"  %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i | find /i "self"
         (NOTE ` is a back quote found on same key as ~)

Reset a user to the default permissions as defined by the schema
   DSACLS "cn=jane doe1,ou=test accounts,dc=contoso,dc=local" /S (case sensitive)

Perfrom same task for all users in an OU 
   FOR /F "tokens=* usebackq"  %i in (`dsquery user "ou=test accounts,dc=contoso,dc=local"`) DO dsacls %i /S  (case sensitive)

Posted by MuadDib | 1 Comments

Windows Vista Resource Kit Has Been Released

The Windows Vista Resource Kit has been released:

 http://www.microsoft.com/MSPress/books/9536.aspx?wt_svl=10125VHa1&mg_id=10125VHb1 

If you are respponsible for deploying and supporting Vista then you should have a copy of the resource kit on your desk.  Mine is on the way...

 

Posted by MuadDib | 1 Comments

Send Email from a Script

Scripts are great for automating tasks that you need to perform on a regular basis.  With a few lines of code you add the ability to send an email from within your scripts to notify you of a particular event.

From a programming standpoint, there are two ways to send a script programmatically.  The first involves using the Simple Mail Transport Protocol (SMTP) service installed on the computer where the script runs.  The second method involves using another SMTP server to forward you emails.  I prefer the latter since you only need one computer running SMTP to send emails instead of installing the service on a number of computers.

Before you can use the script you must locate a server running SMTP.  Check with your mail administrator and see if you can use one of the mail servers to forward emails.  If you don't have a server running SMTP you can add it to one of your existing servers.  In Windows Server 2003 SMTP is installed as part of the POP3 service.  To install the POP3 service open Control Panel > Add or Remove Programs > Add/Remove Windows Components then select Email Services.  Click the details button and check the box next to POP3 Service. 

Once the service has been installed you need to configure it so it will relay emails.  Open IIS Manager, right-click "Default SMTP Server" and select properties.  Click the "Access" tab and select the "Rely..." button.  Select the "Only the list below" radio button and configure the servers that will be allowed to relay emails on this server.

Now that you have an SMTP server you need a script.  The script below is the one I used.  I created a function called "SendEmail" and I pass it the subject (sSubject) and body text (sPageText) as arguments.  By creating a function, I can reuse this block of code in multiple scripts.  I have hard coded the "from address" (oEmail.From), "to address" (oEmail.To), and SMTP server (app1.lab.local).

 

OPTION EXPLICIT
Dim sPageText, sSubject
ON ERROR RESUME NEXT

sSubject = "ALERT - UPS SHUTDOWN"
sPagetext = NOW() & "   The UPS has shutdown due to low battery.  UPSDOWN.CMD script was fired."

'Send Email
SendEmail sSubject, sPageText

Function SendEmail (sSubjectText,sBodyText)
    Dim oEmail
    Set oEmail = CreateObject("CDO.Message")
    oEmail.From = "ADMIN@lab.local"
    oEmail.To = "RemoteAdmin@yourdomain.com"
    oEmail.Subject = sSubjectText
    oEmail.Textbody = sBodyText
    oEmail.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    oEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
    "app1.lab.local"
    oEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    oEmail.Configuration.Fields.Update
    oEmail.Send
END FUNCTION

 

Resources

Sending E-Mail Without Installing the SMTP Service
http://www.microsoft.com/technet/scriptcenter/guide/sas_ent_wbpa.mspx?mfr=true

 

Posted by MuadDib | 0 Comments

Controlling Virtual Machines with a Script

I discovered how easy it is to control virtual machines with a script this weekend.  I have one server that I use to run virtual machines that I keep running all the time.  When I patch this server, I need to shut down all VMs before it is restarted and then restart the VMs after the computer starts.  After doing a quick search I discovered it only takes a few lines of code to shutdown or start a VM.

Shutdown a server named Server1
On Error Resume Next
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Server1")
Set objGuestOS = objVM.GuestOS
objGuestOS.Shutdown()

Startup a server named Server1
On Error Resume Next
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Server1")
objVM.Startup()

If you have multiple VMs you can put them all in the same script as shown below:

On Error Resume Next
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Server1")
Set objGuestOS = objVM.GuestOS
objGuestOS.Shutdown()
sleep 15000
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Server2")
Set objGuestOS = objVM.GuestOS
objGuestOS.Shutdown()

So to make things easier on me I wrote two simple scripts; one that starts the VMs and one that stops them.  I then configured a local policy on the server to run the script that starts the VMs as a "Startup Script" so the VMs would start automatically every time the server is started. 

Virtual Machine and Virtual Server Properties
http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true

 

 

Posted by MuadDib | 0 Comments
Filed under: ,

Santa brought me an XBOX 360 this year...

My wife figured out what to get the geek who has everything this year.  An XBOX 360! 

I can remember the first computer game I ever played, Telengard for the Commodore64.  It was primitive by todays standards.  When you "moved" your player, the player stayed in the middle of the screen and the map was redrawn around you.  Then several years later I started playing DOOM.  This was a great first-person shooter with the ability to play another person via modem (tricky but doable) or via a null modem cable.  I used to play a Deathmatch with a  neighbor every Friday night for about 4-5 hours.  We lived in two doors apart in townhouses and I had a null modem cable that ran from my third floor bedroom to his basement across our yards.  Then came DOOM II.  The next big game to come along was Duke Nukem 3D.  We used to get together and play networked Deathmatches with DUKE.  Then I stopped gaming.  Not sure why.  It just happened. 

I bought DOOM 3 last summer and tried to capture the old magic but it was no use.  After spending 10-12 hours in front of a computer at work, the last thing I wanted to do was sit in front of a computer to play a game.  The XBOX 360 has brought the magic back.  I now sit in a comfortable chair, play the game on a 43" HDTV with 5.1 channel surround sound instead of a 17" monitor and two plastic speakers.  With an XBOX Live account I can play against my friends (or strangers) via the Internet.  The quality of the games is amazing.  I am currently spending time with HALO2, Ghost Recon, and Gears of War (oh yea and sometimes my family LOL).  The graphics are beautiful, the action is fast and the controllers don't hurt my hands like a mouse and keyboard do.  I have not had a chance to play any an opponent over the Internet yet but I hope to this weekend.

Although I was not sure if I would enjoy playing games again I can now tell you I am hooked!  Gaming is now something I look forward to as a way to relax.  Of couse during the game I'm all tense and sweaty from the adrenalin rush of fighting for my life while being chased by mutants from space or enemy soldiers but when the game is over I do finally relax...

Posted by MuadDib | 0 Comments
Filed under:

Script Code Link Added

I have a link in the left navigation bar to a page where I will begin posting some scripts I have written.  I have written several useful scripts over the years and I'll post them here as time permits.  The scripts will mostly be VBscript using WMI and ADSI scripting interfaces to retrieve information from computers and Active Directory.  You might also find a couple of batch files mixed in.  Down the road I will post some Pwershell Scripts and tips as I come up to speed on this new scripting/administration interface.  A link to the modest beginning is shown below.

Script Code

Posted by MuadDib | 0 Comments
Filed under:

Troubleshooting Windows Server Update Service (WSUS)

The creation of the Windows Update web site a few years ago revolutionized the way people with Microsoft products updated these products with the latest patches.  Windows Update made it possible for a "mere mortal" to determine exactly which updates they needed to install and install them automatically.  Windows Update greatly improved the the overall security of millions of Windows Desktops worldwide. 

Windows Server Update Service (WSUS) is a free product from Microsoft that enables you to deploy your own Windows Update site within your own network and control which updates are installed on your equipment.  With WSUS, an administrator can authorize updates for deployment after they are tested and also get detailed reports of which updates each computer needs.  Another big benefit of WSUS is it enables updates to be deployed to computer while no one is logged in.  The most common scenario is to have users log out each night and install patches during the off hours so the computers can be rebooted if necessary.  Although WSUS can deploy patches for most Microsoft applications it is not a complete solution when it comes to maintaining a consistent configuration on all desktops and servers.  For large environments, SMS should be considered because it gives you the ability to deploy, applications and Operating Systems.  In addition SMS will provide detailed inventory information on the hardware and software you have in your environment.

I have been helping a customer bring their WSUS server back on line so they can get updates deployed until the SMS infrastructure they are designing has been completed.  The information below is related to troubleshooting the deployment of WSUS and the Windows Update client.

Windows Update Client
WSUS requires the latest version of the Windows Update client software to be installed.  Windows Server 2003 and Windows XP Service Pack 1 computers Will have the client by default.  For all other you should go to Microsoft.com/downloads to get the latest WSUS client.

Links
Download Windows Server Update Services (software & documentation)
http://www.microsoft.com/windowsserversystem/updateservices/downloads/WSUS.mspx

Client Diagnostic Tool
http://download.microsoft.com/download/9/7/6/976d1084-d2fd-45a1-8c27-a467c768d8ef/WSUS%20Client%20Diagnostic%20Tool.EXE

Server Diagnostic Tool
http://download.microsoft.com/download/7/7/4/7745a34e-f563-443b-b4f8-3a289e995255/WSUS%20Server%20Debug%20Tool.EXE

WSUS w/ SP1
http://www.microsoft.com/windowsserversystem/updateservices/downloads/WSUSSP1.mspx

Troubleshooting
Most of the troubleshooting that needs to be performed with WSUS is related to the clients installing updates and/or reporting they have installed updates.  Keep one thing in mind when troubleshooting, nothing happens instantly with WSUS.  The product is designed to be low maintenance and to have minimal impact on the operation of the computers that are clients.  Don't expect updates to be applied instantly.  If you need that kinds of response, use SMS.

The WSUS client on each computer can be configured manually for small environments but Group Policy is the preferred way.  The Group Policies are located at Computer Configuration > Administrative Templates > Windows Components > Windows Update.  Confirm the GPO is configured with the correct server name and the GPO is linked to the correct OUs.  At the client side, open a command prompt and run "GPUDATE /FORCE" (XP /2003 only) to apply the GPOs to the computer.  Now type "GPRESULT" to see which GPOs are being applied to the computer.  Confirm the GPO containing the WSUS settings was applied under Computer Settings.

Client Registry
There are two keys on the client that indicate that the computer is getting the WSUS settings from the GPO.  The first contains the actual policy settings:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU

The second set of registry keys contains information specific to the computer such as the "SusClientId", "NextDetectionTime", "ScheduledInstallDate" etc.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update

Client Log Files
The are two locations on the local computer where information is logged for the WSUS client.  The first tis the WindowsUpdate.log file located in the C:\Windows folder.  This file contains a running log of all the activity the WSUS client performs.  

The second log is named ReportingEvents.log and is located in the C:\Windows\SoftwareDistribution folder.  Open this log file and go the the last few lines to see which updates are available for installation.

The easiest way to see what is happening is to compare the log files from a working computer to the logs on the computer you are troubleshooting.

Another area to look at is the C:\Windows\SoftwareDistribution\Download folder.  This folder should contain tempo ray folder for recently downloaded updates pending installation.

Troubleshooting Steps

  1. Confirm GPO configuration and linkage to correct OU. 
  2. You should see the computer listed in the Unassigned Computers group once it begins reporting to the WSUS server. 
  3. Confirm the "Automatic Updates" and "Background Intelligent Transfer Service" is running on client and startup is set to automatic. 
  4. Run GPUPDATE & GPRESULT on client to confirm GPOs are being applied.
  5. Check the registry keys and confirm they exist.  If they do not, their may be conflicting GPO settings.  Open a blank MMC and add the RSOP snap in.  Run the RSOP snap in and review the WSUS settings are being configured.  If they are not, another GPO may have the WSUS settings set to "disabled" instead of "not configured".
  6. Review Log files.
  7. Stop and start the "Automatic Updates" and "Background Intelligent Transfer Service"services and then review the log files after a few minutes (remember, things do not happen instantly).  The log files should indicate what updates are required and will be installed
Posted by MuadDib | 0 Comments

Roaming User Profiles

A couple of my customers use Roaming User Profiles (RUP) so that a user's desktop, files and settings follow them no matter which computer they happen to be setting at.  This is a very cool feature for users because no matter which computer they log onto they always have the look and feel.  I have been researching some issues decided to post the information here for future reference.

 314478 How to Create and Copy Roaming User Profiles in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;EN-US;314478

227260 How a slow link is detected for processing user profiles and Group Policy
http://support.microsoft.com/default.aspx?scid=kb;EN-US;227260

227369 Default Behavior for Group Policy Extensions with Slow Link
http://support.microsoft.com/default.aspx?scid=kb;[LN];227369

221833 How to enable user environment debug logging in retail builds of Windows
http://support.microsoft.com/default.aspx?scid=kb;[LN];221833

RUP Issues Resolved by XP SP2

816880 Roaming profiles may not unload after you use WMI on a Windows Server 2003-based computer or a Windows XP-based computer
http://support.microsoft.com/?kbid=816880

819536 Roaming profiles are not saved when a user logs off a Microsoft Windows 2000-based computer or a Microsoft Windows XP-based computer
http://support.microsoft.com/?kbid=819536

827878 The "Exclude directories in roaming profiles" policy stops working when you add paths
http://support.microsoft.com/?kbid=827878

830464 Group Policy does not apply roaming profiles correctly if NTuser.dat and NTuser.pol files are not synchronized
http://support.microsoft.com/?kbid=830464

840998 Changes to your roaming profile are lost when you log on to a Windows XP-based computer
http://support.microsoft.com/?kbid=840998

321936 A roaming user profile does not upload successfully, and Event ID 1000 is logged in the application log in Windows 2000
http://support.microsoft.com/?kbid=321936

831651 "The roaming profile cannot be found" error message when you log on to your network from a Windows XP-based computer
http://support.microsoft.com/?kbid=831651

Documentation

User Data and Settings Management (Great resource for RUP Information)
http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/xpusrdat.mspx

Group Policy Settings for Roaming User Profiles
http://technet2.microsoft.com/WindowsServer/en/library/8623052e-c21f-4fd9-a9a1-056779c2758f1033.mspx?mfr=true

User Profiles and Folder Redirection FAQ
http://www.microsoft.com/technet/community/en-us/management/manage_faq.mspx

 

Posted by MuadDib | 1 Comments
Filed under:

Enable Remote Desktop

Remote Desktop is one of the greatest features added to the Windows operating system.  It enables you to perform remote administration of servers from your desk or fix one of your kids computers from the couch.  Of course it's only great if it is enabled on the computer you are trying to access.  If you find yourself unable to connect to a remote computer because Remote Desktop has not been enabled you can enable it remotely by flipping a bit in the registry using regedt32. 

Here's how:

  1. Use regedt32 to open the registry of the remote computer.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
  3. Change fDenyTSConnections to 0x00 (0x01 disables).  If the key is not there create it.

To enable Remote Assitance set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\fAllowToGetHelp to "1"

This is old news to most of us in IT.  I posted here because the information on the reg key is hard locate when you need it.  I was on-site at a customer yesterday and spent 30 minutes trying to locate this in the Microsoft Knowledgebase without finding it.

Posted by MuadDib | 1 Comments
Filed under: ,

Unlocking the Local Security Policy on a Computer

There are times when you are doing troubleshooting or testing when you need to work on a production computer in a lab environment.  In these cases you capture an image of the computer in question and restore it on lab hardware.  Many times the local security policy has been set by a GPO and cannot be modified by using the Local Security Settings MMC.  When the computer is removed from the network (and domain) the local security policy remains unchanged.  The procedure below will enable you to modify the local security policy on a computer where this has occured.

  1. Log onto the computer with an Administrator account.
  2. Start the Local Security Settings MMC (SECPOL.MSC)
  3. Export the current security settings to an INF file by right clicking the top node in the MMC and selecting Export from the context menu. (for Windows XP see additional information below) and name the file "current.inf" (name is not important)
  4. Open a blank MMC (Start > Run MMC)
  5. Add the Security Configuration and Analysis snap-in.
  6. Right-click the top node in Security Configuration and Analysis and select "New Database" and then save the database.
  7. When prompted to import a security template use the one exported in step 3 above (current.inf)
  8. Now right click Security Configuration and Analysis and select "Analyze Computer Now".
  9. Now browse to the setting you want to modify.  You will notice the database setting and computer settings are the same in all cases.  Double-click the setting and make changes.  Repeat for each setting you want to modify.
  10. When you are finished making changes, right-click top node and select "Configure Computer Now" and you changes will be applied.

In Windows XP the SECPOL.MSC does not support the exporting of the security configuration to a template.  The SECEDIT.EXE command-line utility does not support exporting the configuration either.  There is an updated version of SECEDIT.EXE available from Microsoft as described int he KB article below that does enable you to export the security configuration to an inf file.

You cannot use the Secedit.exe command-line tool to export the local security policy settings on a stand-alone workstation that is running Microsoft Windows XP
http://support.microsoft.com/default.aspx/kb/897327/

Posted by MuadDib | 2 Comments
More Posts Next page »
 
Page view tracker