Category filter
PowerShell script to export Start menu layout
The Start menu layout on Windows devices typically consists of a customizable grid of frequently used and pinned applications within the Start menu. Exporting the Start menu layout is particularly helpful for IT admins when configuring the Windows multi-app kiosk policy. The script facilitates the export of Start menu layout from Windows devices, which is essential for maintaining a standardized Start menu layout of apps while configuring the kiosk lockdown policy across multiple devices. This process involves exporting the required layout from a reference device and then using it on other devices while configuring the multi-app kiosk policy. The document includes a script to export the Start menu layout on Windows devices, which IT admins can deploy using Hexnode’s Execute Custom Script remote action.
Scripting language – PowerShell
File extension – .ps1
Export Start menu layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
try{ #determining the current logged in user $currentLoggedInuser="" $signedInUsers=get-wmiobject win32_process | where-object {$_.processname -eq "explorer.exe"} | Foreach ({$_.getowner().user}) foreach($user in $signedInUsers) { $isactive = C:\windows\system32\qwinsta.exe $user if($isactive -like "* Active*") { $currentLoggedInuser = $user break } } if($currentLoggedInuser -eq "") { Write-Host "cannot find any logged in user, so skipping script execution`nTo execute this script, atleast one user must be logged-in to the device" } else { Write-Host "The start layout for the user $currentLoggedInuser has been exported successfully." $script = "Start-Process ""$file"" -PassThru -Wait" #unregistering ShowNotificationTask task from task scheduler (if we have already registered using script execution) try { $a=Unregister-ScheduledTask -TaskName "ShowNotificationTask" -Confirm:$false -ErrorAction:Ignore } catch { Write-Host "error while unregistering sheduletask-->",$_.Exception.Message } #scheduling task $actions = (New-ScheduledTaskAction -Execute 'powershell.exe' -WorkingDirectory C:\Hexnode\Logs -Argument "-ExecutionPolicy unrestricted -WindowStyle Hidden -NoLogo -command `"&{Export-StartLayout -Path C:\Path\to\the\file\Filename.xml }`"") $principal = New-ScheduledTaskPrincipal -UserId $currentLoggedInuser -RunLevel Highest $settings = New-ScheduledTaskSettingsSet -WakeToRun -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -Hidden -AllowStartIfOnBatteries -Priority 0 -StartWhenAvailable $task = New-ScheduledTask -Action $actions -Principal $principal -Settings $settings $reg= Register-ScheduledTask 'ShowNotificationTask' -InputObject $task Start-ScheduledTask -TaskName "ShowNotificationTask" -Verbose } } catch { Write-Host "Exception inside running script-->",$_.Exception.Message } |
The script fetches and saves the Start menu layout for the currently logged-in user account using the Export-StartLayout
cmdlet. This cmdlet exports the layout of the Start menu as an XML file. The Export-StartLayout
cmdlet is used with the -Path
parameter specifying the location and filename where the XML file containing the Start menu layout will be saved. Replace C:\Path\to\the\file\Filename.xml
with the actual path where you want to save the start layout XML file. Also, replace Filename.xml
with the desired name for the XML file.
What happens at the device end?
Upon successful execution of the script, the Start menu layout of the currently logged-in user account will be saved to the specified location on the device. A success message will then be displayed in the Hexnode UEM portal under the Action History tab.