I wasn't aware of the Active Setup option when I did my deployment. Instead, I wrote some code in the Post-Install section to parse the User profiles, check for pinned Taskbar items from 2010, create a new reg key to keep track, then add a new entry in each user's RunOnce to execute a script on their next login. I know it likely isn't the cleanest method, but it has worked consistently for me.
Post install code:
Post install code:
# Find all all Office 2010 Links and remove them
Write-Log "Finding all old TaskBar Links, writing a registry entry to keep track, and removing the old files"
Copy-File $dirSupportFiles\ReplaceOldLinks.ps1 -Destination "C:\users\Public"
$users = Get-UserProfiles | Where-Object{$_.SID -ine "S-1-5-21-Default-User"}
[scriptblock]$HKCURegistrySettings = {
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce' -Name 'ReplaceOldOfficeLinks' -Value 'powershell.exe -noninteractive -noprofile -executionpolicy bypass -file "c:\users\public\ReplaceOldLinks.ps1" -windowstyle Hidden' -Type String -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings -UserProfiles $users
foreach ($u in $users)
{
$links = Get-ChildItem -Path "$($u.ProfilePath)\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" -Filter "*2010.lnk" -ErrorAction SilentlyContinue
$regBase = "Registry::HKEY_USERS\$($u.SID)\Software\Microsoft\Office\15.0\Links"
foreach($l in $links){
switch -wildcard ($l.Name)
{
"*Outlook*" {Set-RegistryKey -Key "$regBase\Outlook"}
"*Access*" {Set-RegistryKey -Key "$regBase\Access"}
"*Excel*" {Set-RegistryKey -Key "$regBase\Excel"}
"*InfoPath*" {Set-RegistryKey -Key "$regBase\InfoPath"}
"*OneNote*" {Set-RegistryKey -Key "$regBase\OneNote"}
"*PowerPoint*" {Set-RegistryKey -Key "$regBase\PowerPoint"}
"*Project*" {Set-RegistryKey -Key "$regBase\Project"}
"*Publisher*" {Set-RegistryKey -Key "$regBase\Publisher"}
"*Word*" {Set-RegistryKey -Key "$regBase\Word"}
}
}
$links | Remove-Item -Force -ErrorAction SilentlyContinue
}
ReplaceOldOfficeLinks.ps1$oldlinks = (Get-ChildItem -Path HKCU:\SOFTWARE\Microsoft\Office\15.0\Links).PSChildName
$linkbase = "$($env:ALLUSERSPROFILE)\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013"
foreach($link in $oldlinks){
Switch -wildcard ($link)
{
"*Access*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Access 2013.lnk" -ErrorAction SilentlyContinue }
"*Excel*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Excel 2013.lnk" -ErrorAction SilentlyContinue }
"*InfoPath*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\InfoPath Designer 2013.lnk" -ErrorAction SilentlyContinue }
"*OneNote*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\OneNote 2013.lnk" -ErrorAction SilentlyContinue }
"*Outlook*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Outlook 2013.lnk" -ErrorAction SilentlyContinue }
"*PowerPoint*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\PowerPoint 2013.lnk" -ErrorAction SilentlyContinue }
"*Publisher*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Publisher 2013.lnk" -ErrorAction SilentlyContinue }
"*Project*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Project 2013.lnk" -ErrorAction SilentlyContinue }
"*Word*"{ Set-PinnedApplication -Action PinToTaskbar -FilePath "$linkbase\Word 2013.lnk" -ErrorAction SilentlyContinue }
}
}
function Set-PinnedApplication
{
<#
.SYNOPSIS
This function are used to pin and unpin programs from the taskbar and Start-menu in Windows 7 and Windows Server 2008 R2
.DESCRIPTION
The function have to parameteres which are mandatory:
Action: PinToTaskbar, PinToStartMenu, UnPinFromTaskbar, UnPinFromStartMenu
FilePath: The path to the program to perform the action on
.EXAMPLE
Set-PinnedApplication -Action PinToTaskbar -FilePath "C:\WINDOWS\system32\notepad.exe"
.EXAMPLE
Set-PinnedApplication -Action UnPinFromTaskbar -FilePath "C:\WINDOWS\system32\notepad.exe"
.EXAMPLE
Set-PinnedApplication -Action PinToStartMenu -FilePath "C:\WINDOWS\system32\notepad.exe"
.EXAMPLE
Set-PinnedApplication -Action UnPinFromStartMenu -FilePath "C:\WINDOWS\system32\notepad.exe"
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$Action,
[Parameter(Mandatory=$true)][string]$FilePath
)
if(-not (test-path $FilePath)) {
throw "FilePath does not exist."
}
function InvokeVerb {
param([string]$FilePath,$verb)
$verb = $verb.Replace("&","")
$path= split-path $FilePath
$shell=new-object -com "Shell.Application"
$folder=$shell.Namespace($path)
$item = $folder.Parsename((split-path $FilePath -leaf))
$itemVerb = $item.Verbs() | ? {$_.Name.Replace("&","") -eq $verb}
if($itemVerb -eq $null){
throw "Verb $verb not found."
} else {
$itemVerb.DoIt()
}
}
function GetVerb {
param([int]$verbId)
try {
$t = [type]"CosmosKey.Util.MuiHelper"
} catch {
$def = [Text.StringBuilder]""
[void]$def.AppendLine('[DllImport("user32.dll")]')
[void]$def.AppendLine('public static extern int LoadString(IntPtr h,uint id, System.Text.StringBuilder sb,int maxBuffer);')
[void]$def.AppendLine('[DllImport("kernel32.dll")]')
[void]$def.AppendLine('public static extern IntPtr LoadLibrary(string s);')
add-type -MemberDefinition $def.ToString() -name MuiHelper -namespace CosmosKey.Util
}
if($global:CosmosKey_Utils_MuiHelper_Shell32 -eq $null){
$global:CosmosKey_Utils_MuiHelper_Shell32 = [CosmosKey.Util.MuiHelper]::LoadLibrary("shell32.dll")
}
$maxVerbLength=255
$verbBuilder = new-object Text.StringBuilder "",$maxVerbLength
[void][CosmosKey.Util.MuiHelper]::LoadString($CosmosKey_Utils_MuiHelper_Shell32,$verbId,$verbBuilder,$maxVerbLength)
return $verbBuilder.ToString()
}
$verbs = @{
"PintoStartMenu"=5381
"UnpinfromStartMenu"=5382
"PintoTaskbar"=5386
"UnpinfromTaskbar"=5387
}
if($verbs.$Action -eq $null){
Throw "Action $action not supported`nSupported actions are:`n`tPintoStartMenu`n`tUnpinfromStartMenu`n`tPintoTaskbar`n`tUnpinfromTaskbar"
}
InvokeVerb -FilePath $FilePath -Verb $(GetVerb -VerbId $verbs.$action)
}