{"id":119,"date":"2017-04-27T14:04:47","date_gmt":"2017-04-27T12:04:47","guid":{"rendered":"http:\/\/blog.van-daag.nl\/?p=119"},"modified":"2017-07-25T18:15:00","modified_gmt":"2017-07-25T18:15:00","slug":"osd-bios-upgrade-during-os-deployment-in-mdtconfigmgr-by-mikael-nystrom","status":"publish","type":"post","link":"https:\/\/van-daag.nl\/?p=119","title":{"rendered":"OSD \u2013 BIOS upgrade during OS Deployment in MDT\/ConfigMgr by Mikael Nystrom"},"content":{"rendered":"<p>Source: <a href=\"https:\/\/deploymentbunny.com\/2016\/07\/20\/osd-bios-upgrade-during-os-deployment-in-mdtconfigmgr-v3\/\">deploymentbunny.com<\/a><\/p>\n<p>Changed the script for my enviroment<\/p>\n<pre class=\"lang:ps decode:true \" title=\"Install Bios Update.ps1\">Function Import-SMSTSENV{\r\n    try\r\n    {\r\n        $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment\r\n        Write-Output \"$ScriptName - tsenv is $tsenv \"\r\n        $MDTIntegration = \"YES\"\r\n         \r\n        #$tsenv.GetVariables() | % { Write-Output \"$ScriptName - $_ = $($tsenv.Value($_))\" }\r\n    }\r\n    catch\r\n    {\r\n        Write-Output \"$ScriptName - Unable to load Microsoft.SMS.TSEnvironment\"\r\n        Write-Output \"$ScriptName - Running in standalonemode\"\r\n        $MDTIntegration = \"NO\"\r\n    }\r\n    Finally\r\n    {\r\n    if ($MDTIntegration -eq \"YES\"){\r\n        $Logpath = $tsenv.Value(\"LogPath\")\r\n        $LogFile = $Logpath + \"\\\" + \"$ScriptName.log\"\r\n \r\n    }\r\n    Else{\r\n        $Logpath = $env:TEMP\r\n        $LogFile = $Logpath + \"\\\" + \"$ScriptName.log\"\r\n    }\r\n    }\r\n}\r\nFunction Start-Logging{\r\n    start-transcript -path $LogFile -Force\r\n}\r\nFunction Stop-Logging{\r\n    Stop-Transcript\r\n}\r\nFunction Invoke-Exe{\r\n    [CmdletBinding(SupportsShouldProcess=$true)]\r\n  \r\n    param(\r\n        [parameter(mandatory=$true,position=0)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [string]\r\n        $Executable,\r\n  \r\n        [parameter(mandatory=$false,position=1)]\r\n        [string]\r\n        $Arguments\r\n    )\r\n  \r\n    if($Arguments -eq \"\")\r\n    {\r\n        Write-Verbose \"Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru\"\r\n        $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru\r\n    }else{\r\n        Write-Verbose \"Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru\"\r\n        $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru\r\n    }\r\n    Write-Verbose \"Returncode is $($ReturnFromEXE.ExitCode)\"\r\n    Return $ReturnFromEXE.ExitCode\r\n}\r\n \r\n# Set vars\r\n$SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path\r\n$SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path\r\n$SOURCEROOT = \"$SCRIPTDIR\\Source\"\r\n$SettingsFile = $SCRIPTDIR + \"\\\" + $SettingsName\r\n$LANG = (Get-Culture).Name\r\n$OSV = $Null\r\n$ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE\r\n \r\n#Try to Import SMSTSEnv\r\n. Import-SMSTSENV\r\n \r\n# Set more vars\r\n$computerSystem = Get-CimInstance CIM_ComputerSystem\r\n$Make = $tsenv.Value(\"Make\")\r\n$Model = $computerSystem.Model\r\n$ModelAlias = $tsenv.Value(\"ModelAlias\")\r\n$MakeAlias = $tsenv.Value(\"MakeAlias\")\r\n \r\n#Start Transcript Logging\r\n. Start-Logging\r\n \r\n#Output base info\r\nWrite-Output \"\"\r\nWrite-Output \"$ScriptName - ScriptDir: $ScriptDir\"\r\nWrite-Output \"$ScriptName - SourceRoot: $SOURCEROOT\"\r\nWrite-Output \"$ScriptName - ScriptName: $ScriptName\"\r\nWrite-Output \"$ScriptName - Current Culture: $LANG\"\r\nWrite-Output \"$ScriptName - Integration with MDT(LTI\/ZTI): $MDTIntegration\"\r\nWrite-Output \"$ScriptName - Log: $LogFile\"\r\nWrite-Output \"$ScriptName - Model (win32_computersystem): $((Get-WmiObject Win32_ComputerSystem).model)\"\r\nWrite-Output \"$ScriptName - Name (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Name)\"\r\nWrite-Output \"$ScriptName - Version (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Version)\"\r\nWrite-Output \"$ScriptName - Model (from TSENV): $Model\"\r\nWrite-Output \"$ScriptName - ModelAlias (from TSENV): $ModelAlias\"\r\n \r\n#Check Model\r\nif($((Get-WmiObject Win32_ComputerSystem).model) -eq 'HP EliteBook 8560w'){\r\n    Write-Output \"Model is $((Get-WmiObject Win32_ComputerSystem).model)\"\r\n    Write-Output \"Checking BIOS Version\"\r\n    Write-Output \"Version is $((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion)\"\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '68SVD Ver. F.50'){\r\n        Write-Output \"Needs upgrade\"\r\n        $Exe = 'hpqflash.exe'\r\n        $Location = \"$SCRIPTDIR\\Source\\HP EliteBook 8560w\"\r\n        $Executable = $Location + \"\\\" + $exe\r\n        Set-Location -Path $Location\r\n        Invoke-Exe -Executable \"$Executable\" -Arguments \"\/s \/p LCadmin1.bin\" -Verbose\r\n    }\r\n    else\r\n    {\r\n        Write-Output \"No Need to upgrade\"\r\n    }\r\n}\r\nif($((Get-WmiObject Win32_ComputerSystem).model) -eq 'HP ProBook 6570b'){\r\n    Write-Output \"Model is $((Get-WmiObject Win32_ComputerSystem).model)\"\r\n    Write-Output \"Checking BIOS Version\"\r\n    Write-Output \"Version is $((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion)\"\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -Like '*ICE*'){\r\n        if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '68ICE Ver. F.62'){\r\n            Write-Output \"Needs upgrade\"\r\n            $Exe = 'hpqflash.exe'\r\n            $Location = \"$SCRIPTDIR\\Source\\HP ProBook 6570b\"\r\n            $Executable = $Location + \"\\\" + $exe\r\n            Set-Location -Path $Location\r\n            Invoke-Exe -Executable \"$Executable\" -Arguments \"\/s \/f 68ICE.cab\" -Verbose\r\n        }\r\n        else\r\n        {\r\n            Write-Output \"No Need to upgrade\"\r\n        }\r\n    }\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -Like '*ICF*'){\r\n        if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '68ICF Ver. F.62'){\r\n            Write-Output \"Needs upgrade\"\r\n            $Exe = 'hpqflash.exe'\r\n            $Location = \"$SCRIPTDIR\\Source\\HP ProBook 6570b\"\r\n            $Executable = $Location + \"\\\" + $exe\r\n            Set-Location -Path $Location\r\n            Invoke-Exe -Executable \"$Executable\" -Arguments \"\/s \/f 68ICF.cab\" -Verbose\r\n        }\r\n        else\r\n        {\r\n            Write-Output \"No Need to upgrade\"\r\n        }\r\n    }\r\n    }\r\n   \r\n   if($((Get-WmiObject Win32_ComputerSystem).model) -eq 'Latitude 7480'){\r\n    Write-Output \"Model is $((Get-WmiObject Win32_ComputerSystem).model)\"\r\n    Write-Output \"Checking BIOS Version\"\r\n    Write-Output \"Version is $((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion)\"\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '1.2.9'){\r\n        Write-Output \"Needs upgrade\"\r\n        $Exe = 'Latitude_7x80_1.2.9.exe'\r\n        $Location = \"$SCRIPTDIR\\Source\\Latitude 7480\"\r\n        $Executable = $Location + \"\\\" + $exe\r\n        Set-Location -Path $Location\r\n        Invoke-Exe -Executable \"$Executable\" -Arguments \"\/s \/p=Password\" -Verbose\r\n    }\r\n    else\r\n    {\r\n        Write-Output \"No Need to upgrade\"\r\n    }\r\n}\r\n\r\n   if($((Get-WmiObject Win32_ComputerSystem).model) -eq 'Latitude E7470'){\r\n    Write-Output \"Model is $((Get-WmiObject Win32_ComputerSystem).model)\"\r\n    Write-Output \"Checking BIOS Version\"\r\n    Write-Output \"Version is $((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion)\"\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '1.12.3'){\r\n        Write-Output \"Needs upgrade\"\r\n        $Exe = 'Latitude_E7x70_1.12.3.exe'\r\n        $Location = \"$SCRIPTDIR\\Source\\Latitude E7470\"\r\n        $Executable = $Location + \"\\\" + $exe\r\n        Set-Location -Path $Location\r\n        Invoke-Exe -Executable \"$Executable\" -Arguments \"\/s \/p=Password\" -Verbose\r\n    }\r\n    else\r\n    {\r\n        Write-Output \"No Need to upgrade\"\r\n    }\r\n}\r\n\r\n\r\nif($((Get-WmiObject Win32_ComputerSystem).model) -eq 'HP Compaq dc7900 Small Form Factor'){\r\n    Write-Output \"Model is $((Get-WmiObject Win32_ComputerSystem).model)\"\r\n    Write-Output \"Checking BIOS Version\"\r\n    Write-Output \"Version is $((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion)\"\r\n    if($((Get-WmiObject Win32_Bios).SMBIOSBIOSVersion) -ne '786G1 v01.27'){\r\n        Write-Output \"Needs upgrade\"\r\n        $Exe = 'hpqflash.exe'\r\n        $Location = \"$SCRIPTDIR\\Source\\HP Compaq dc7900 Small Form Factor\\HPQFlash\"\r\n        $Executable = $Location + \"\\\" + $exe\r\n        $SourceFile = $Location + \"\\\" + \"Password01.bin\"\r\n        $Destination = $env:TEMP\r\n        $DestinationFile = $Destination + \"\\\" + \"Password01.bin\"\r\n        Copy-Item -Path $SourceFile -Destination $DestinationFile -Force -Verbose \r\n        Set-Location -Path $Location\r\n        Invoke-Exe -Executable $Executable -Arguments \"\/s \/p $DestinationFile\"\r\n    }\r\n    else\r\n    {\r\n        Write-Output \"No Need to upgrade\"\r\n    }\r\n}\r\n \r\n#Stop Logging\r\n. Stop-Logging<\/pre>\n<p>This is how it is in MDT.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-130 size-full\" src=\"https:\/\/i0.wp.com\/blog.van-daag.nl\/wp-content\/uploads\/2017\/04\/image001-1.png?resize=640%2C567\" alt=\"\" width=\"640\" height=\"567\" srcset=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2017\/04\/image001-1.png?w=740&amp;ssl=1 740w, https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2017\/04\/image001-1.png?resize=300%2C266&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>This is the folder structure<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-131 size-full\" src=\"https:\/\/i0.wp.com\/blog.van-daag.nl\/wp-content\/uploads\/2017\/04\/image002-1.png?resize=640%2C410\" alt=\"\" width=\"640\" height=\"410\" srcset=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2017\/04\/image002-1.png?w=1016&amp;ssl=1 1016w, https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2017\/04\/image002-1.png?resize=300%2C192&amp;ssl=1 300w, https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2017\/04\/image002-1.png?resize=768%2C492&amp;ssl=1 768w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: deploymentbunny.com Changed the script for my enviroment Function Import-SMSTSENV{ try { $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment Write-Output &#8220;$ScriptName &#8211; tsenv is $tsenv &#8221; $MDTIntegration = &#8220;YES&#8221; #$tsenv.GetVariables() | % { Write-Output &#8220;$ScriptName &#8211; $_ = $($tsenv.Value($_))&#8221; } } catch { Write-Output &#8220;$ScriptName &#8211; Unable to load Microsoft.SMS.TSEnvironment&#8221; Write-Output &#8220;$ScriptName &#8211; Running in standalonemode&#8221; $MDTIntegration [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24,11,15,19],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-mdt","category-powershell-script","category-sccm","category-windows-10"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=119"}],"version-history":[{"count":1,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions\/212"}],"wp:attachment":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}