Function Execute-TaskSequence {     Param (         [parameter(Mandatory = $true)]         [string]$Name     )     Try {           $softwareCenter = New-Object -ComObject "UIResource.UIResourceMgr"     }     Catch {         Exit 1     }     If ($softwareCenter) {           $taskSequence = $softwareCenter.GetAvailableApplications() | Where { $_.PackageName -eq "$Name" }         If ($taskSequence) {             $taskSequenceProgramID = $taskSequence.ID             $taskSequencePackageID = $taskSequence.PackageID             # Execute the task sequence             Try {                 $softwareCenter.ExecuteProgram($taskSequenceProgramID,$taskSequencePackageID,$true)             }             Catch {                 Exit 1             }         }     } } Execute-TaskSequence "Upgrade to Windows 10 - 1709" New-Item -Path HKCU:\Software -Name CCMEXEC –Force New-ItemProperty -Path HKCU:\Software\CCMEXEC -Name "TSHasRun" -Value 1 -PropertyType "String"