Using PSADT to pin to taskbar

I am using PSADT via SCCM to update Office 2016 MSI to Office 365 Click to Run. The Office install works as expected and there are no issues with that.

The problem: After the install I would ideally like to remove the orphaned taskbar shortcuts for Office 2016 (setup by GPO via xml) and then add the icons for O365. This is a pain given the changes to how taskbar pinning from command line has changed across windows versions. It is made even more complicated with SCCM since it runs as system but I think I have gotten over those hurdles.

Since the orphaned icons go away after a reboot, my current plan to set a runonce key for the currently logged on user doing the install via SCCM Software Center. Then on the next reboot it should run the appropriate script for that version of windows. I did not write the scripts for pinning, they are just ones I found on the internet that work fine when ran from a powershell prompt.

All of this works when ran manually through powershell but when I do the full install through SCCM the runonce key is set, I reboot, powershell launches but the taskbar icons are not set. If I set the runonce manually and reboot, it works as expected. I am missing something either in the powershell scripts or something to do with the scope things are running in I think. It’s driving me crazy.

Here is where I am at. This is the Deploy-Application.ps1 from PSADT this code is in the post install phase section.

## <Perform Post-Installation tasks here> #$install dir is the sccm cache folder where the file are stored new-item -Path c:filesscripts -ItemType directory -force #move the scripts out of the windows folder so the user will be able to access it copy-item -Path $installdirfilespin.ps1 -Destination c:filesscriptspin.ps1 copy-item -Path $installdirfilespin1903.ps1 -Destination c:filesscriptspin1903.ps1 copy-item -Path $installdirfilesPinToTaskBar1903.ps1 -Destination c:filesscriptsPinToTaskBar1903.ps1 #get-loggedon user is a PSADT function to pull the currently logged on user since SCCM is running as system $user = Get-LoggedOnUser #sets the runonce registry key for the next boot $path = "Microsoft.PowerShell.CoreRegistry::HKEY_USERS" + $user.SID + "SoftwareMicrosoftWindowsCurrentVersionRunOnce" #get the windows version and set the appropriate runonce key to the script for that version If ((Get-Item "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion").GetValue('ReleaseID') -ge 1903) { Set-ItemProperty -Path $path "NextRun" ('c:windowssystem32windowspowershellv1.0powershell.exe -command "c:filesscriptspin1903.ps1"') } Else { Set-ItemProperty -Path $path "NextRun" ('c:windowssystem32windowspowershellv1.0powershell.exe -command "c:filesscriptspin.ps1"') } 

The test VM I am working off of that this is not working on is W10 1903 and this is the pin1903.ps1 I am calling from the runonce:

$path = 'c:filesscriptsPinToTaskBar1903.ps1' & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsOutlook.lnk' PIN & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsSkype For Business.lnk' PIN & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsWord.lnk' PIN & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsExcel.lnk' PIN & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsPublisher.lnk' PIN & $path 'C:ProgramDataMicrosoftWindowsStart MenuProgramsPowerPoint.lnk' PIN 

The Pintotaskbar1903.ps1 file I am calling is from here and works fine when ran normally.

If someone has a better way to do this I would certainly welcome that as well.

submitted by /u/thehoof
[link] [comments]

Leave a Reply