From 001a9c8410ba1e642f3768e38c20b35308711a23 Mon Sep 17 00:00:00 2001 From: Cristian Schmitt Nieto <69589673+schmittnieto@users.noreply.github.com> Date: Thu, 15 May 2025 16:44:29 +0200 Subject: [PATCH 1/2] Integration of my Windows Scripts (from the repository https://github.com/schmittnieto/nerdio-scripted-actions) when they reach a production-ready state --- .../Disable Office Updates Task.ps1 | 57 ++++++++++++ ...Hide or unhide Drives in File Explorer.ps1 | 91 +++++++++++++++++++ .../OneDrive Remote App configuration.ps1 | 78 ++++++++++++++++ 3 files changed, 226 insertions(+) create mode 100644 scripted-actions/windows-scripts/Disable Office Updates Task.ps1 create mode 100644 scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 create mode 100644 scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 diff --git a/scripted-actions/windows-scripts/Disable Office Updates Task.ps1 b/scripted-actions/windows-scripts/Disable Office Updates Task.ps1 new file mode 100644 index 0000000..687662d --- /dev/null +++ b/scripted-actions/windows-scripts/Disable Office Updates Task.ps1 @@ -0,0 +1,57 @@ +<# + Author : Cristian Schmitt Nieto + Source : https://learn.microsoft.com/en-us/microsoft-365/troubleshoot/updates/office-feature-updates-task-faq +#> + +#description: Toggle the built-in "Office Feature Updates" scheduled task to avoid performance issues on multi-session hosts. +#execution mode: Individual +#tags: CSN, Microsoft, Golden Image, Scheduled Task, OfficeUpdates + +<#variables: +{ + "Action": { + "Description": "Enable or disable the Office Feature Updates scheduled task.", + "DisplayName": "Office Update Task Action", + "IsRequired": true, + "OptionsSet": [ + { "Label": "Enable", "Value": "Enable" }, + { "Label": "Disable", "Value": "Disable" } + ] + } +} +#> + +param ( + [Parameter(Mandatory)] + [ValidateSet("Enable","Disable")] + [string]$Action +) + +$TaskName = 'Office Feature Updates' +$TaskPath = '\Microsoft\Office\' + +Write-Host "Starting Office Update Task configuration: $Action..." + +# Attempt to retrieve the task +$task = Get-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -ErrorAction SilentlyContinue + +if (-not $task) { + Write-Error "Scheduled task '$TaskPath$TaskName' not found." + exit 1 +} + +switch ($Action) { + 'Enable' { + Write-Host "Enabling scheduled task '$TaskPath$TaskName'..." + Enable-ScheduledTask -InputObject $task + Write-Host "Task enabled." + } + + 'Disable' { + Write-Host "Disabling scheduled task '$TaskPath$TaskName'..." + Disable-ScheduledTask -InputObject $task + Write-Host "Task disabled." + } +} + +Write-Host "Completed Office Update Task configuration: $Action" diff --git a/scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 b/scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 new file mode 100644 index 0000000..fedeb8a --- /dev/null +++ b/scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 @@ -0,0 +1,91 @@ +<# + Author : Cristian Schmitt Nieto + Source : https://learn.microsoft.com/en-us/troubleshoot/windows-client/group-policy/using-group-policy-objects-hide-specified-drives +#> + +#description : Hide or unhide drives in File Explorer by managing the NoDrives policy. +#execution mode: IndividualWithRestart +#tags: CSN, Windows Script, Golden Image, Explorer, Drive Visibility + +<#variables: +{ + "Action": { + "optionsSet": [ + { "label": "Hide specified drives", "value": "Hide" }, + { "label": "Unhide all drives", "value": "Unhide" } + ] + }, + "DrivesToHide": { + "description": "Comma‑separated list of drive letters to hide (e.g. C,D,E,F). Only used when Action is Hide.", + "isRequired": false, + "defaultValue": "" + } +} +#> + + +param( + [ComponentModel.DisplayName('Action')] + [Parameter(Mandatory)] + [ValidateSet('Hide','Unhide')] + [string]$Action = 'Hide', + + [ComponentModel.DisplayName('Drives to hide (Only use if Hide Option is selected)')] + [Parameter()] + [string]$DrivesToHide = '' +) + +$regPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' + +# Ensure the Explorer policy key exists +if (-not (Test-Path $regPath)) { + New-Item -Path $regPath -Force | Out-Null +} + +if ($Action -eq 'Unhide') { + if (Get-ItemProperty -Path $regPath -Name 'NoDrives' -ErrorAction SilentlyContinue) { + Remove-ItemProperty -Path $regPath -Name 'NoDrives' -ErrorAction Stop + Write-Host "Removed NoDrives entry; all drives will be visible." + } + else { + Write-Host "NoDrives entry not found; nothing to remove." + } + return +} + +# Action = Hide +if ([string]::IsNullOrWhiteSpace($DrivesToHide)) { + throw "DrivesToHide must be specified when Action is 'Hide'." +} + +# Drive bitmask map +$driveMap = @{ + A=1; B=2; C=4; D=8; E=16; F=32; G=64; H=128; + I=256; J=512; K=1024; L=2048; M=4096; N=8192; O=16384; P=32768; + Q=65536; R=131072; S=262144; T=524288; U=1048576; V=2097152; W=4194304; X=8388608; + Y=16777216; Z=33554432 +} + +# Parse & validate +$letters = $DrivesToHide.Split(',') | ForEach-Object { $_.Trim().ToUpper() } +$mask = 0 +foreach ($letter in $letters) { + if ($driveMap.ContainsKey($letter)) { + $mask += $driveMap[$letter] + } + else { + throw "Invalid drive letter specified: '$letter'" + } +} + +# Create or update the NoDrives DWORD +if (Get-ItemProperty -Path $regPath -Name 'NoDrives' -ErrorAction SilentlyContinue) { + Set-ItemProperty -Path $regPath -Name 'NoDrives' -Value $mask -Type DWord -Force + Write-Host "Updated NoDrives to $mask; hidden drives: $($letters -join ', ')." +} +else { + New-ItemProperty -Path $regPath -Name 'NoDrives' -Value $mask -PropertyType DWord -Force | Out-Null + Write-Host "Created NoDrives = $mask; hidden drives: $($letters -join ', ')." +} + +Write-Host "Please restart Explorer or reboot for changes to take effect." diff --git a/scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 b/scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 new file mode 100644 index 0000000..4a3f530 --- /dev/null +++ b/scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 @@ -0,0 +1,78 @@ +<# + Author : Markus Steigner & Cristian Schmitt Nieto + Source : https://learn.microsoft.com/azure/virtual-desktop/onedrive-remoteapp +#> + +#description: Toggle background launch of Microsoft OneDrive for Azure Virtual Desktop RemoteApp sessions +#execution mode: Individual +#tags: CSN, Microsoft, Golden Image, Remote Apps, OneDrive + +<#variables: +{ + "OneDriveBackgroundLaunch": { + "Description": "Enable or disable launching OneDrive silently in the background for RemoteApp sessions.", + "DisplayName": "OneDrive background launch", + "IsRequired": true, + "OptionsSet": [ + { "Label": "Enable", "Value": "Enable" }, + { "Label": "Disable", "Value": "Disable" } + ] + } +} +#> + + +param ( + [Parameter(Mandatory)] + [ValidateSet("Enable","Disable")] + [string]$OneDriveBackgroundLaunch +) + +# Registry paths +$tsKey = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" +$runKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" + +# Ensure the TS policy key exists +if (-not (Test-Path $tsKey)) { + New-Item -Path $tsKey -Force | Out-Null +} + +switch ($OneDriveBackgroundLaunch) { + "Enable" { + Write-Host "Enabling OneDrive background launch for RemoteApp sessions…" + + # 1) Enable enhanced shell experience + if (Get-ItemProperty -Path $tsKey -Name UseShellAppRuntimeRemoteApp -ErrorAction SilentlyContinue) { + Set-ItemProperty -Path $tsKey -Name UseShellAppRuntimeRemoteApp -PropertyType DWord -Value 1 -Force + } + else { + New-ItemProperty -Path $tsKey -Name UseShellAppRuntimeRemoteApp -PropertyType DWord -Value 1 -Force | Out-Null + } + + # 2) Add OneDrive to Run, launching in background + $oneDriveExe = Join-Path $env:ProgramFiles "Microsoft OneDrive\OneDrive.exe" + $runValue = "`"$oneDriveExe`" /background" + if (Get-ItemProperty -Path $runKey -Name OneDrive -ErrorAction SilentlyContinue) { + Set-ItemProperty -Path $runKey -Name OneDrive -PropertyType String -Value $runValue -Force + } + else { + New-ItemProperty -Path $runKey -Name OneDrive -PropertyType String -Value $runValue -Force | Out-Null + } + } + + "Disable" { + Write-Host "Disabling OneDrive background launch for RemoteApp sessions…" + + # Remove the TS shell-experience setting if present + if (Get-ItemProperty -Path $tsKey -Name UseShellAppRuntimeRemoteApp -ErrorAction SilentlyContinue) { + Remove-ItemProperty -Path $tsKey -Name UseShellAppRuntimeRemoteApp -ErrorAction SilentlyContinue + } + + # Remove the Run entry for OneDrive if present + if (Get-ItemProperty -Path $runKey -Name OneDrive -ErrorAction SilentlyContinue) { + Remove-ItemProperty -Path $runKey -Name OneDrive -ErrorAction SilentlyContinue + } + } +} + +Write-Host "Completed OneDrive background-launch configuration: $OneDriveBackgroundLaunch" \ No newline at end of file From b643b1bf8bc6a12c422481f566dc4c00d8a43c27 Mon Sep 17 00:00:00 2001 From: Cristian Schmitt Nieto <69589673+schmittnieto@users.noreply.github.com> Date: Sat, 17 May 2025 23:11:19 +0200 Subject: [PATCH 2/2] Integration of my Windows Scripts (from the repository https://github.com/schmittnieto/nerdio-scripted-actions) when they reach a production-ready state --- .../Disable Office Updates Task.ps1 | 0 .../Hide or unhide Drives in File Explorer.ps1 | 0 .../OneDrive Remote App configuration.ps1 | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename scripted-actions/{windows-scripts => custom-image-template-scripts}/Disable Office Updates Task.ps1 (100%) rename scripted-actions/{windows-scripts => custom-image-template-scripts}/Hide or unhide Drives in File Explorer.ps1 (100%) rename scripted-actions/{windows-scripts => custom-image-template-scripts}/OneDrive Remote App configuration.ps1 (100%) diff --git a/scripted-actions/windows-scripts/Disable Office Updates Task.ps1 b/scripted-actions/custom-image-template-scripts/Disable Office Updates Task.ps1 similarity index 100% rename from scripted-actions/windows-scripts/Disable Office Updates Task.ps1 rename to scripted-actions/custom-image-template-scripts/Disable Office Updates Task.ps1 diff --git a/scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 b/scripted-actions/custom-image-template-scripts/Hide or unhide Drives in File Explorer.ps1 similarity index 100% rename from scripted-actions/windows-scripts/Hide or unhide Drives in File Explorer.ps1 rename to scripted-actions/custom-image-template-scripts/Hide or unhide Drives in File Explorer.ps1 diff --git a/scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 b/scripted-actions/custom-image-template-scripts/OneDrive Remote App configuration.ps1 similarity index 100% rename from scripted-actions/windows-scripts/OneDrive Remote App configuration.ps1 rename to scripted-actions/custom-image-template-scripts/OneDrive Remote App configuration.ps1