# Script by Mark Randol
# randoltech.blogspot.com
$registryPath = "HKLM:\Software\MyCompany\SCCM Operating System Deployment"
[String[]]$OSDVariables = "OSArchitecture","OSDAnswerFilePath","OSDComputerName","OSDImagePackageId","OSDImageVersion","OSDTargetSystemDrive","OSDTargetSystemParition","OSDTargetSystemRoot","OSVersionNumber","_OSDOSImagePackageId","_OSDTargetSystemRoot","_SMSTSAdvertID","_SMSTSAssignedSiteCode","_SMSTSBootImageID","_SMSTSBootMediaPackageID","_SMSTSLaunchMode","_SMSTSLogPath","_SMSTSMachineName","_SMSTSMediaType","_SMSTSOrgName","_SMSTSPackageID","_SMSTSPackageName","_SMSTSSiteCode","_SMSTSStandAloneMedia","_SMSTSSupportUnknownMachines","_SMSTSUserStatePath"
if (!(Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null }
$InstallDate = Get-Date
New-ItemProperty -Path $registryPath -Name "OSInstallDateTime" -Value $InstallDate -PropertyType STRING -Force | Out-Null
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
foreach ($OSDVariableName in $OSDVariables)
{
$OSDVariableValue = $tsenv.Value($OSDVariableName)
New-ItemProperty -Path $registryPath -Name $OSDVariableName -Value $OSDVariableValue -PropertyType STRING -Force | Out-Null
}
Wednesday, January 16, 2019
Script to stamp the registry with your OSD variables
Thursday, January 10, 2019
Command lines for creating a bootable USB thumb drive
Command lines for creating a bootable USB thumb drive:
diskpart
list disk
sel dis #
clean
create par pri
sel par 1
format fs=ntfs quick <--- for Legacy
format fs=fat32 quick <--- for UEFI
act
exit
diskpart
list disk
sel dis #
clean
create par pri
sel par 1
format fs=ntfs quick <--- for Legacy
format fs=fat32 quick <--- for UEFI
act
exit
Thursday, October 18, 2018
Step-by-Step how PXE boots a machine using SCCM OSD
I had a problem that was quite difficult to work through and in order to figure it out I had to go really deep on PXE. Figured this step-by-step might help someone else in the future.
Enjoy!
Another good reference on network boot process:
https://blogs.technet.microsoft.com/dominikheinz/2011/03/18/sccm-pxe-network-boot-process
- The network boot client computer sends a broadcast to entire network with option 60 (on any normal network this will only actually broadcast on the local subnet but IP helpers generally get it to the DHCP server).
- Both DHCP and the WDS server get the broadcast (either both are assigned as DHCP servers with IP helpers or DHCP options are set to forward the request to the WDS).
- DHCP offers an IP address to the client (keyword "offers", this hasn't been accepted yet).
- Before the client machine accepts the IP address it waits for a signal from the WDS server WDS. Before sending the signal back to the client the WDS sever runs a stored procedure, LOOKUPDEVICE, against the SCCM database. If the client machine is found in SCCM or if there is an advertisement for "Unknown Machines" collection then WDS signals the client to proceed with the PXE boot.
- The client machine now accepts the IP offered by DHCP.
- DHCP DORA finally completes when the DHCP server acknowledges the client IP assignment. The client machine now has an IP address and is ready to proceed.
- The client machine downloads WDSNBP.COM from PXE server to detect the hardware architecture (x86 or x64)
- The client downloads the PXEBOOT.COM boot files for its architecture from PXE server. The file downloaded at this step is controlled/ monitored by SMSPXE.
- SMSPXE runs a stored procedure called getbootaction and depending on the result, it gives the PXE boot files to client.
- The client machine now downloads the Boot image, bootmgr.exe and BCD store. This is an SMB file transfer, all previous file transfers were TFTP. Boot image downloaded here would be dependent on the result of the architecture detection done earlier by WDSNBP file.
- Once the Boot image and the other two files are downloaded completely BootMGR and BCD store are used to initialize the WINPE environment.
Enjoy!
Another good reference on network boot process:
https://blogs.technet.microsoft.com/dominikheinz/2011/03/18/sccm-pxe-network-boot-process
Friday, August 24, 2018
Powershell Script to prompt for computer name during OSD
function Load-Form {
$Form.Controls.Add($TBComputerName)
$Form.Controls.Add($GBComputerName)
$Form.Controls.Add($ButtonOK)
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()
}
function Set-OSDComputerName {
$ErrorProvider.Clear()
if ($TBComputerName.Text.Length -eq 0) {
$ErrorProvider.SetError($GBComputerName, "Please enter a computer name")
}
else {
if ($TBComputerName.Text.Length -gt 15) {
$ErrorProvider.SetError($GBComputerName, "Computer name cannot be more than 15 characters")
}
else {
$OSDComputerName = $TBComputerName.Text.Replace("[","").Replace("]","").Replace(":","").Replace(";","").Replace("|","").Replace("=","").Replace("+","").Replace("*","").Replace("?","").Replace("<","").Replace(">","").Replace("/","").Replace("\","").Replace(",","")
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$TSEnv.Value("OSDComputerName") = "$($OSDComputerName)"
$Form.Close()
}
}
}
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Global:ErrorProvider = New-Object System.Windows.Forms.ErrorProvider
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(285,140)
$Form.MinimumSize = New-Object System.Drawing.Size(285,140)
$Form.MaximumSize = New-Object System.Drawing.Size(285,140)
$Form.StartPosition = "CenterScreen"
$Form.SizeGripStyle = "Hide"
$Form.Text = "Enter Computer Name"
$Form.ControlBox = $false
$Form.TopMost = $true
$TBComputerName = New-Object System.Windows.Forms.TextBox
$TBComputerName.Location = New-Object System.Drawing.Size(25,30)
$TBComputerName.Size = New-Object System.Drawing.Size(215,50)
$TBComputerName.TabIndex = "1"
$GBComputerName = New-Object System.Windows.Forms.GroupBox
$GBComputerName.Location = New-Object System.Drawing.Size(20,10)
$GBComputerName.Size = New-Object System.Drawing.Size(225,50)
$GBComputerName.Text = "Computer name:"
$ButtonOK = New-Object System.Windows.Forms.Button
$ButtonOK.Location = New-Object System.Drawing.Size(195,70)
$ButtonOK.Size = New-Object System.Drawing.Size(50,20)
$ButtonOK.Text = "OK"
$ButtonOK.TabIndex = "2"
$ButtonOK.Add_Click({Set-OSDComputerName})
Load-Form
Friday, August 17, 2018
WinPE Version List
WinPE Version List (Updated June 16, 2018)
The table below shows the main versions of WinPE that you will see in the wild, along with their WinPE version, the Windows version name, and the numeric Windows version string that it was built from.
| WinPE | Windows | Windows Version | Notes |
| 1.0 | Windows XP | 5.1.2600.x | First version of WinPE. |
| 1.1 | Windows XP SP1 | 5.1.2600.x | |
| 1.2 | Windows Server 2003 | 5.2.3790.x | |
| 1.5 | Windows XP SP2 | 5.1.2600.x | Windows PE 2004. |
| 1.6 | Windows Server 2003 SP1 | 5.2.3790.x | Windows PE 2005. |
| 2.0 | Windows Vista | 6.0.6000.x | |
| 2.1 | Windows Server 2008 | 6.0.6001.x | |
| 2.2 | Windows Server 2008 SP2 | 6.0.6002.x | |
| 3.0 | Windows 7 | 6.1.7600.x | Windows AIK 2.0. |
| 3.1 | Windows 7 SP1 | 6.1.7601.x | Windows AIK Supplement for Windows 7 SP1. |
| 4.0 | Windows 8 | 6.2.9200.x | Windows ADK (Windows Kits 8.0). |
| 5.0 | Windows 8.1 | 6.3.9300.x | Windows ADK (Windows Kits 8.1). |
| 5.1 | Windows 8.1 Update 1 | 6.3.9600.x | Windows ADK (Windows Kits 8.1 Update). |
| 10 (1507) | Windows 10 1507 | 10.0.10240.16384 | Windows ADK (Windows Kits 10.0) 1507 |
| 10 (1511) | Windows 10 1511 | 10.0.10586.0 | Windows ADK (Windows Kits 10.0) 1511 |
| 10 (1607) | Windows 10 1607 | 10.0.14393.0 | Windows ADK (Windows Kits 10.0) 1607 |
| 10 (1703) | Windows 10 1703 | 10.0.15063.0 | Windows ADK (Windows Kits 10.0) 1703 |
| 10 (1709) | Windows 10 1709 | 10.0.16299.15 | Windows ADK (Windows Kits 10.0) 1709 |
| 10 (1803) | Windows 10 1803 | 10.0.17134.1 | Windows ADK (Windows Kits 10.0) 1803 |
List of Built-In Task OSD Sequence Variables
| Built-in Variable Name | Description |
|---|---|
_SMSTSAdvertID
|
Stores the current running task sequence advertisement ID. It uses the same format as a Configuration Manager 2007 software distribution advertisement ID. If the task sequence is running from stand-alone media, this variable is undefined.
Example:
ABC20001
|
_SMSTSBootImageID
|
Stores the Configuration Manager 2007 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 2007 boot image package is associated.
Example:
ABC00001
|
_SMSTSClientGUID
|
Stores the value of Configuration Manager 2007 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 will be 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 returned by the last action that was 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:
|
_SMSTSLogPath
|
Stores the full path of the log directory. This can be used to determine where actions should be logged. This value is not set when no hard drive is 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 the OSDComputerName variable.
Example:
ABC
|
_SMSTSMediaType
|
Specifies the type of media that will be 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 2007 management point.
|
_SMSTSMPPort
|
Stores the management point port number of a Configuration Manager 2007 management point.
Example:
80
|
_SMSTSOrgName
|
Stores the branding title name, which will be 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 2007 software package ID.
Example:
HJT00001
|
_SMSTSPackageName
|
Stores the current running task sequence name specified by the Configuration Manager 2007 administrator when the task sequence is created.
Example:
Deploy xpsp2 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 packages from distribution point shares.
|
_SMSTSSiteCode
|
Stores the site code of the Configuration Manager 2007 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 be 300,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 will only be set if the task sequence is started from the Configuration Manager 2007 client. For example, if _SMSTSLaunchMode is set to SMS. The variable can have the following values:
|
_SMSTSUseSSL
|
Specifies whether the task sequence uses SSL to communicate with the Configuration Manager 2007 management point. If your site is running in native mode, the value is set to true.
|
SMSTSErrorDialogTimeout
|
When an error occurs in a task sequence, a dialog box is displayed that is dismissed automatically after a default time-out value. Use this variable to specify a time-out value in seconds other than the default of 15 minutes.
|
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 reboot is requested. If this variable is not set, a default message will appear.
Example:
This computer is being rebooted by the task sequence manager.
|
SMSTSRebootRequested
|
Indicates that a reboot is requested after the current task sequence step is completed. If a reboot 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 a reboot to complete the task sequence step. After the computer is rebooted, the task sequence will continue to run from the next task sequence step.
|
SMSTSLocalDataDrive
|
Specifies where temporary files are stored on the destination computer while the task sequence is running.
|
SMSTSRetryRequested
|
Requests a retry after the current task sequence step is completed. If this task sequence variable is set, the SMSTSRebootRequested must also be set to true. After the computer is restarted, the task sequence manager will rerun the same task sequence step.
|
Creating Your Own Task Sequence Variables
Operating System Deployment Task Sequence Variables
Tuesday, August 14, 2018
Powershell script to determine OS architecture (32bit or 64bit)
This will return either "32" or "64" depending on the OS architecture.
Write-Host (Get-WmiObject -Class Win32_Processor | Select-Object AddressWidth).AddressWidthNOTE: this is OS architecture, not CPU architecture. That is not relevant on 64bit machines, but if you have 32bit Windows running on a 64bit CPU it will return 32.
Labels:
32bit,
64bit,
Architecture,
OS,
PowerShell,
WMI,
x64,
x86
Subscribe to:
Posts (Atom)