How to PIN Office 365 apps after installation using PsAppDeployToolkit?

This is my PS1 script (uninstall previous version of Office and install the latest Fast Insider)

https://pastebin.com/6fC1u9hh

I also want to PIN the Office 365 apps to the taskbar. I have the following in my scrpit

    & cscript.exe "$dirSupportFiles\pintotaskbar.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PowerPoint 2016.lnk"
    & cscript.exe "$dirSupportFiles\pintotaskbar.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook 2016.lnk"
    & cscript.exe "$dirSupportFiles\pintotaskbar.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word 2016.lnk"
    & cscript.exe "$dirSupportFiles\pintotaskbar.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\skype For Business 2016.lnk"
    & cscript.exe "$dirSupportFiles\pintotaskbar.vbs" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Excel 2016.lnk"

If i open Powershell ISE, and run the whole script, it uninstalls old version of office, install the one in the Files folder in my package and pins the apps, but when I run it through SCCM, it doesn’t PIN the apps. Any ideas?

This is the VBS Script to PIN apps - https://pastebin.com/C3BEkEwF

Thanks in advance.

My guess would be that you are running the SCCM package as Admin (i.e. system) and similar to the Set-PinnedApplication function, the pintotaskbar.vbs needs to be run as the user. “This should typically be run in the user context, as pinned items are stored in the user profile.”