Hello,
I am creating an install of O365 Click to Run install and trying to customize taskbar icons on the fly. I have it most of the way there but there is one snafu. Our taskbar icons are set by GPO so I am removing the Office 2016 icons in pre install and attempting to add the O365 icons in post install.
The unpin script works fine and all of the Office 2016 icons are removed. Then Office installs just fine but the pin script doesn’t pin anything and the installation finished without error. If I go to the script and run it manually from powershell or right click it and “run with powershell” it works just fine and pins the icons. But never works through the PSADT install.
I am using the scripts from https://pinto10blog.wordpress.com/2016/09/10/pinto10/ to handle the pinning and unpinning.
Could this be an issue with running as the user two different times? Here is the meat of my deploy-application.ps1.
$installdir = Get-ChildItem c:\windows\ccmcache\*\officecheck.txt -filter officecheck.txt | Select-Object -ExpandProperty directoryname`
$user = Get-LoggedOnUser
new-item -Path c:\files\scripts -ItemType directory -force
copy-item -Path $installdir\files\pin_pre1903.ps1 -Destination c:\files\scripts\pin_pre1903.ps1
copy-item -Path $installdir\files\pin_1903.ps1 -Destination c:\files\scripts\pin_1903.ps1
copy-item -Path $installdir\files\unpin_pre1903.ps1 -Destination c:\files\scripts\unpin_pre1903.ps1
copy-item -Path $installdir\files\unpin_1903.ps1 -Destination c:\files\scripts\unpin_1903.ps1
copy-item -Path $installdir\files\PinToTaskBar1903.ps1 -Destination c:\files\scripts\PinToTaskBarPre1903.ps1
copy-item -Path $installdir\files\PinToTaskBar1903.ps1 -Destination c:\files\scripts\PinToTaskBar1903.ps1
$win10version = (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseID')
If ($win10version -ge 1903) {
Execute-ProcessAsUser -UserName $user.username -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\files\scripts\unpin_1903.ps1`"; Exit `$LastExitCode }" -Wait
}
Else {
Execute-ProcessAsUser -UserName $user.username -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\files\scripts\unpin_pre1903.ps1`"; Exit `$LastExitCode }" -Wait
}
##*===============================================
##* INSTALLATION
##*===============================================
[string]$installPhase = 'Installation'
## <Perform Installation tasks here>
Show-InstallationProgress -StatusMessage "Installing Microsoft Office 365 Pro Plus"
Execute-Process 'setup.exe' -Parameters '/configure configuration.xml' -WindowStyle Hidden
##*===============================================
##* POST-INSTALLATION
##*===============================================
[string]$installPhase = 'Post-Installation'
## <Perform Post-Installation tasks here>
If ($win10version -ge 1903) {
Execute-ProcessAsUser -UserName $user.username -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\files\scripts\pin_1903.ps1`"; Exit `$LastExitCode }" -Wait
}
Else {
Execute-ProcessAsUser -UserName $user.username -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\files\scripts\pin_pre1903.ps1`"; Exit `$LastExitCode }" -Wait
}
The machine I am testing on is 1903 so here is the content of the pin_1903.ps1 script.
$path = 'c:\files\scripts\PinToTaskBar1903.ps1'
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk' PIN
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype For Business.lnk' PIN
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word.lnk' PIN
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Excel.lnk' PIN
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Publisher.lnk' PIN
& $path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PowerPoint.lnk' PIN