Tuesday, May 12, 2015

Task Sequence Built-in Variable List

This is totally a rip-off, copy/paste from https://technet.microsoft.com/en-us/library/hh273375.aspx but I wanted it here so that I know where to look for it quickly.
Built-in Variable NameDescription
_SMSTSAdvertID
Stores the current running task sequence deployment unique ID. It uses the same format as a Configuration Manager software distribution deployment ID. If the task sequence is running from stand-alone media, this variable is undefined.
Example:
ABC20001
_TSAppInstallStatus
For System Center 2012 R2 Configuration Manager and later:
The task sequence sets the _TSAppInstallStatus variable with the installation status for the application during the Install Application task sequence step. The task sequence sets the variable with one of the following values:
  1. Undefined: Set when the Install Application task sequence step has not been run.
  2. Error: Set when at least one application failed because of an error during the Install Application task sequence step.
  3. Warning: Set when no errors occur during the Install Application task sequence step, but one or more applications, or a required dependency, did not install because a requirement was not met.
  4. Success: Set when there are no errors or warning detected during the Install Application task sequence step.
_SMSTSBootImageID
Stores the Configuration Manager boot image package ID if a boot image package is associated with the current running task sequence. The variable will not be set if no Configuration Manager boot image package is associated.
Example:
ABC00001
_SMSTSBootUEFI
For System Center 2012 Configuration Manager SP1 and later:
The task sequence sets the SMSTSBootUEFI variable when it detects a computer that is in UEFI mode.
_SMSTSClientGUID
Stores the value of Configuration Manager client GUID. This variable is not set if the task sequence is running from stand-alone media.
Example:
0a1a9a4b-fc56-44f6-b7cd-c3f8ee37c04c
_SMSTSCurrentActionName
Specifies the name of the currently running task sequence step. This variable is set before the task sequence manager runs each individual step.
Example:
run command line
_SMSTSDownloadOnDemand
Set to true if the current task sequence is running in download-on-demand mode, which means the task sequence manager downloads content locally only when it must access the content.
_SMSTSInWinPE
This variable is set to true when the current task sequence step is running in the Windows PE environment, and it is set to false if not. You can test this task sequence variable to determine the current operating system environment.
_SMSTSLastActionRetCode
Stores the return code that was returned by the last action that was run. This variable can be used as a condition to determine if the next step is run.
Example:
0
_SMSTSLastActionSucceeded
The variable is set to true if the last action succeeded and to false if the last action failed. If the last action was skipped because the step was disabled or the associated condition evaluated to false, this variable is not reset, which means it still holds the value for the previous action.
_SMSTSLaunchMode
Specifies the task sequence launch method. The task sequence can have the following values:
  • SMS - specifies that the task sequence is started by using the Configuration Manager client.
  • UFD - specifies that the task sequence is started by using USB media and that the USB media was created in Windows XP/2003.
  • UFD+FORMAT - specifies that the task sequence is started by using USB media and that the USB media was created in Windows Vista or later.
  • CD - specifies that the task sequence is started by using a CD.
  • DVD - specifies that the task sequence is started by using a DVD.
  • PXE - specifies that the task sequence is started from PXE.
  • HD – specifies that the task sequence was started from a hard disk (prestaged media only).
_SMSTSLogPath
Stores the full path of the log directory. This can be used to determine where actions are logged. This value is not set when a hard drive is not available.
_SMSTSMachineName
Stores and specifies the computer name. Stores the name of the computer that the task sequence will use to log all status messages. To change the computer name in the new operating system, use theOSDComputerName variable.
Example:
ABC
_SMSTSMDataPath
Specifies the path defined by the SMSTSLocalDataDrive variable. When you define SMSTSLocalDataDrive before the task sequence starts, such as by setting a collection variable, Configuration Manager then defines the _SMSTSMDataPath variable once the Task Sequence starts.
_SMSTSMediaType
Specifies the type of media that is used to initiate the installation. Examples of types of media are Boot Media, Full Media, PXE, and Prestaged Media.
_SMSTSMP
Stores the name or IP address of a Configuration Manager management point.
_SMSTSMPPort
Stores the management point port number of a Configuration Manager management point.
Example:
80
_SMSTSOrgName
Stores the branding title name that is displayed in a task sequence progress user interface dialog box.
Example:
XYZ Organization
_SMSTSPackageID
Stores the current running task sequence ID. This ID uses the same format as a Configuration Manager software package ID.
Example:
HJT00001
_SMSTSPackageName
Stores the current running task sequence name specified by the Configuration Manager administrator when the task sequence is created.
Example:
Deploy Windows 7 task sequence
_SMSTSRunFromDP
Set to true if the current task sequence is running in run-from-distribution-point mode, which means the task sequence manager obtains required package shares from distribution point.
_SMSTSSiteCode
Stores the site code of the Configuration Manager site.
Example:
ABC
_SMSTSType
Specifies the type of the current running task sequence. It can have the following values:
1 - indicates a generic task sequence.
2 - indicates an operating system deployment task sequence.
_SMSTSTimezone
The _SMSTSTimezone variable stores the time zone information in the following format (without spaces):
Bias, StandardBias, DaylightBias, StandardDate.wYear, wMonth, wDayOfWeek, wDay, wHour, wMinute, wSecond, wMilliseconds, DaylightDate.wYear, wMonth, wDayOfWeek, wDay, wHour, wMinute, wSecond, wMilliseconds, StandardName, DaylightName
Example:
For the Eastern Time U.S. and Canada, the value would be300,0,-60,0,11,0,1,2,0,0,0,0,3,0,2,2,0,0,0,Eastern Standard Time,Eastern Daylight Time
_SMSTSUseCRL
Specifies whether the task sequence uses the certificate revocation list when it uses a Secure Socket Layer (SSL) certificate to communicate with the management point.
_SMSTSUserStarted
Specifies whether a task sequence is started by a user. This variable is set only if the task sequence is started from the Software Center. For example, if _SMSTSLaunchMode is set to SMS. The variable can have the following values:
  • true - specifies that the task sequence is manually started by a user from the Software Center.
  • false - specifies that the task sequence is initiated automatically by the Configuration Manager scheduler.
