maurice-daly / DriverAutomationTool

Home of the Driver Automation Tool
https://www.msendpointmgr.com
BSD 2-Clause "Simplified" License
395 stars 120 forks source link

Recommendation: v4.2 TargetOsName and TargetOsVersion blank #329

Open RoYoMi opened 2 years ago

RoYoMi commented 2 years ago

Problem

We upgraded from v4.1.3 to v4.2. On first implementation of v4.2 we found the script was failing with blank or null TargetOsName and TargetOsVersion errors. Obviously this is our problem because the those fields are listed as mandatory in the script, and this upgrade is not a drop-in-replacement.

Solution

Because the script is running on the target device which has access to that information, instead of populating those parameters directly in the task sequence, we thought it would be better to make the script smart enough to answer those parameters directly.

To do this we set both parameters to not mandatory, and updated lines 268 and 277 as follows:

Was: Line 268: [string]$TargetOSName, Line 278: [string]$TargetOSVersion,

Is now: Line 268: [string]$TargetOSName = $("Windows $(([version](Get-CimInstance Win32_Operatingsystem).version).Major)"), Line 278: [string]$TargetOSVersion = $( $Temp = get-itemproperty -path "hklm:\software\microsoft\windows nt\currentversion" if ( $Temp.DisplayVersion -imatch "...." ) { $Temp.DisplayVersion } else { $Temp.ReleaseID } ),

This makes the script default to the exact values the device is running while at the same time allowing the TS to dictate values.

If you're using this script is a OSD with the -baremetal option, then you may need to include the options in the Task Sequence. This is because the OSD may not have access to the actual OS drive and therefore may not yet be able to issue a query against it.

chaosisbliss commented 2 years ago

@RoYoMi strikes again. I was just reading your other edits on another post for error logging. I see these have not been reflected in the available script. Do you care to share your script with the error logging and targetOS changes?

RoYoMi commented 2 years ago

LOL sure I just need to know where to send it

chaosisbliss commented 2 years ago

You can send it to nandtinc@gmail.com. It's a dummy email account.

RoYoMi commented 2 years ago

Sent, enjoy :)

shaikh441 commented 2 years ago

Hi, We are looking to achieve something like the above in our environment, as we are running multiple OS versions and need the script in the task sequence to be able to detect the OS version of the machine being imaged, and pick the matching package, without having to have separate task sequences/steps for each OS version we release.

@RoYoMi Would you be able to share where I set the 2 parameters (TargetOSName & TargetOSVersion) to not mandatory please?