Functions
Functions
# Install Java
Function InstallJava {
Write-Output "Installing Java"
winget install -e Oracle.JavaRuntimeEnvironment
}
# Install 7-Zip
Function Install7Zip {
Write-Output "Installing 7-Zip"
winget install -e 7zip.7zip
}
# Install Notepad ++
Function InstallNotepadplusplus {
Write-Output "Installing Notepad++"
winget install -e Notepad++.Notepad++
}
# Install MPCHC
Function InstallMediaPlayerClassic {
Write-Output "Installing Media Player Classic (VLC Alternative)"
winget install -e clsid2.mpc-hc
}
# Install VLC
Function InstallVLCMediaPlayer {
Write-Output "Installing VLC"
winget install -e VideoLAN.VLC
}
# Install Brave
Function InstallBrave {
Write-Output "Installing Brave"
winget install -e BraveSoftware.BraveBrowser
}
# Install Firefox
Function InstallFirefox {
Write-Output "Installing Firefox"
winget install -e Mozilla.Firefox
}
# Install Irfanview
Function InstallIrfanview {
Write-Output "Installing Irfanview"
winget install -e IrfanSkiljan.IrfanView
}
# Install SumatraPDF
Function InstallSumatrapdf {
Write-Output "Installing SumatraPDF"
winget install -e SumatraPDF.SumatraPDF
}
# Install AutoHotkey
Function InstallAutoHotkey {
Write-Output "Installing AutoHotkey"
winget install -e Lexikos.AutoHotkey
}
# Install Discord
Function InstallDiscord {
Write-Output "Installing Discord"
winget install -e Discord.Discord
}
# Install VS Codium
Function InstallVSCodium {
Write-Output "Installing VS Codium"
winget install -e VSCodium.VSCodium
}
#endregion Third
# Disable the Connected User Experiences and Telemetry (DiagTrack) service, and
block connection for the Unified Telemetry Client Outbound Traffic
Function DisableDiagTrackService {
Write-Output "Disabling DiagTrack Service ..."
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Enable the Connected User Experiences and Telemetry (DiagTrack) service, and
allow connection for the Unified Telemetry Client Outbound Traffic
Function EnableDiagTrackService {
Write-Output "Enabling DiagTrack Service ..."
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Do not use sign-in info to automatically finish setting up device after an update
Function DisableSigninInfo {
Write-Output "Disabling Signin Info ..."
$SID = (Get-CimInstance -ClassName Win32_UserAccount | Where-Object -
FilterScript {$_.Name -eq $env:USERNAME}).SID
if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\
CurrentVersion\Winlogon\UserARSO\$SID"))
{
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
Winlogon\UserARSO\$SID" -Force
}
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
Winlogon\UserARSO\$SID" -Name OptOut -PropertyType DWord -Value 1 -Force
}
# Hide the Windows welcome experiences after updates and occasionally when I sign
in to highlight what's new and suggested
Function HideWindowsWelcomeExperience {
Write-Output "Hiding Windows Welcome Experience ..."
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
ContentDeliveryManager -Name SubscribedContent-310093Enabled -PropertyType DWord -
Value 0 -Force
}
# Show the Windows welcome experiences after updates and occasionally when I sign
in to highlight what's new and suggested
Function ShowWindowsWelcomeExperience {
Write-Output "Showing Windows Welcome Experience ..."
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
ContentDeliveryManager -Name SubscribedContent-310093Enabled -PropertyType DWord -
Value 1 -Force
}
# Let Microsoft use your diagnostic data for personalized tips, ads, and
recommendations
Function EnableTailoredExperiences {
Write-Output "Enabling Tailored Experiences ..."
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Privacy -Name TailoredExperiencesWithDiagnosticDataEnabled -PropertyType DWord -
Value 1 -Force
}
Start-Sleep -Seconds 1
if ($Taskmgr)
{
$Taskmgr.CloseMainWindow()
}
Start-Process -FilePath Taskmgr.exe -PassThru
Start-Sleep -Seconds 3
do
{
Start-Sleep -Milliseconds 100
$Preferences = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\
Windows\CurrentVersion\TaskManager -Name Preferences
}
until ($Preferences)
$Preferences[28] = 0
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
TaskManager -Name Preferences -PropertyType Binary -Value $Preferences -Force
}
Start-Sleep -Seconds 1
if ($Taskmgr)
{
$Taskmgr.CloseMainWindow()
}
Start-Process -FilePath Taskmgr.exe -PassThru
Start-Sleep -Seconds 3
do
{
Start-Sleep -Milliseconds 100
$Preferences = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\
Windows\CurrentVersion\TaskManager -Name Preferences
}
until ($Preferences)
# Do not add the "- Shortcut" suffix to the file name of created shortcuts
Function DisableShortcutsSuffix {
Write-Output "Disabling Shortcuts Suffix ..."
if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer\NamingTemplates))
{
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer\NamingTemplates -Force
}
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer\NamingTemplates -Name ShortcutNameTemplate -PropertyType String -Value
"%s.lnk" -Force
}
# Add the "- Shortcut" suffix to the file name of created shortcuts
Function EnableShortcutsSuffix {
Write-Output "Enabling Shortcuts Suffix ..."
Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer\NamingTemplates -Name ShortcutNameTemplate -Force -ErrorAction Ignore
}
# When I grab a windows's title bar and shake it, don't minimize all other windows
Function DisableAeroShaking {
Write-Output "Disabling Aero Shaking ..."
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced -Name DisallowShaking -PropertyType DWord -Value 1 -Force
}
# When I grab a windows's title bar and shake it, minimize all other windows
Function EnableAeroShaking {
Write-Output "Enabling Aero Shaking ..."
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced -Name DisallowShaking -PropertyType DWord -Value 0 -Force
}
#region OneDrive
# Uninstall OneDrive
Function UninstallOneDrive {
Write-Output "Uninstalling OneDrive ..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" |
Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -
Name "DisableFileSyncNGSC" -Type DWord -Value 1
# Install OneDrive
Function InstallOneDrive {
Write-Output "Installing OneDrive ..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\
OneDrive" -Name "DisableFileSyncNGSC" -ErrorAction SilentlyContinue
& "$env:SystemRoot\SysWOW64\OneDriveSetup.exe"
}
#endregion OneDrive
#region System
# Disable hibernation
Function DisableHibernation {
Write-Output "Disabling Hibernation ..."
POWERCFG /HIBERNATE OFF
}
# Enable hibernation
Function EnableHibernation {
Write-Output "Enabling Hibernation ..."
POWERCFG /HIBERNATE ON
}
# Turn on access to mapped drives from app running with elevated permissions with
Admin Approval Mode enabled
Function EnableMappedDrivesAppElevatedAccess {
Write-Output "Enabling Mapped Drives App Elevated Access ..."
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force
}
# Turn off access to mapped drives from app running with elevated permissions with
Admin Approval Mode enabled
Function DisableMappedDrivesAppElevatedAccess {
Write-Output "Disabling Mapped Drives App Elevated Access ..."
Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore
}
# Always wait for the network at computer startup and logon for workgroup networks
Function EnableWaitNetworkStartup {
Write-Output "Enabling Wait Network Startup ..."
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $true)
{
if (-not (Test-Path -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows
NT\CurrentVersion\Winlogon"))
{
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\
CurrentVersion\Winlogon" -Force
}
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\
CurrentVersion\Winlogon" -Name SyncForegroundPolicy -PropertyType DWord -Value 1 -
Force
}
}
# Never wait for the network at computer startup and logon for workgroup networks
Function DisableWaitNetworkStartup {
Write-Output "Disabling Wait Network Startup ..."
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $true)
{
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows
NT\CurrentVersion\Winlogon" -Name SyncForegroundPolicy -Force -ErrorAction Ignore
}
}
# Do not use the latest installed .NET runtime for all apps
Function DisableLatestInstalledNET {
Write-Output "Disabling Latest Installed .NET ..."
Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name
OnlyUseLatestCLR -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework
-Name OnlyUseLatestCLR -Force -ErrorAction Ignore
}
# Do not allow the computer to turn off the network adapters to save power
Function DisableNetworkAdaptersSavePower {
Write-Output "Disabling Network Adapters Save Power ..."
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-
Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
foreach ($Adapter in $Adapters)
{
$Adapter.AllowComputerToTurnOffDevice = "Disabled"
$Adapter | Set-NetAdapterPowerManagement
}
}
# Allow the computer to turn off the network adapters to save power
Function EnableNetworkAdaptersSavePower {
Write-Output "Enabling Network Adapters Save Power ..."
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-
Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
foreach ($Adapter in $Adapters)
{
$Adapter.AllowComputerToTurnOffDevice = "Enabled"
$Adapter | Set-NetAdapterPowerManagement
}
}
# Disable and delete reserved storage after the next update installation
Function DisableReservedStorage {
Write-Output "Disabling Reserved Storage ..."
try
{
Set-WindowsReservedStorageState -State Disabled
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Error -Message ($Localization.ReservedStorageIsInUse -f
$MyInvocation.Line) -ErrorAction SilentlyContinue
}
}
# Turn off pressing the Shift key 5 times to turn Sticky keys
Function DisableStickyShift {
Write-Output "Disabling Sticky Shift ..."
New-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name
Flags -PropertyType String -Value 506 -Force
}
# Automatically saving my restartable apps and restart them when I sign back in
Function EnableSaveRestartableApps {
Write-Output "Enabling Save Restartable Apps ..."
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
Winlogon" -Name RestartApps -Value 1 -Force
}
# Turn off automatically saving my restartable apps and restart them when I sign
back in
Function DisableSaveRestartableApps {
Write-Output "Disabling Save Restartable Apps ..."
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
Winlogon" -Name RestartApps -Value 0 -Force
}
# Enable "Network Discovery" and "File and Printers Sharing" for workgroup networks
Function EnableNetworkDiscovery {
Write-Output "Enabling Network Discovery ..."
$FirewallRules = @(
# File and printer sharing
"@FirewallAPI.dll,-32752",
# Network discovery
"@FirewallAPI.dll,-28502"
)
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
{
Set-NetFirewallRule -Group $FirewallRules -Profile Private -Enabled
True
Set-NetFirewallRule -Profile Public, Private -Name FPS-SMB-In-TCP -
Enabled True
Set-NetConnectionProfile -NetworkCategory Private
}
}
# Disable "Network Discovery" and "File and Printers Sharing" for workgroup
networks
Function DisableNetworkDiscovery {
Write-Output "Disabling Network Discovery ..."
$FirewallRules = @(
# File and printer sharing
"@FirewallAPI.dll,-32752",
# Network discovery
"@FirewallAPI.dll,-28502"
)
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
{
Set-NetFirewallRule -Group $FirewallRules -Profile Private -Enabled
False
}
}
# Automatically adjust active hours for me based on daily usage
Function AutomaticallyActiveHours {
Write-Output "Setting Automatically Active Hours ..."
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -
Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
}
# Set Windows Terminal Preview as default terminal app to host the user interface
for command-line applications
Function WindowsTerminalDefaultTerminalApp {
Write-Output "Setting Windows Terminal Default Terminal App ..."
if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
{
# Checking if the Terminal version supports such feature
$TerminalVersion = (Get-AppxPackage -Name
Microsoft.WindowsTerminal).Version
if ([System.Version]$TerminalVersion -ge [System.Version]"1.11")
{
if (-not (Test-Path -Path "HKCU:\Console\%%Startup"))
{
New-Item -Path "HKCU:\Console\%%Startup" -Force
}
# Set Windows Console Host as default terminal app to host the user interface for
command-line applications
Function ConsoleHostDefaultTerminalApp {
Write-Output "Setting Console Host Default Terminal App ..."
New-ItemProperty -Path "HKCU:\Console\%%Startup" -Name DelegationConsole -
PropertyType String -Value "{00000000-0000-0000-0000-000000000000}" -Force
New-ItemProperty -Path "HKCU:\Console\%%Startup" -Name DelegationTerminal -
PropertyType String -Value "{00000000-0000-0000-0000-000000000000}" -Force
}
#endregion System
# Run the Windows PowerShell shortcut from the Start menu as Administrator
Function ElevatedRunPowerShellShortcut {
Write-Output "Setting Elevated Run PowerShell Shortcut ..."
[byte[]]$bytes = Get-Content -Path "$env:APPDATA\Microsoft\Windows\Start
Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Encoding Byte -Raw
$bytes[0x15] = $bytes[0x15] -bor 0x20
Set-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows
PowerShell\Windows PowerShell.lnk" -Value $bytes -Encoding Byte -Force
}
# Run the Windows PowerShell shortcut from the Start menu as user
Function NonElevatedRunPowerShellShortcut {
Write-Output "Setting NonElevated Run PowerShell Shortcut ..."
[byte[]]$bytes = Get-Content -Path "$env:APPDATA\Microsoft\Windows\Start
Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Encoding Byte -Raw
$bytes[0x15] = $bytes[0x15] -bxor 0x20
Set-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows
PowerShell\Windows PowerShell.lnk" -Value $bytes -Encoding Byte -Force
}
#region Gaming
#endregion Gaming
# Create the "Process Creation" Event Viewer сustom view to log the executed
processes and their arguments
Function EnableEventViewerCustomView {
Write-Output "Enable Event Viewer Custom View ..."
# Enable events auditing generated when a process is created (starts)
auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}"
/success:enable /failure:enable
$XML = @"
<ViewerConfig>
<QueryConfig>
<QueryParams>
<UserQuery />
</QueryParams>
<QueryNode>
<Name>$($Localization.EventViewerCustomViewName)</Name>
<Description>$($Localization.EventViewerCustomViewDescription)</Description>
<QueryList>
<Query Id="0" Path="Security">
<Select
Path="Security">*[System[(EventID=4688)]]</Select>
</Query>
</QueryList>
</QueryNode>
</QueryConfig>
</ViewerConfig>
"@
# Enable logging for all PowerShell scripts input to the Windows PowerShell event
log
Function EnablePowerShellScriptsLogging {
Write-Output "Enabling PowerShell Scripts Logging ..."
if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\
PowerShell\ScriptBlockLogging))
{
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\
ScriptBlockLogging -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\
ScriptBlockLogging -Name EnableScriptBlockLogging -PropertyType DWord -Value 1 -
Force
}
# Disable logging for all PowerShell scripts input to the Windows PowerShell event
log
Function DisablePowerShellScriptsLogging {
Write-Output "Disabling PowerShell Scripts Logging ..."
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\
PowerShell\ScriptBlockLogging -Name EnableScriptBlockLogging -Force -ErrorAction
Ignore
}
# Microsoft Defender SmartScreen doesn't marks downloaded files from the Internet
as unsafe
Function DisableSaveZoneInformation {
Write-Output "Disabling Save Zone Information ..."
if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\Attachments))
{
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\Attachments -Force
}
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\Attachments -Name SaveZoneInformation -PropertyType DWord -Value 1 -Force
}
# Microsoft Defender SmartScreen marks downloaded files from the Internet as unsafe
Function EnableSaveZoneInformation {
Write-Output "Enabling Save Zone Information ..."
Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\Attachments -Name SaveZoneInformation -Force -ErrorAction Ignore
}
# Show the "Extract all" item in the Windows Installer (.msi) context menu
Function ShowMSIExtractContext {
Write-Output "Showing MSI Extract Context ..."
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\
Extract\Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract\
Command -Force
}
$Value = "{0}" -f "msiexec.exe /a `"%1`" /qb TARGETDIR=`"%1 extracted`""
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract\
Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract
-Name MUIVerb -PropertyType String -Value "@shell32.dll,-37514" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract
-Name Icon -PropertyType String -Value "shell32.dll,-16817" -Force
}
# Hide the "Extract all" item from the Windows Installer (.msi) context menu
Function HideMSIExtractContext {
Write-Output "Hiding MSI Extract Context ..."
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract -
Recurse -Force -ErrorAction Ignore
}
# Show the "Install" item in the Cabinet (.cab) filenames extensions context menu
Function ShowCABInstallContext {
Write-Output "Showing CAB Install Context ..."
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\
Command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\
Command -Force
}
$Value = "{0}" -f "cmd /c DISM.exe /Online /Add-Package
/PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\
Command -Name "(default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -
Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -
Name HasLUAShield -PropertyType String -Value "" -Force
}
# Hide the "Install" item from the Cabinet (.cab) filenames extensions context menu
Function HideCABInstallContext {
Write-Output "Hiding CAB Install Context ..."
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Recurse
-Force -ErrorAction Ignore
}
# Show the "Run as different user" item in the .exe filename extensions context
menu
Function ShowRunAsDifferentUserContext {
Write-Output "Showing Run As Different User Context ..."
Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\exefile\shell\runasuser
-Name Extended -Force -ErrorAction Ignore
}
# Hide the "Run as different user" item from the .exe filename extensions context
menu
Function HideRunAsDifferentUserContext {
Write-Output "Hiding Run As Different User Context ..."
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\exefile\shell\runasuser -
Name Extended -PropertyType String -Value "" -Force
}
# Hide the "Cast to Device" item from the media files and folders context menu
Function HideCastToDeviceContext {
Write-Output "Hiding Cast To Device Context ..."
if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Shell Extensions\Blocked"))
{
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell
Extensions\Blocked" -Force
}
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell
Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType
String -Value "Play to menu" -Force
}
# Show the "Cast to Device" item in the media files and folders context menu
Function ShowCastToDeviceContext {
Write-Output "Showing Cast To Device Context ..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -
ErrorAction Ignore
}
# Hide the "Edit with Photos" item from the media files context men
Function HideEditWithPhotosContext {
Write-Output "Hiding Edit With Photos Context ..."
if (Get-AppxPackage -Name Microsoft.Windows.Photos)
{
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\
AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -
PropertyType String -Value "" -Force
}
}
# Show the "Edit with Photos" item in the media files context menu
Function ShowEditWithPhotosContext {
Write-Output "Showing Edit With Photos Context ..."
if (Get-AppxPackage -Name Microsoft.Windows.Photos)
{
Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\
AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -
Force -ErrorAction Ignore
}
}
# Hide the "Create a new video" item from the media files context menu
Function HideCreateANewVideoContext {
Write-Output "Hiding Create A New Video Context ..."
if (Get-AppxPackage -Name Microsoft.Windows.Photos)
{
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\
AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name
ProgrammaticAccessOnly -PropertyType String -Value "" -Force
}
}
# Show the "Create a new video" item in the media files context menu
Function ShowCreateANewVideoContext {
Write-Output "Showing Create A New Video Context ..."
if (Get-AppxPackage -Name Microsoft.Windows.Photos)
{
Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\
AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name
ProgrammaticAccessOnly -Force -ErrorAction Ignore
}
}
# Hide the "Print" item from the .bat and .cmd context menu
Function HidePrintCMDContext {
Write-Output "Hiding Print CMD Context ..."
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\batfile\shell\print -Name
ProgrammaticAccessOnly -PropertyType String -Value "" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\cmdfile\shell\print -Name
ProgrammaticAccessOnly -PropertyType String -Value "" -Force
}
# Show the "Print" item in the .bat and .cmd context menu
Function ShowPrintCMDContext {
Write-Output "Showing Print CMD Context ..."
Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\batfile\shell\print -
Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\cmdfile\shell\print -
Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
}
# Hide the "Include in Library" item from the folders and drives context menu
Function HideIncludeInLibraryContext {
Write-Output "Hiding Include In Library Context ..."
New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Folder\ShellEx\
ContextMenuHandlers\Library Location" -Name "(default)" -PropertyType String -Value
"-{3dad6c5d-2167-4cae-9914-f99e41c12cfa}" -Force
}
# Show the "Include in Library" item in the folders and drives context menu
Function ShowIncludeInLibraryContext {
Write-Output "Showing Include In Library Context ..."
New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Folder\ShellEx\
ContextMenuHandlers\Library Location" -Name "(default)" -PropertyType String -Value
"{3dad6c5d-2167-4cae-9914-f99e41c12cfa}" -Force
}
# Hide the "Send to" item from the folders context menu
Function HideSendToContext {
Write-Output "Hiding Send To Context ..."
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\
shellex\ContextMenuHandlers\SendTo -Name "(default)" -PropertyType String -Value "-
{7BA4C740-9E81-11CF-99D3-00AA004AE837}" -Force
}
# Hide the "Turn on BitLocker" item from the drives context menu
Function HideBitLockerContext {
Write-Output "Hiding BitLocker Context ..."
if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq
"Professional") -or ($_.Edition -like "Enterprise*")})
{
if ((Get-BitLockerVolume).ProtectionStatus -eq "Off")
{
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Drive\shell\
encrypt-bde-elev -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
}
}
}
# Hide the "Compressed (zipped) Folder" item from the "New" context menu
Function HideCompressedFolderNewContext {
Write-Output "Hiding Compressed Folder New Context ..."
Remove-Item -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew
-Force -ErrorAction Ignore
}
# Show the "Compressed (zipped) Folder" item to the "New" context menu
Function ShowCompressedFolderNewContext {
Write-Output "Showing Compressed Folder New Context ..."
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\
ShellNew))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\
ShellNew -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\
ShellNew -Name Data -PropertyType Binary -Value ([byte[]]
(80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)) -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\
ShellNew -Name ItemName -PropertyType ExpandString -Value "@%SystemRoot%\system32\
zipfldr.dll,-10194" -Force
}
# Enable the "Open", "Print", and "Edit" items if more than 15 files selected
Function EnableMultipleInvokeContext {
Write-Output "Enabling Multiple Invoke Context ..."
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer -Name MultipleInvokePromptMinimum -PropertyType DWord -Value 300 -Force
}
# Disable the "Open", "Print", and "Edit" items if more than 15 files selected
Function DisableMultipleInvokeContext {
Write-Output "Disabling Multiple Invoke Context ..."
Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Explorer -Name MultipleInvokePromptMinimum -Force -ErrorAction Ignore
}
# Hide the "Look for an app in the Microsoft Store" item in the "Open with" dialog
Function HideUseStoreOpenWith {
Write-Output "Hiding Use Store Open With ..."
if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\
Explorer))
{
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -
Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -
Name NoUseStoreOpenWith -PropertyType DWord -Value 1 -Force
}
# Show the "Look for an app in the Microsoft Store" item in the "Open with" dialog
Function ShowUseStoreOpenWith {
Write-Output "Showing Use Store Open With ..."
Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer
-Name NoUseStoreOpenWith -Force -ErrorAction Ignore
}
# Hide the "Open in Windows Terminal" menu option in the folders context menu
Function HideOpenWindowsTerminalContext {
Write-Output "Hiding Open Windows Terminal Context ..."
if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
{
if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\
CurrentVersion\Shell Extensions\Blocked"))
{
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\
Shell Extensions\Blocked" -Force
}
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\
CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-
901F640F5155}" -PropertyType String -Value "WindowsTerminal" -Force
}
}
# Show the "Open in Windows Terminal" menu option in the folders context menu
Function ShowOpenWindowsTerminalContext {
Write-Output "Showing Open Windows Terminal Context ..."
if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
{
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\
CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-
901F640F5155}" -Force -ErrorAction Ignore
}
}
# Hide the "Open in Windows Terminal (Admin)" item from the Desktop and folders
context menu
Function HideOpenWindowsTerminalAdminContext {
Write-Output "Hiding Open Windows Terminal Context ..."
$Items = @(
"Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas",
"Registry::HKEY_CLASSES_ROOT\Directory\shell\runas"
)
Remove-Item -Path $Items -Recurse -Force -ErrorAction Ignore
}
# Show the "Open in Windows Terminal (Admin)" item in the Desktop and folders
context menu
Function ShowOpenWindowsTerminalAdminContext {
Write-Output "Showing Open Windows Terminal Context ..."
if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
{
# Show the option in the Desktop context menu
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\Directory\
Background\shell\runas\command))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\
shell\runas\command -ItemType Directory -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\
Background\shell\runas -Name "(default)" -PropertyType String -Value
$Localization.OpenInWindowsTerminalAdmin -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\
Background\shell\runas -Name Icon -PropertyType String -Value "imageres.dll,73" -
Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\
Background\shell\runas -Name NoWorkingDirectory -PropertyType String -Value "" -
Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\
Background\shell\runas\command -Name "(default)" -PropertyType String -Value
"wt.exe -d ""%V""" -Force
#region Other
#endregion Other