Advanced Task Sequence - nonoloki2/Devops GitHub Wiki
Step 1 run Powershell Script
Name: === SECTION - TS_START #--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Convert all of the variables currently in the environment to PowerShell variables $tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }
#--- Cleanup Action Name $LogTSSection = $_SMSTSCurrentActionName.Replace("=== SECTION - ","")
#--- Save Section name $tsenv.Value("LogTSSection") = $LogTSSection
Policy Bypass
Step 2 run Powershell Script
#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Set TS Logging Variables $LogStartTime = Get-Date -UFormat %Y-%m-%d__%H-%M-%S
#--- Save TS Logging Variables $tsenv.Value("LogStartTime") = $LogStartTime
Policy Bypass
Step 3 run Command Line
Name: Throw an error if not in WinPE
Command Line: ========= ERROR not in WinPE ==========
Condition: _SMSTSInWinPE not equals true
Step 4 Task Sequence Variable
Name: Set OSDLogPowerShellParameters to True
Variable: OSDLogPowerShellParameters Value: TRUE
New Group (TS GUI)
Step 5 run Command Line
Name: CMD - Download TS GUI Package Command Line: cscript.exe copyfiles.vbs X:\windows\TEMP\SMSTSDownload.INI GDC0066E x:\GDC0066E
Step 6 run Command Line
Name: CMD - Run TS Gui from package Command Line: x:\GDC0066E\TsGui.exe
New Group (Initiate Logs)
Step 7 run Powershell Script
Name: === SECTION - INIT_LOGS
Script
#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Convert all of the variables currently in the environment to PowerShell variables $tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }
#--- Cleanup Action Name $LogTSSection = $_SMSTSCurrentActionName.Replace("=== SECTION - ","")
#--- Save Section name $tsenv.Value("LogTSSection") = $LogTSSection
Policy Bypass
Step 8 run Powershell Script
Name: PS - Static Log Variables
Script
#=======
Create an object to access the task sequence environment
$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
Or, convert all of the variables currently in the environment to PowerShell variables
$tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }
#--- Get TS Logging Variables $OSDComputerName = $tsenv.Value("OSDComputerName") $LogStartTime = $tsenv.Value("LogStartTime")
#--- Set TS Logging Variables $LogServer = "GDC1PSCMSQL001" $LogShare = "\$LogServer\OSDLogs" $LogFolder = "$OSDComputerName" + "__" + "$LogStartTime" + "_PROD"
#--- Set Logging Locations $LogSaveLocation = $LogShare + "" + $LogFolder
#--- Save TS Logging Variables $tsenv.Value("LogServer") = $LogServer $tsenv.Value("LogShare") = $LogShare $tsenv.Value("LogFolder") = $LogFolder $tsenv.Value("LogSaveLocation") = $LogSaveLocation
"----" "OSDComputerName $OSDComputerName" "LogStartTime $LogStartTime" "LogServer $LogServer" "LogShare $LogShare" "LogFolder $LogFolder" "LogSaveLocation $LogSaveLocation" "----" Policy bypass
Step 9 Connect to Network Folder
Name: Drive: L to ODSLogs path: %LogShare% account: set domain account
Step 10 run Powershell Script
Name: PS - Create Log Folder
Script
#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Get TS Logging Variables $LogFolder = $tsenv.Value("LogFolder") $LogShare = $tsenv.Value("LogShare")
#--- Create Log Folders New-Item -Path "L:" -Name "$LogFolder" -ItemType "directory"
Policy Bypass
Step 11 run Powershell Script
Name: LOGS - PS - Initialization complete
Script
#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Convert all of the variables currently in the environment to PowerShell variables $tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }
#--- Cleanup Action Name $CleanActionName = $_SMSTSCurrentActionName.Replace("LOGS - PS - ","")
#--- Write status message to Progress log file Write-Output "<![LOG[$CleanActionName]LOG]!><time=""$(Get-Date -UFormat '%T').000+000"" date=""$(Get-Date -UFormat '%m-%d-%Y')"" component=""$HostName"" context="""" type=""1"" thread=""N/A"" file=""Progress"">" | Out-File -FilePath "$LogSaveLocation\Progress.log" -Encoding "Default" -Append
#--- Copy SMSTS log Copy-Item "$SMSTSLogPath\smsts.log" "$LogSaveLocation\smsts_$(Get-Date -UFormat %Y-%m-%d__%H-%M-%S).log"
Policy Bypass
New Group (Install Operation system)
Step 12 run Powershell Script
Name: === SECTION - OS_INSTALL
Script
#--- Create an object to access the task sequence environment $tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
#--- Convert all of the variables currently in the environment to PowerShell variables $tsenv.GetVariables() | % { Set-Variable -Name "$" -Value "$($tsenv.Value($))" }
#--- Cleanup Action Name $LogTSSection = $_SMSTSCurrentActionName.Replace("=== SECTION - ","")
#--- Save Section name $tsenv.Value("LogTSSection") = $LogTSSection
Policy Bypass