_SMSTSUseSSL
Specifies whether the task sequence uses SSL to communicate with the Configuration Manager management point. If your site is running in native mode, the value is set to true.
_SMSTSWTG
For System Center 2012 Configuration Manager SP1 and later:
Specifies if the computer is running as a Windows To Go device.
SMSTSAssignmentsDownloadInterval
For System Center 2012 Configuration Manager SP1 and later:
Use this variable to specify the number of seconds to wait before the client will attempt to download the policy since the last attempt (which returned no policies). By default, the client will wait 0 seconds before retrying.
You can set this variable by using a prestart command from media or PXE.
SMSTSAssignmentsDownloadRetry
For System Center 2012 Configuration Manager SP1 and later:
Use this variable to specify the number of times a client will attempt to download the policy after no policies are found on the first attempt. By default, the client will retry 0 times.
You can set this variable by using a prestart command from media or PXE.
SMSTSAssignUsersMode
Specifies how a task sequence associates users with the destination computer. Set the variable to one of the following values.
  • Auto: The task sequence creates a relationship between the specified users and destination computer when it deploys the operating system to the destination computer.
  • Pending: The task sequence creates a relationship between the specified users and the destination computer, but waits for approval from the administrative user before the relationship is set.
  • Disabled: The task sequence does not associate users with the destination computer when it deploys the operating system.
SMSTSDownloadProgram
For System Center 2012 Configuration Manager SP1 and later:
Use this variable to specify an Alternate Content Provider, a downloader program that is used to download content instead of the default Configuration Manager downloader, for the task sequence. As part of the content download process, the task sequence checks the variable for a specified downloader program. If specified, the task sequence runs the program to perform the download.
SMSTSDownloadRetryCount
For System Center 2012 R2 Configuration Manager and later:
Use this variable to specify the number of times that Configuration Manager attempts to download content from a distribution point. By default, the client will retry 2 times.
SMSTSDownloadRetryDelay
For System Center 2012 R2 Configuration Manager and later:
Use this variable to specify the number of seconds that Configuration Manager waits before it retries to download content from a distribution point. By default, the client will wait 15 seconds before retrying.
SMSTSErrorDialogTimeout
When an error occurs in a task sequence, a dialog box is displayed that is automatically dismissed after a number of seconds specified by this variable. By default, the dialog box is automatically dismissed after900 seconds (15 minutes)..
TSErrorOnWarning
For System Center 2012 R2 Configuration Manager and later:
Use this variable to specify whether the task sequence engine considers a detected warning as an error during the Application Installation task sequence step. The task sequence sets the _TSAppInstallStatus variable to Warning when one or more applications, or a required dependency, did not install because a requirement was not met. When you set the TSErrorOnWarning variable to True and the _TSAppInstallStatus variable is set to Warning, it is treated as an error. A value of False is the default behavior.
SMSTSLanguageFolder
For System Center 2012 Configuration Manager SP1 and later:
Use this variable to change the display language of a language neutral boot image.
SMSTSLocalDataDrive
Specifies where temporary files are stored on the destination computer while the task sequence is running.
This variable must be set before the task sequence starts, such as by setting a collection variable. Once the task sequence starts, Configuration Manager defines the _SMSTSMDataPath variable once the Task Sequence starts.
SMSTSMPListRequestTimeout
For System Center 2012 R2 Configuration Manager and later:
Use this variable to specify how many milliseconds a task sequence waits before it retries to install an application after it fails to retrieve the management point list from location services. By default, the task sequence waits 60,000 milliseconds (60 seconds) before it retries the step, and retries up to three times. This variable is applicable only to the Install Application task sequence step.
SMSTSPersistContent
For System Center 2012 Configuration Manager SP1 and later:
Use this variable to temporarily persist content in the task sequence cache.
SMSTSPostAction
For System Center 2012 Configuration Manager SP1 and later:
Specifies a command that is run after the task sequence completes. For example, you can use this variable to specify a script that enables write filters on embedded devices after the task sequence deploys an operating system to the device.
SMSTSPreferredAdvertID
Forces a specific targeted deployment on the destination computer to be run. This can be set through a prestart command from media or PXE. If this variable is set, the task sequence overrides any required deployments.
OSDPreserveDriveLetter
For System Center 2012 Configuration Manager SP1 and later:
This variable determines whether or not the task sequence uses the drive letter captured in the operating system image WIM file when applying that image to a destination computer. In Configuration Manager with no service pack, the drive letter captured in the WIM file is used when applying the operating system image WIM file. In Configuration Manager SP1, you can set the value for this variable to False to use the location that you specify for the Destination setting in the Apply Operating System task sequence step. For more information about the Apply Operating System task sequence step, see the Apply Operating System Image section in the Task Sequence Steps in Configuration Manager topic.
SMSTSRebootDelay
Specifies how many seconds to wait before the computer restarts. The task sequence manager will display a notification dialog before reboot if this variable is not set to 0.
Examples:
0
30
SMSTSRebootMessage
Specifies the message to display in the shutdown dialog box when a restart is requested. If this variable is not set, a default message will appear.
Example:
This computer is being restarted by the task sequence manager.
SMSTSRebootRequested
Indicates that a restart is requested after the current task sequence step is completed. If a restart is required, just set this variable to true, and the task sequence manager will restart the computer after this task sequence step. The task sequence step must set this task sequence variable if it requires the restart to complete the task sequence step. After the computer is restarted, the task sequence will continue to run from the next task sequence step.
SMSTSRetryRequested
Requests a retry after the current task sequence step is completed. If this task sequence variable is set, theSMSTSRebootRequested must also be set to true. After the computer is restarted, the task sequence manager will rerun the same task sequence step.
SMSTSUDAUsers
Specifies the primary user of the destination computer. Specify the users by using the following format. Separate multiple users by using a comma (,).
Example:
domain\user1, domain\user2, domain\user3
For more information about associating users with the destination computer, see How to Associate Users with a Destination Computer.

