├── Customize TaskBar and Start Windows 11 ├── CustomizeTaskbar v1.1.ps1 ├── CustomizeTaskbar.ps1 └── Readme ├── MEMCM Retry Installation for Approved App.ps1 ├── MEMCM User GPupdate from System context.ps1 ├── MEMCM WakeOnLan.ps1 ├── README.md ├── Refresh User GPO using MEMCM Script └── RefreshUserGPO ├── UpdateEdgeSourceFiles ├── DownloadUpdateEdge_v1.2.ps1 └── Readme └── Windows 11 Multi App Kiosk ├── Readme └── Windows11 MultiApp Kiosk.ps1 /Customize TaskBar and Start Windows 11/CustomizeTaskbar v1.1.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Customize Taskbar in Windows 11 3 | Sassan Fanai / Jörgen Nilsson 4 | Version 1.1 5 | Added Option to remove CoPIlot and updated remove Search 6 | #> 7 | 8 | param ( 9 | [switch]$RemoveTaskView, 10 | [switch]$RemoveCopilot, 11 | [switch]$RemoveWidgets, 12 | [switch]$RemoveChat, 13 | [switch]$MoveStartLeft, 14 | [switch]$RemoveSearch, 15 | [switch]$StartMorePins, 16 | [switch]$StartMoreRecommendations, 17 | [switch]$RunForExistingUsers 18 | ) 19 | 20 | [string]$RegValueName = "CustomizeTaskbar" 21 | [string]$FullRegKeyName = "HKLM:\SOFTWARE\ccmexec\" 22 | 23 | # Create registry value if it doesn't exist 24 | If (!(Test-Path $FullRegKeyName)) { 25 | New-Item -Path $FullRegKeyName -type Directory -force 26 | } 27 | 28 | New-itemproperty $FullRegKeyName -Name $RegValueName -Value "1" -Type STRING -Force 29 | 30 | REG LOAD HKLM\Default C:\Users\Default\NTUSER.DAT 31 | 32 | switch ($PSBoundParameters.Keys) { 33 | # Removes Task View from the Taskbar 34 | 'RemoveTaskView' { 35 | Write-Host "Attempting to run: $PSItem" 36 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force 37 | try { $reg.Handle.Close() } catch {} 38 | 39 | } 40 | # Removes Widgets from the Taskbar 41 | 'RemoveWidgets' { 42 | Write-Host "Attempting to run: $PSItem" 43 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force 44 | try { $reg.Handle.Close() } catch {} 45 | } 46 | # Removes Copilot from the Taskbar 47 | 'RemoveCopilot' { 48 | Write-Host "Attempting to run: $PSItem" 49 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowCopilotButton" -Value "0" -PropertyType Dword -Force 50 | try { $reg.Handle.Close() } catch {} 51 | } 52 | # Removes Chat from the Taskbar 53 | 'RemoveChat' { 54 | Write-Host "Attempting to run: $PSItem" 55 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force 56 | try { $reg.Handle.Close() } catch {} 57 | } 58 | # Default StartMenu alignment 0=Left 59 | 'MoveStartLeft' { 60 | Write-Host "Attempting to run: $PSItem" 61 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force 62 | try { $reg.Handle.Close() } catch {} 63 | } 64 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 65 | 'StartMorePins' { 66 | Write-Host "Attempting to run: $PSItem" 67 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force 68 | try { $reg.Handle.Close() } catch {} 69 | } 70 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 71 | 'StartMoreRecommendations' { 72 | Write-Host "Attempting to run: $PSItem" 73 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force 74 | try { $reg.Handle.Close() } catch {} 75 | 76 | } # Removes search from the Taskbar 77 | 'RemoveSearch' { 78 | Write-Host "Attempting to run: $PSItem" 79 | $RegKey = "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\RunOnce" 80 | if (-not(Test-Path $RegKey )) { 81 | $reg = New-Item $RegKey -Force | Out-Null 82 | try { $reg.Handle.Close() } catch {} 83 | } 84 | $reg = New-ItemProperty $RegKey -Name "RemoveSearch" -Value "reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Search /t REG_DWORD /v SearchboxTaskbarMode /d 0 /f" -PropertyType String -Force 85 | try { $reg.Handle.Close() } catch {} 86 | } 87 | Default { 'No parameters were specified' } 88 | } 89 | [GC]::Collect() 90 | REG UNLOAD HKLM\Default 91 | 92 | if ($PSBoundParameters.ContainsKey('RunForExistingUsers')) { 93 | Write-Host "RunForExistingUsers parameter specified." 94 | $UserProfiles = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" | 95 | Where-Object { $_.PSChildName -match "S-1-5-21-(\d+-?){4}$" } | 96 | Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)\NTuser.dat" } } 97 | 98 | # Loop through each profile on the machine 99 | foreach ($UserProfile in $UserProfiles) { 100 | Write-Host "Running for profile: $($UserProfile.UserHive)" 101 | # Load User NTUser.dat if it's not already loaded 102 | if (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS\$($UserProfile.SID)) -eq $false) { 103 | Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE LOAD HKU\$($UserProfile.SID) $($UserProfile.UserHive)" -Wait -WindowStyle Hidden 104 | } 105 | switch ($PSBoundParameters.Keys) { 106 | # Removes Task View from the Taskbar 107 | 'RemoveTaskView' { 108 | Write-Host "Attempting to run: $PSItem" 109 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force 110 | try { $reg.Handle.Close() } catch {} 111 | 112 | } 113 | # Removes Widgets from the Taskbar 114 | 'RemoveWidgets' { 115 | Write-Host "Attempting to run: $PSItem" 116 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force 117 | try { $reg.Handle.Close() } catch {} 118 | } 119 | # Removes Copilot from the Taskbar 120 | 'RemoveCopilot' { 121 | Write-Host "Attempting to run: $PSItem" 122 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowCopilotButton" -Value "0" -PropertyType Dword -Force 123 | try { $reg.Handle.Close() } catch {} 124 | } 125 | # Removes Chat from the Taskbar 126 | 'RemoveChat' { 127 | Write-Host "Attempting to run: $PSItem" 128 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force 129 | try { $reg.Handle.Close() } catch {} 130 | } 131 | # Default StartMenu alignment 0=Left 132 | 'MoveStartLeft' { 133 | Write-Host "Attempting to run: $PSItem" 134 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force 135 | try { $reg.Handle.Close() } catch {} 136 | } 137 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 138 | 'StartMorePins' { 139 | Write-Host "Attempting to run: $PSItem" 140 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force 141 | try { $reg.Handle.Close() } catch {} 142 | } 143 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 144 | 'StartMoreRecommendations' { 145 | Write-Host "Attempting to run: $PSItem" 146 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force 147 | try { $reg.Handle.Close() } catch {} 148 | } 149 | # Removes search from the Taskbar 150 | 'RemoveSearch' { 151 | Write-Host "Attempting to run: $PSItem" 152 | $RegKey = "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Search" 153 | if (-not(Test-Path $RegKey )) { 154 | $reg = New-Item $RegKey -Force | Out-Null 155 | try { $reg.Handle.Close() } catch {} 156 | } 157 | $reg = New-ItemProperty $RegKey -Name "SearchboxTaskbarMode" -Value "0" -PropertyType Dword -Force 158 | try { $reg.Handle.Close() } catch {} 159 | } 160 | Default { 'No parameters were specified' } 161 | } 162 | # Unload NTUser.dat 163 | if ($ProfileWasLoaded -eq $false) { 164 | [GC]::Collect() 165 | Start-Sleep 1 166 | Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE UNLOAD HKU\$($UserProfile.SID)" -Wait -WindowStyle Hidden 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Customize TaskBar and Start Windows 11/CustomizeTaskbar.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Customize Taskbar in Windows 11 3 | Sassan Fanai / Jörgen Nilsson 4 | Version 1.0 5 | #> 6 | 7 | param ( 8 | [switch]$RemoveTaskView, 9 | [switch]$RemoveWidgets, 10 | [switch]$RemoveChat, 11 | [switch]$MoveStartLeft, 12 | [switch]$RemoveSearch, 13 | [switch]$StartMorePins, 14 | [switch]$StartMoreRecommendations, 15 | [switch]$RunForExistingUsers 16 | ) 17 | 18 | [string]$RegValueName = "CustomizeTaskbar" 19 | [string]$FullRegKeyName = "HKLM:\SOFTWARE\ccmexec\" 20 | 21 | # Create registry value if it doesn't exist 22 | If (!(Test-Path $FullRegKeyName)) { 23 | New-Item -Path $FullRegKeyName -type Directory -force 24 | } 25 | 26 | New-itemproperty $FullRegKeyName -Name $RegValueName -Value "1" -Type STRING -Force 27 | 28 | REG LOAD HKLM\Default C:\Users\Default\NTUSER.DAT 29 | 30 | switch ($PSBoundParameters.Keys) { 31 | # Removes Task View from the Taskbar 32 | 'RemoveTaskView' { 33 | Write-Host "Attempting to run: $PSItem" 34 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force 35 | try { $reg.Handle.Close() } catch {} 36 | 37 | } 38 | # Removes Widgets from the Taskbar 39 | 'RemoveWidgets' { 40 | Write-Host "Attempting to run: $PSItem" 41 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force 42 | try { $reg.Handle.Close() } catch {} 43 | } 44 | # Removes Chat from the Taskbar 45 | 'RemoveChat' { 46 | Write-Host "Attempting to run: $PSItem" 47 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force 48 | try { $reg.Handle.Close() } catch {} 49 | } 50 | # Default StartMenu alignment 0=Left 51 | 'MoveStartLeft' { 52 | Write-Host "Attempting to run: $PSItem" 53 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force 54 | try { $reg.Handle.Close() } catch {} 55 | } 56 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 57 | 'StartMorePins' { 58 | Write-Host "Attempting to run: $PSItem" 59 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force 60 | try { $reg.Handle.Close() } catch {} 61 | } 62 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 63 | 'StartMoreRecommendations' { 64 | Write-Host "Attempting to run: $PSItem" 65 | $reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force 66 | try { $reg.Handle.Close() } catch {} 67 | 68 | } # Removes search from the Taskbar 69 | 'RemoveSearch' { 70 | Write-Host "Attempting to run: $PSItem" 71 | $RegKey = "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Search" 72 | if (-not(Test-Path $RegKey )) { 73 | $reg = New-Item $RegKey -Force | Out-Null 74 | try { $reg.Handle.Close() } catch {} 75 | } 76 | $reg = New-ItemProperty $RegKey -Name "SearchboxTaskbarMode" -Value "0" -PropertyType Dword -Force 77 | try { $reg.Handle.Close() } catch {} 78 | } 79 | Default { 'No parameters were specified' } 80 | } 81 | [GC]::Collect() 82 | REG UNLOAD HKLM\Default 83 | 84 | if ($PSBoundParameters.ContainsKey('RunForExistingUsers')) { 85 | Write-Host "RunForExistingUsers parameter specified." 86 | $UserProfiles = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" | 87 | Where-Object { $_.PSChildName -match "S-1-5-21-(\d+-?){4}$" } | 88 | Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)\NTuser.dat" } } 89 | 90 | # Loop through each profile on the machine 91 | foreach ($UserProfile in $UserProfiles) { 92 | Write-Host "Running for profile: $($UserProfile.UserHive)" 93 | # Load User NTUser.dat if it's not already loaded 94 | if (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS\$($UserProfile.SID)) -eq $false) { 95 | Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE LOAD HKU\$($UserProfile.SID) $($UserProfile.UserHive)" -Wait -WindowStyle Hidden 96 | } 97 | switch ($PSBoundParameters.Keys) { 98 | # Removes Task View from the Taskbar 99 | 'RemoveTaskView' { 100 | Write-Host "Attempting to run: $PSItem" 101 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force 102 | try { $reg.Handle.Close() } catch {} 103 | 104 | } 105 | # Removes Widgets from the Taskbar 106 | 'RemoveWidgets' { 107 | Write-Host "Attempting to run: $PSItem" 108 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force 109 | try { $reg.Handle.Close() } catch {} 110 | } 111 | # Removes Chat from the Taskbar 112 | 'RemoveChat' { 113 | Write-Host "Attempting to run: $PSItem" 114 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force 115 | try { $reg.Handle.Close() } catch {} 116 | } 117 | # Default StartMenu alignment 0=Left 118 | 'MoveStartLeft' { 119 | Write-Host "Attempting to run: $PSItem" 120 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force 121 | try { $reg.Handle.Close() } catch {} 122 | } 123 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 124 | 'StartMorePins' { 125 | Write-Host "Attempting to run: $PSItem" 126 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force 127 | try { $reg.Handle.Close() } catch {} 128 | } 129 | # Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2) 130 | 'StartMoreRecommendations' { 131 | Write-Host "Attempting to run: $PSItem" 132 | $reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force 133 | try { $reg.Handle.Close() } catch {} 134 | } 135 | # Removes search from the Taskbar 136 | 'RemoveSearch' { 137 | Write-Host "Attempting to run: $PSItem" 138 | $RegKey = "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Search" 139 | if (-not(Test-Path $RegKey )) { 140 | $reg = New-Item $RegKey -Force | Out-Null 141 | try { $reg.Handle.Close() } catch {} 142 | } 143 | $reg = New-ItemProperty $RegKey -Name "SearchboxTaskbarMode" -Value "0" -PropertyType Dword -Force 144 | try { $reg.Handle.Close() } catch {} 145 | } 146 | Default { 'No parameters were specified' } 147 | } 148 | # Unload NTUser.dat 149 | if ($ProfileWasLoaded -eq $false) { 150 | [GC]::Collect() 151 | Start-Sleep 1 152 | Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE UNLOAD HKU\$($UserProfile.SID)" -Wait -WindowStyle Hidden 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Customize TaskBar and Start Windows 11/Readme: -------------------------------------------------------------------------------- 1 | Script to customize the Taskbar and default Start Menu layout on Windows 11 22H2 2 | -------------------------------------------------------------------------------- /MEMCM Retry Installation for Approved App.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | [string]$MachineName, 4 | [string]$AppName 5 | ) 6 | 7 | Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" 8 | $SiteCode = (Get-WmiObject -Namespace root\sms -Query 'SELECT SiteCode FROM SMS_ProviderLocation').SiteCode 9 | Set-Location "$($SiteCode):" 10 | $NameSpace ="ROOT\SMS\site_$($SiteCode)" 11 | 12 | $AppID = (Get-CMApplication -Name "$AppName").ModelName 13 | $SMSID = (Get-CMDevice -Name "$MachineName").SMSID 14 | 15 | $reqObj = Get-WmiObject -Namespace $NameSpace -Class SMS_UserApplicationRequest | Where {$_.ModelName -eq $AppID -and $_.RequestedMachine -eq $MachineName} 16 | $reqObjPath = $reqObj.__PATH 17 | 18 | Invoke-WmiMethod -Path $reqObjPath -Name RetryInstall -------------------------------------------------------------------------------- /MEMCM User GPupdate from System context.ps1: -------------------------------------------------------------------------------- 1 | # Script to update User GPO from System context using a Schedule Task 2 | # Written by Jörgen Nilsson 3 | # ccmexec.com 4 | 5 | # Creates a local vbscript, which will run GPUpdate without displaying anything for the end user 6 | $VBScript = @" 7 | Set objShell = WScript.CreateObject("WScript.Shell") 8 | Result = objShell.Run ("cmd /c echo n | gpupdate /target:user /force",0,true) 9 | Wscript.quit(Result) 10 | "@ 11 | 12 | $VBScript | Out-File -FilePath "$env:Windir\RunUserGPO.vbs" -Force 13 | 14 | # Gets the logged on user 15 | $computer = $env:COMPUTERNAME 16 | $computerSystem = Get-WMIObject -class Win32_ComputerSystem -ComputerName $computer 17 | $LoggedUser = $computerSystem.UserName 18 | If ($LoggedUser -eq $null) { 19 | Write-output "No user logged on" 20 | Exit 1 21 | } 22 | # Creates and run a Schedule Task as the logged on user 23 | $TaskName= "GPupdateUser" 24 | $Action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "$env:Windir\RunUserGPO.vbs /NoLogo" 25 | $Principal = New-ScheduledTaskPrincipal "$loggedUser" 26 | $Settings = New-ScheduledTaskSettingsSet 27 | 28 | $Task = New-ScheduledTask -Action $Action -Principal $Principal -Settings $Settings 29 | Register-ScheduledTask $TaskName -InputObject $Task | out-null 30 | Start-ScheduledTask $TaskName | out-null 31 | 32 | # Wait for Schedule task to complete 33 | $Counter = 200 # 40 s 34 | while ((Get-ScheduledTask -TaskName $TaskName).State -ne 'Ready' -and $Counter-- -gt 0) { 35 | Start-Sleep -Milliseconds 200 36 | } 37 | 38 | if ($Counter -lt 0) { 39 | Write-Output "Timeout waiting for Scheduled Task" 40 | exit 1 41 | } 42 | 43 | # Verify Result 44 | $St = Get-ScheduledTask -TaskName $TaskName 45 | $Result = (Get-ScheduledTaskInfo -InputObject $St).LastTaskResult 46 | if ($Result -eq 0) { 47 | Write-Output "Completed Succesfully" 48 | } 49 | else { 50 | Write-Output "Error running Schedule task, error code = $('0x{0:x}' -f $Result)" 51 | } 52 | 53 | # Cleaning up 54 | Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false 55 | Remove-Item -Path "$env:Windir\RunUserGPO.vbs" -Force -------------------------------------------------------------------------------- /MEMCM WakeOnLan.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script to use client notification to Wake up a single computer or a collection of computers. 3 | 4 | Written by Johan Schrewelius and Jörgen Nilsson 5 | 6 | 2019-01-22 ccmexec.com 7 | #> 8 | 9 | [CmdletBinding()] 10 | Param( 11 | $CmpName = $Null, 12 | $CollId = "SMS00001", 13 | $SiteServer = "" 14 | ) 15 | 16 | if (!$CmpName -and $CollId -eq "SMS00001") { 17 | 18 | Write-Host "Seems wrong to wake every single computer in the environment, refusing to perform." 19 | exit 1 20 | } 21 | 22 | $SiteCode = (Get-WmiObject -ComputerName "$SiteServer" -Namespace root\sms -Query 'SELECT SiteCode FROM SMS_ProviderLocation').SiteCode 23 | 24 | if ($CmpName) { 25 | 26 | $ResourceID = (Get-WmiObject -ComputerName "$SiteServer" -Namespace "Root\SMS\Site_$($SiteCode)" -Query "Select ResourceID from SMS_R_System Where NetBiosName = '$($CmpName)'").ResourceID 27 | 28 | if ($ResourceID) { 29 | $CmpName = @($ResourceID) 30 | } 31 | } 32 | 33 | $WMIConnection = [WMICLASS]"\\$SiteServer\Root\SMS\Site_$($SiteCode):SMS_SleepServer" 34 | $Params = $WMIConnection.psbase.GetMethodParameters("MachinesToWakeup") 35 | $Params.MachineIDs = $CmpName 36 | $Params.CollectionID = $CollId 37 | $return = $WMIConnection.psbase.InvokeMethod("MachinesToWakeup", $Params, $Null) 38 | 39 | if (!$return) { 40 | Write-Host "No machines are online to wake up selected devices" 41 | } 42 | 43 | if ($return.numsleepers -ge 1) { 44 | Write-Host "The resource selected are scheduled to wake-up as soon as possible" 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PowerShell -------------------------------------------------------------------------------- /Refresh User GPO using MEMCM Script/RefreshUserGPO: -------------------------------------------------------------------------------- 1 | # Script to update User GPO from System context using a Schedule Task 2 | # Written by Jörgen Nilsson 3 | # ccmexec.com 4 | 5 | # Creates a local vbscript, which will run GPUpdate without displaying anything for the end user 6 | $VBScript = @" 7 | Set objShell = WScript.CreateObject("WScript.Shell") 8 | Result = objShell.Run ("cmd /c echo n | gpupdate /target:user /force",0,true) 9 | Wscript.quit(Result) 10 | "@ 11 | 12 | $VBScript | Out-File -FilePath "$env:Windir\RunUserGPO.vbs" -Force 13 | 14 | # Gets the logged on user 15 | $computer = $env:COMPUTERNAME 16 | $computerSystem = Get-WMIObject -class Win32_ComputerSystem -ComputerName $computer 17 | $LoggedUser = $computerSystem.UserName 18 | If ($LoggedUser -eq $null) { 19 | Write-output "No user logged on" 20 | Exit 1 21 | } 22 | # Creates and run a Schedule Task as the logged on user 23 | $TaskName = "GPupdateUser" 24 | $Action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "$env:Windir\RunUserGPO.vbs /NoLogo" 25 | $Principal = New-ScheduledTaskPrincipal "$loggedUser" 26 | $Settings = New-ScheduledTaskSettingsSet 27 | 28 | $Task = New-ScheduledTask -Action $Action -Principal $Principal -Settings $Settings 29 | Register-ScheduledTask $TaskName -InputObject $Task | out-null 30 | Start-ScheduledTask $TaskName | out-null 31 | 32 | # Wait for Schedule task to complete 33 | $Counter = 200 # 40 s 34 | while ((Get-ScheduledTask -TaskName $TaskName).State -ne 'Ready' -and $Counter-- -gt 0) { 35 | Start-Sleep -Milliseconds 200 36 | } 37 | 38 | if ($Counter -lt 0) { 39 | Write-Output "Timeout waiting for Scheduled Task" 40 | exit 1 41 | } 42 | 43 | # Verify Result 44 | $St = Get-ScheduledTask -TaskName $TaskName 45 | $Result = (Get-ScheduledTaskInfo -InputObject $St).LastTaskResult 46 | if ($Result -eq 0) { 47 | Write-Output "Completed Succesfully" 48 | } 49 | else { 50 | Write-Output "Error running Schedule task, error code = $('0x{0:x}' -f $Result)" 51 | } 52 | 53 | # Cleaning up 54 | Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false 55 | Remove-Item -Path "$env:Windir\RunUserGPO.vbs" -Force 56 | -------------------------------------------------------------------------------- /UpdateEdgeSourceFiles/DownloadUpdateEdge_v1.2.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param ( 3 | $CMEdgeAppName = "Microsoft Edge Latest - Stable", 4 | $CMAppDeploymentType = "Edge X64 Default Deployment Type", 5 | $TempPath = "D:\Staging", 6 | $Targetpath = "\\d00008\Sources\Apps\Microsoft Edge\Stable\81.0.416.64\X64\", 7 | $VersionsToKeep = 3 8 | ) 9 | 10 | # Logging parameters 11 | $LogParams = @{ 12 | FileName = $($MyInvocation.MyCommand.Name) 13 | LogFileName = "$($TempPath)\$($MyInvocation.MyCommand.Name.Replace(".ps1", ".log"))" 14 | Component = "PowerShellScript" 15 | LogSizeKB = 2048 16 | } 17 | 18 | function WriteLog { 19 | param( 20 | [Parameter(Mandatory)] 21 | [string]$LogText, 22 | $Component, 23 | [Parameter(Mandatory)] 24 | [ValidateNotNullOrEmpty()] 25 | [ValidateSet('Info','Warning','Error','Verbose')] 26 | [string]$Type, 27 | [string]$LogFileName, 28 | [string]$FileName, 29 | [int]$LogSizeKB = 2048 30 | ) 31 | 32 | switch ($Type) 33 | { 34 | "Info" { $typeint = 1 } 35 | "Warning" { $typeint = 2 } 36 | "Error" { $typeint = 3 } 37 | "Verbose" { $typeint = 4 } 38 | } 39 | 40 | $time = Get-Date -f "HH:mm:ss.ffffff" 41 | $date = Get-Date -f "MM-dd-yyyy" 42 | $ParsedLog = "" 43 | $ParsedLog | Out-File -FilePath "$LogFileName" -Append -Encoding utf8 -WhatIf:$false 44 | 45 | if ((Get-Item "$LogFileName").length / 1KB -gt $LogSizeKB) { 46 | $ext = [System.IO.Path]::GetExtension($LogFileName) 47 | Rename-Item -Path "$LogFileName" -NewName "$LogFileName".Replace("$ext", "$((Get-Date -Format "_yyyy_MM_dd_HH_mm_ss_fff"))$($ext)") -Force -ErrorAction SilentlyContinue -WhatIf:$false 48 | } 49 | } 50 | 51 | # Create Staging path 52 | if (!(Test-Path -Path $TempPath)) { 53 | New-Item -Path $TempPath -Force -ItemType Directory | Out-Null 54 | } 55 | 56 | WriteLog "### Starting script ###" @LogParams -Type Info 57 | # Download and Import Modules 58 | Write-Host "Importing CM Module..." 59 | WriteLog "Importing CM Module..." @LogParams -Type Info 60 | Import-Module $env:SMS_ADMIN_UI_PATH.Replace("bin\i386","bin\ConfigurationManager.psd1") -Force -ErrorAction Stop 61 | if ($null -eq (Get-Module ConfigurationManager)) { 62 | Write-Host "Could not load the ConfigurationManager module, exiting script." -ForegroundColor Red 63 | WriteLog "Could not load the ConfigurationManager module, exiting script." @LogParams -Type Error 64 | Exit 1 65 | } 66 | if ($null -eq (Get-Module -Name Evergreen -ListAvailable)) { 67 | Write-Host "Evergreen module not found, attempting to install module" -ForegroundColor Yellow 68 | WriteLog "Evergreen module not found, attempting to install module" @LogParams -Type Warning 69 | Install-Module Evergreen -Force 70 | } 71 | 72 | Write-Host "Updating Evergreen module..." 73 | WriteLog "Updating Evergreen module..." @LogParams -Type Info 74 | Update-Module Evergreen -Force 75 | Import-Module Evergreen 76 | 77 | 78 | # Check for updated Edge version 79 | Write-Host "Info: Checking for updated version of Edge" 80 | $LatestEdge = (Get-MicrosoftEdge | Where-Object {$PSItem.Channel -eq "Stable" -and $PSItem.Architecture -eq "x64"}) 81 | $CurrentEdge = Get-ChildItem $TempPath -Directory | Sort-Object {[version]$PSItem.Name} -Descending | Select-Object -First 1 82 | if ($null -ne $CurrentEdge) { 83 | if ([version]$CurrentEdge.Name -eq [version]$LatestEdge.Version) { 84 | Write-Host "Edge is up-to-date, version [$($LatestEdge.Version)] already in $TempPath." -ForegroundColor Green 85 | Write-Host "Nothing to do, exiting script." 86 | WriteLog "Edge is up-to-date, version [$($LatestEdge.Version)] already in $TempPath." @LogParams -Type Info 87 | WriteLog "### Nothing to do, exiting script. ###" @LogParams -Type Info 88 | Exit 0 89 | } 90 | } 91 | 92 | # Download & Update Edge 93 | $StagingPath = Join-Path $TempPath $LatestEdge.Version 94 | Write-host "Update is available. Downloading version [$($LatestEdge.Version)] to $StagingPath" -ForegroundColor Yellow 95 | WriteLog "Update is available. Downloading version [$($LatestEdge.Version)] to $StagingPath" @LogParams -Type Info 96 | New-Item -Path $StagingPath -ItemType Directory | Out-Null 97 | Invoke-WebRequest $LatestEdge.URI -OutFile "$($StagingPath)\MicrosoftEdgeEnterpriseX64.msi" 98 | Write-host "Attempting to update Edge version to [$($LatestEdge.Version)] from [$($CurrentEdge.Name)]" 99 | WriteLog "Attempting to update Edge version to [$($LatestEdge.Version)] from [$($CurrentEdge.Name)]" @LogParams -Type Info 100 | Write-host "Copying MicrosoftEdgeEnterpriseX64.msi to $Targetpath" 101 | WriteLog "Copying MicrosoftEdgeEnterpriseX64.msi to $Targetpath" @LogParams -Type Info 102 | Copy-Item -Path "Microsoft.PowerShell.Core\FileSystem::$StagingPath\MicrosoftEdgeEnterpriseX64.msi" -Destination "Microsoft.PowerShell.Core\FileSystem::$Targetpath" -Force 103 | Write-host "Updating content on DPs for App: [$CMEdgeAppName] and DeploymentType: [$CMAppDeploymentType]" 104 | WriteLog "Updating content on DPs for App: [$CMEdgeAppName] and DeploymentType: [$CMAppDeploymentType]" @LogParams -Type Info 105 | Set-Location -LiteralPath "$((Get-PSDrive -PSProvider CMSite).Name):" -ErrorAction Stop 106 | Update-CMDistributionPoint -ApplicationName $CMEdgeAppName -DeploymentTypeName $CMAppDeploymentType 107 | 108 | # Delete old versions from staging path 109 | Get-ChildItem $TempPath -Directory | Sort-Object {[version]$PSItem.Name} -Descending | Select-Object -Skip $VersionsToKeep | 110 | ForEach-Object { 111 | Write-Host "Deleting old version [$($PSItem.Name)] from staging path" 112 | WriteLog "Deleting old version [$($PSItem.Name)] from staging path" @LogParams -Type Info 113 | Remove-Item $PSItem.Fullname -Recurse -Force 114 | } 115 | 116 | Write-host "### Done, existing script. ###" 117 | WriteLog "### Done, existing script. ###" @LogParams -Type Info 118 | -------------------------------------------------------------------------------- /UpdateEdgeSourceFiles/Readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Windows 11 Multi App Kiosk/Readme: -------------------------------------------------------------------------------- 1 | I will share different sample Windows 11 Multi App Kiosk samples in this folder 2 | -------------------------------------------------------------------------------- /Windows 11 Multi App Kiosk/Windows11 MultiApp Kiosk.ps1: -------------------------------------------------------------------------------- 1 | $nameSpaceName="root\cimv2\mdm\dmmap" 2 | $className="MDM_AssignedAccess" 3 | $obj = Get-CimInstance -Namespace $namespaceName -ClassName $className 4 | Add-Type -AssemblyName System.Web 5 | $obj.Configuration = [System.Web.HttpUtility]::HtmlEncode(@" 6 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | "@) 44 | 45 | Set-CimInstance -CimInstance $obj --------------------------------------------------------------------------------