Showing posts with label WSH. Show all posts
Showing posts with label WSH. Show all posts

Wednesday, May 7, 2008

Decrypt / Encrypt string in ROT-13

' Converts a string from ROT13
Const Alpha_Upper = "abcdefghijklm" ' First 13 letters

Const Alpha_Lower = "nopqrstuvwxyz" ' Second 13 letters
Dim aAlpha, aStringDim iDim sROT13, sFullROT13


aAlpha = Split(Alpha, ",")
sString = Wscript.Arguments(0)


For i = 1 to Len(sString)
  iPos = InStr(Alpha_Upper, LCase(Mid(sString, i, 1)))
  If iPos > 0 Then ' Found in upper so return corresponding lower character
    sROT13 = Mid(Alpha_Lower, iPos, 1)
  Else
    iPos = InStr(Alpha_Lower, LCase(Mid(sString, i, 1)))
    If iPos > 0 Then
      sROT13 = Mid(Alpha_Upper, iPos, 1)
    Else
      sROT13 = Mid(sString, i, 1) ' Not an alphabetic character, so just return the supplied character
    End If
  End If

  sFullRot13 = sFullRot13 & sROT13
Next

Wscript.Echo sFullROT13

Monday, April 28, 2008

ZTI DefaultDomainName setting lost

During a ZTI based deployment we received intermittent reports of computers with the default domain name being set to the workstation instead of the domain it had joined.

Steps to reproduce the problem.

Set DefaultDomainName to the same name as the domain the computer is joined with mis-matching case.

Click the Drop-down box on the CTL+ALT+DEL screen, the logon box will change the Default Domain to be the workstation.

Cause:
When the DefaultDomainName is set to a name not matching the NetBIOS domain name, the workstation sets the Default domain name to the workstation.
This includes names that do not match case.


A custom script set the
"HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName" registry field but stored the domain name in lower case.


Resolution:
Modify the custom script to extract the domain from WMI.


"Select DomainName from Win32_NTDomain Where NOT DnsForestName IS NULL"

ZTITattoo.wsf - OSD clears TaskSequence registry entries

During OSD of a custom image the ZTITatoo.wsf script clears the TaskSequenceVersion, TaskSequenceName and TaskSequenceID fields.

Line 131 of ZTITatoo.wsf refers to a registry write action for when an LTI deployment is running.
Line 140 performs the corresponding update for OSD only if a OSD deployment is running.

The contents of TaskSequence* registry fields are pertinent to an OSD deployment as they provide information as to which WIM and Deployment task sequence are utilised.

I would contend that the ZTITatoo.wsf script would be better served having a conditional execution around the update of the LTI TaskSequence* fields.

Something like the following (Line 127);

'//----------------------------------------------------------------------------
'// If this is Lite Touch, populate the task sequence details
'//----------------------------------------------------------------------------
If oEnvironment.Item("OSDPACKAGEID") = "" then
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\BDD 2007\Task Sequence ID", oEnvironment.Item("TaskSequenceID"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\BDD 2007\Task Sequence Name", oEnvironment.Item("TaskSequenceName"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\BDD 2007\Task Sequence Version", oEnvironment.Item("TaskSequenceVersion"), "REG_SZ"
End If


Wednesday, April 23, 2008

Fix Broken Windows Scripting Host

Recently during an SMS application deployment we had an application installation remove the .vbs, .wsf and .js file associations.

I used the following command coupled with psexec.exe to restore functionality to the affected machines remotely.

Rundll32.exe setupapi,InstallHinfSection DefaultInstall 128 C:\Windows\inf\Wsh.inf

Using this method restores the files associations for .wsh, .vbs, .vbe, .js, .jse, .wsf, .wsc and also ensures that all WSH files are installed. This is the same command that XP Setup uses to install WSH.

Wednesday, April 16, 2008

Pre-Stage Computer resource record in SMS

Specifying the Computer name and MAC address provides a more accurate means of ensuring that the intended computer will assume the pre-staged SMS resource record.

The MAC address is optional, however, it increases the chance that the original physical computer will assume the new SMS Resource record.

Once the pre-staged record has been created, advertisements can be assigned to the record.
The advantage of this is that when the computer is built, it assumes the record and automatically receives the pre-configured advertisements.

See KB 307026 for list of elements checked during SMS client installation
http://support.microsoft.com/kb/307026

SMSResGen.dll is the SMS Resource Generator Object, which is included with the Active Directory/SMS Synchronization Tools. This tool is available from the Microsoft Web site at http://www.microsoft.com/smserver

VBScript Code for pre-staging a computer resource record in SMS

Const ADDPPROP_NONE = &H0
Const ADDPROP_GUID = &H2
Const ADDPROP_KEY = &H8
Const ADDPROP_NAME = &H44
'get the current GUID, if available
sComputer="TEST-WS1"
Set DDR=CreateObject("SMSResGen.SMSResGen.1")
DDR.DDRNew "System", "PrestageAgent", ""
' DDR.DDRAddString "SMS Unique Identifier", GUID, 64, ADDPROP_NAME
DDR.DDRAddString "Name", sComputer, 64, ADDPROP_NAMEDDR.DDRAddString "Netbios Name", sComputer, 64, ADDPROP_KEY
Dim IPAddress(3), IPSubnet(3), MACAddress(3)
IPAddress(0)=""
IPSubnet(0)=""
MACAddress(0)="00:0C:29:96:53:F2"
DDR.DDRAddStringArray "IP Addresses", Array(IPAddress(0),IPAddress(1)), 64, ADDPROP_ARRAY
DDR.DDRAddStringArray "MAC Addresses", Array(MACAddress(0),MACAddress(1)), 64, ADDPROP_ARRAY
DDR.DDRAddStringArray "IP Subnets", Array(IPSubnet(0),IPSubnet(1)), 64, ADDPROP_ARRAY
DDR.DDRWrite sComputer & ".DDR"
DDR.DDRSendtoSMS
Set FSO=CreateObject("Scripting.FileSystemObject")
'FSO.GetFile(sComputer & ".DDR").Delete

ImportGPO.wsf may not import GPO's using a Migration Table on Windows Server 2003

The ImportGPO.wsf script doesn't correctly test for null values at Line 162.

Cause: Incorrect testing of null value on Line 162

Resolution: See KB911800
http://support.microsoft.com/kb/911800