Wednesday, May 6, 2015

VBScript to check wireless or wired connection

I needed to know if my computers were connected to the internet via a wired connection or wireless but for my use case I needed to exclude all other information.

The scripts that I was able to find that dealt with similar items did not actually return which connection was in use.  The closest I found was one that would disable the wireless adapter if the wired adapter was in use.  Even that one, however, was overly complicated in that it ran two loops through WMI rather than just one.  So, I used the WMI classes from it but developed my own script to do this more elegantly.

Here's what I came up with:

'==================================================================

' NAME:  Check Connection Type

' AUTHOR: Mark Randol
' DATE  : 4/29/2015

' COMMENT: this script will return
'          1 if the both are in use (shouldn't happen, but can)
'          2 if wired LAN adapter is in use
'          3 if wireless LAN adapter is in use
'          4 if none of the LAN adapters are in use.
'==================================================================

On Error Resume Next

Dim strComputer
Dim objWMIService
Dim colWiFi
Dim colLAN
Dim objWifi
Dim objLAN
Dim state
Dim wireStatus
Dim wifiStatus
Dim strOut
Dim intOutput

'===================================================================================
' Initialize Variables
'===================================================================================

intOutput = 4
state = ""
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colLAN = objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionStatus = 2 and PhysicalAdapter = 'True'")

'==================================================================
' Enumerate the wired adapters in WMI.  Add 1 to output if wired adapter is in use.
'==================================================================

Wscript.Echo("Output starting at " & intOutput)

For Each objLAN in colLAN
    strOut = objLAN.NetConnectionID & " " & objLAN.Name & " " & objLAN.PhysicalAdapter
    if instr(lcase(objLAN.Name),"virtual") = 0 and instr(lcase(objLAN.Name),"multiplex") = 0 and  instr(lcase(objLAN.Name),"bridge") = 0 then
       '==================================================================
' Above line (if statement) is there to eliminate other extraneous adapters that
' still show up even though we are eliminating all but "physical" adapters.  Some
' virtual adapters are still there, Microsoft being the biggest offender.
' Add to the line if necessary to remove other non-physical adapters.
'==================================================================

        if instr(lcase(objLAN.NetConnectionID),"wireless") > 0 or instr(lcase(objLAN.NetConnectionID),"wi-fi") > 0 then
            intOutput = intOutput - 2
            Wscript.Echo(strOut & " connected.  Output is now " & intOutput)
        end if
        if instr(lcase(objLAN.NetConnectionID),"wireless") = 0 and instr(lcase(objLAN.NetConnectionID),"wi-fi") = 0 Then
            intOutput = intOutput - 1
            Wscript.Echo(strOut & " connected.  Output is now " & intOutput)
        end if
    end if
next

Wscript.Echo("Final Output = " & intOutput)
Wscript.Echo(intOutput)
WScript.Quit(intOutput)