Post by happysccm on May 15, 2020 5:45:44 GMT
I'm able to replace 90% of my MDT Wizard preflight - Can't set a warning for existing AD computer name, and nested group membership check (These are on Jason's roadmap and not big deals).
Thanks to CC for the nice example. I took it and customized it for my workplace. Still tweaking it bit by bit
My Task sequence starts by setting variable IsVirtualMachine to 'True' with a wmi query
Then a powershell script puts the AssetTag output to the variable SystemAssetTag
Then a powershell script validates the AssetTag against a naming standard, output to AssetTagValid
Physical: MUXXXXXXXX
VM: MUXXXXXXXX-SOE
If AssetTagValid = True
OSDComputerName is set to SystemAssetTag
Then the first UI++ is loaded. This copy is stored on the boot media so it can run before formatting the disk
UI++64.exe /disabletsvareditor /config:"CheckGroupMembership.xml"
Then, I re-use format disk steps from MDT task sequence.
Then the main UI++ runs from a package.
This will prompt for a computer name if the AssetTag isn't valid. Enforcing the naming standard for physical machines.
Then set the computer name to uppercase
Then run preflight steps with the option to re-try
Thanks to CC for the nice example. I took it and customized it for my workplace. Still tweaking it bit by bit
My Task sequence starts by setting variable IsVirtualMachine to 'True' with a wmi query
SELECT * FROM Win32_ComputerSystem WHERE Model = 'Virtual Machine'
Then a powershell script puts the AssetTag output to the variable SystemAssetTag
(Get-CimInstance Win32_SystemEnclosure).SMBIOSAssetTag
Then a powershell script validates the AssetTag against a naming standard, output to AssetTagValid
Physical: MUXXXXXXXX
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$assetTagRegex = '^(mu|MU|Mu|mU)[0-9]{8}'
$assetTag = $tsenv.Value('SystemAssetTag')
$assetTag -match $assetTagRegex
VM: MUXXXXXXXX-SOE
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$assetTagRegex = '^(mu|MU|Mu|mU)[0-9]{8}(-)(SOE|soe|Soe)'
$assetTag = $tsenv.Value('SystemAssetTag')
$assetTag -match $assetTagRegex
If AssetTagValid = True
OSDComputerName is set to SystemAssetTag
Then the first UI++ is loaded. This copy is stored on the boot media so it can run before formatting the disk
UI++64.exe /disabletsvareditor /config:"CheckGroupMembership.xml"
<UIpp Title="SOE - Authenticate" Color="#3366ff">
<Actions>
<!-- User Auth to run the TS. Skip if location is off site imaging facility -->
<Action Type="UserAuth" Title="User Authentication" Domain="ad.happysccm.com" Group="All-Admin-Accounts" GetGroups="True" ShowBack="True">
<Field Name="Domain" ReadOnly="True" />
</Action>
</Actions>
</UIpp>
Then, I re-use format disk steps from MDT task sequence.
Then the main UI++ runs from a package.
This will prompt for a computer name if the AssetTag isn't valid. Enforcing the naming standard for physical machines.
Then set the computer name to uppercase
Then run preflight steps with the option to re-try
- On Lan
- Plugged in
- Supported Model or VM - A script runs before and sets the variable ModelSupported to True if it's in our supported models list
- UEFI Bios Mode or VM
- TPM On or VM
<UIpp Title="Windows 10 - GUC" Color="#3366ff">
<Actions>
<!-- Set dummy values so logic below works -->
<Action Type="TSVar" Name="XTPMAvailable">""</Action>
<Action Type="TSVar" Name="XTPMActivated">""</Action>
<Action Type="DefaultValues" ValueTypes="TPM" ShowProgress="True">
</Action>
<!-- This step is for virtual machines -->
<Action Type="Input" Name="OSDComputerNameVM" Title="System Name" ShowBack="True" Condition='"%AssetTagValid%" <> "True" And "%IsVirtualMachine%" = "True"'>
<TextInput Prompt="Computer Name" Hint="Enter the name for this system" Variable="OSDComputerName" Question="Please enter a computer name" Default="%_SMSTSMachineName%" />
</Action>
<!-- bare metal machines -->
<Action Type="Input" Name="OSDComputerName" Title="System Name" Condition='"%AssetTagValid%" <> "True" And "%IsVirtualMachine%" <> "True"'>
<TextInput Prompt="System Asset Tag" Question="Enter the MU number of this system" RegEx="^(mu|MU|Mu|mU)[0-9]{8}" Variable="OSDComputerName" Default="%_SMSTSMachineName%" />
</Action>
<!-- Convert OSDComputerName to uppercase -->
<Action Type="TSVar" Name="OSDComputerName">UCase("%OSDComputerName%")</Action>
<!-- Supported Model Check -->
<Action Type="ExternalCall" Title="External Command">cscript.exe //NOLOGO //B WIN10OSDCheckHWModel.vbs</Action>
<ActionGroup Name="Preflight">
<Action Type="DefaultValues" ValueTypes="Asset,Network" ShowProgress="True" />
<Action Type="Preflight" Title="Preflight checks" ShowBack="True">
<Check Text="WLAN disconnected" CheckCondition='"%XWLANDisconnected%" = "True"' ErrorDescription="Only systems physically connected to the LAN can be upgraded to Windows 10." />
<Check Text="Not on battery" CheckCondition='"%XOnBattery%" = "False"' ErrorDescription="Only systems connected to AC power can be upgraded to Windows 10." />
<Check Text="Check hardware model" CheckCondition='"%ModelSupported%" = "True" OR "%IsVirtualMachine%" = "True"' ErrorDescription="This Model is not currently supported to run the Windows 10 SOE." />
<Check Text="Check bios mode" CheckCondition='("%XSystemUEFI%" = "True" AND %XSystemUEFI% = "True") OR "%IsVirtualMachine%" = "True"' ErrorDescription="Please update the BIOS firmware, ensure the boot mode is set to UEFI and Secure boot is enabled." />
<Check Text="TPM is available and activated" CheckCondition='("%XTPMAvailable%" = "True" AND %XTPMActivated% = "True") OR "%IsVirtualMachine%" = "True"' ErrorDescription="Enable and Activate TPM in the BIOS"/>
</Action>
</ActionGroup>
</Actions>
</UIpp>