cschneegans / unattend-generator

.NET Core library to create highly customized autounattend.xml files
https://schneegans.de/windows/unattend-generator/
MIT License
542 stars 43 forks source link

REQUEST - Install programs #80

Closed kendi182 closed 1 day ago

kendi182 commented 4 days ago

Hello, is there any field where I can install programs silently, such as Chrome, Adobe Reader, K-Lite, among others?

If I have a complete link to download the files, would this be possible?

cschneegans commented 3 days ago

Certainly. For example, this is how I install Google Chrome with a custom .ps1 script in the Scripts to run in the system context, before user accounts are created section:

$file = "$env:TEMP\ChromeSetup.exe";
$uri = 'https://dl.google.com/chrome/install/chrome_installer.exe';
[System.Net.WebClient]::new().DownloadFile( $uri, $file );
Start-Process -FilePath $file -ArgumentList '/silent /install' -Wait;

This link will configure the form accordingly.

The system context is the natural phase to install software, but some installers expect user accounts to be present, and hence you need to call such installers from a custom script in the Scripts to run when the first user logs on after Windows has been installed section.

Some users prefer winget to install software. I have no experience with winget, but this script seems to do the job:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
winget install -e --accept-package-agreements --accept-source-agreements Google.Chrome

This link will configure the form accordingly.

Reptaiin commented 3 days ago

Thank you so much for the examples, I was looking for a way to do this. Winget seems better suited for a future picker where the generator can offer a way to install programs using sites like https://winstall.app/, see my example:

Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
winget install -e --accept-package-agreements --accept-source-agreements abbodi1406.vcredist Microsoft.DirectX Google.Chrome.Dev 7zip.7zip Valve.Steam ente-io.auth-desktop 64Gram.64Gram VideoLAN.VLC GIMP.GIMP.Nightly smartfrigde.Legcord Roblox.Roblox
winget install -e --accept-package-agreements --accept-source-agreements 9N0866FS04W8 9NBLGGH516XP 9NMPJ99VJBWV -s msstore 
jayphizzle commented 3 days ago

I would like to take the chance to jump in this topic.

How can i access/ handle files which are located on the same USB Stick as the windows iso an unattended.xml ? For example to install Programms which are not available for download or to copy custom configuration files?

thx

cschneegans commented 3 days ago

How can i access/ handle files which are located on the same USB Stick as the windows iso an unattended.xml ?

I assume that your question is about how to reliably determine its drive letter. In a .ps1 custom script, you can easily iterate over all drives and test if there is an autounattend.xml file in the root directory, like so:

foreach( $drive in [System.IO.DriveInfo]::GetDrives() ) {
    if( Join-Path -Path $drive.RootDirectory -ChildPath 'autounattend.xml' | Test-Path ) {
        # Do something with $drive...
    }
}

For example, VMwareTools.ps1 uses a very similar method.

Furthermore, I have recently added a constant volume label unattend_iso to the .iso file generated by the the Download .iso file button, so you can also test for that volume label:

foreach( $drive in [System.IO.DriveInfo]::GetDrives() ) {
    if( $drive.VolumeLabel -eq 'unattend_iso' ) {
        # Do something with $drive...
    }
}
kendi182 commented 3 days ago

Certainly. For example, this is how I install Google Chrome with a custom .ps1 script in the Scripts to run in the system context, before user accounts are created section:

$file = "$env:TEMP\ChromeSetup.exe";
$uri = 'https://dl.google.com/chrome/install/chrome_installer.exe';
[System.Net.WebClient]::new().DownloadFile( $uri, $file );
Start-Process -FilePath $file -ArgumentList '/silent /install' -Wait;

This link will configure the form accordingly.

The system context is the natural phase to install software, but some installers expect user accounts to be present, and hence you need to call such installers from a custom script in the Scripts to run when the first user logs on after Windows has been installed section.

Some users prefer winget to install software. I have no experience with winget, but this script seems to do the job:

Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
winget install -e --accept-package-agreements --accept-source-agreements Google.Chrome

This link will configure the form accordingly.

hello, I tested both solutions you gave me and neither worked. Follow the xml that I originally use without the program installation commands.

``` pt-BR 0416:00010416 pt-BR pt-BR pt-BR true 00000-00000-00000-00000-00000 true 1 reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassTPMCheck /t REG_DWORD /d 1 /f 2 reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassSecureBootCheck /t REG_DWORD /d 1 /f 3 reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassRAMCheck /t REG_DWORD /d 1 /f TEMPNAME 1 powershell.exe -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;" 2 powershell.exe -NoProfile -Command "& { Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\GetComputerName.ps1' -Raw | Invoke-Expression > C:\Windows\Setup\Scripts\ComputerName.txt; } *>&1 >> 'C:\Windows\Setup\Scripts\GetComputerName.log';" 3 cmd.exe /c start /MIN powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\SetComputerName.ps1' -Raw | Invoke-Expression;" 4 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v BypassNRO /t REG_DWORD /d 1 /f 5 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 6 reg.exe add "HKU\DefaultUser\Software\Policies\Microsoft\Windows\WindowsCopilot" /v TurnOffWindowsCopilot /t REG_DWORD /d 1 /f 7 reg.exe unload "HKU\DefaultUser" 8 reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate" /f 9 cmd.exe /c "del "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"" 10 cmd.exe /c "del "C:\Windows\System32\OneDriveSetup.exe"" 11 cmd.exe /c "del "C:\Windows\SysWOW64\OneDriveSetup.exe"" 12 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 13 reg.exe delete "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f 14 reg.exe unload "HKU\DefaultUser" 15 reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate" /f 16 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f 17 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-packages.ps1' -Raw | Invoke-Expression;" 18 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-caps.ps1' -Raw | Invoke-Expression;" 19 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-features.ps1' -Raw | Invoke-Expression;" 20 net.exe accounts /maxpwage:UNLIMITED 21 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 22 reg.exe add "HKU\DefaultUser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d 0 /f 23 reg.exe unload "HKU\DefaultUser" 24 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\ShowAllTrayIcons.ps1' -Raw | Invoke-Expression;" 25 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 26 reg.exe add "HKU\DefaultUser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowTaskViewButton /t REG_DWORD /d 0 /f 27 reg.exe unload "HKU\DefaultUser" 28 reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v VerifiedAndReputablePolicyState /t REG_DWORD /d 0 /f 29 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /v SmartScreenEnabled /t REG_SZ /d "Off" /f 30 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WTDS\Components" /v ServiceEnabled /t REG_DWORD /d 0 /f 31 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WTDS\Components" /v NotifyMalicious /t REG_DWORD /d 0 /f 32 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WTDS\Components" /v NotifyPasswordReuse /t REG_DWORD /d 0 /f 33 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WTDS\Components" /v NotifyUnsafeApp /t REG_DWORD /d 0 /f 34 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 35 reg.exe add "HKU\DefaultUser\Software\Microsoft\Edge\SmartScreenEnabled" /ve /t REG_DWORD /d 0 /f 36 reg.exe add "HKU\DefaultUser\Software\Microsoft\Edge\SmartScreenPuaEnabled" /ve /t REG_DWORD /d 0 /f 37 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\AppHost" /v EnableWebContentEvaluation /t REG_DWORD /d 0 /f 38 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\AppHost" /v PreventOverride /t REG_DWORD /d 0 /f 39 reg.exe unload "HKU\DefaultUser" 40 reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f 41 reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f 42 icacls.exe C:\ /remove:g "*S-1-5-11" 43 powershell.exe -NoProfile -Command "Set-ExecutionPolicy -Scope 'LocalMachine' -ExecutionPolicy 'RemoteSigned' -Force;" 44 fsutil.exe behavior set disableLastAccess 1 45 reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v AUOptions /t REG_DWORD /d 4 /f 46 reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f 47 reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f 48 reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Dsh" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f 49 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 50 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "ContentDeliveryAllowed" /t REG_DWORD /d 0 /f 51 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "FeatureManagementEnabled" /t REG_DWORD /d 0 /f 52 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "OEMPreInstalledAppsEnabled" /t REG_DWORD /d 0 /f 53 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEnabled" /t REG_DWORD /d 0 /f 54 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEverEnabled" /t REG_DWORD /d 0 /f 55 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d 0 /f 56 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SoftLandingEnabled" /t REG_DWORD /d 0 /f 57 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContentEnabled" /t REG_DWORD /d 0 /f 58 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d 0 /f 59 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338387Enabled" /t REG_DWORD /d 0 /f 60 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d 0 /f 61 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338389Enabled" /t REG_DWORD /d 0 /f 62 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d 0 /f 63 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-353698Enabled" /t REG_DWORD /d 0 /f 64 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d 0 /f 65 reg.exe unload "HKU\DefaultUser" 66 reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d 0 /f 67 reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\BitLocker" /v "PreventDeviceEncryption" /t REG_DWORD /d 1 /f 68 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 69 reg.exe add "HKU\DefaultUser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarAl /t REG_DWORD /d 0 /f 70 reg.exe unload "HKU\DefaultUser" 71 reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Edge" /v HideFirstRunExperience /t REG_DWORD /d 1 /f 72 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 73 reg.exe add "HKU\.DEFAULT\Control Panel\Keyboard" /v InitialKeyboardIndicators /t REG_SZ /d "2" /f 74 reg.exe add "HKU\DefaultUser\Control Panel\Keyboard" /v InitialKeyboardIndicators /t REG_SZ /d "2" /f 75 reg.exe unload "HKU\DefaultUser" 76 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\MakeEdgeUninstallable.ps1' -Raw | Invoke-Expression;" 77 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\SetStartPins.ps1' -Raw | Invoke-Expression;" 78 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 79 reg.exe add "HKU\DefaultUser\SOFTWARE\Microsoft\Windows\DWM" /v ColorPrevalence /t REG_DWORD /d 0 /f 80 reg.exe unload "HKU\DefaultUser" 81 cmd.exe /c "powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\unattend-01.ps1' -Raw | Invoke-Expression;" >>"C:\Windows\Setup\Scripts\unattend-01.log" 2>&1" 82 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 83 reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "UnattendedSetup" /t REG_SZ /d "powershell.exe -NoProfile -Command \"Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\UserOnce.ps1' -Raw | Invoke-Expression;\"" /f 84 reg.exe unload "HKU\DefaultUser" 0416:00010416 pt-BR pt-BR pt-BR 3 true false true 1 cmd.exe /c "powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\unattend-02.ps1' -Raw | Invoke-Expression;" >>"C:\Windows\Setup\Scripts\unattend-02.log" 2>&1" param( [xml] $Document ); $scriptsDir = 'C:\Windows\Setup\Scripts\'; foreach( $file in $Document.unattend.Extensions.File ) { $path = [System.Environment]::ExpandEnvironmentVariables( $file.GetAttribute( 'path' ) ); if( $path.StartsWith( $scriptsDir ) ) { mkdir -Path $scriptsDir -ErrorAction 'SilentlyContinue'; } $encoding = switch( [System.IO.Path]::GetExtension( $path ) ) { { $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; } { $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); } default { [System.Text.Encoding]::Default; } }; [System.IO.File]::WriteAllBytes( $path, ( $encoding.GetPreamble() + $encoding.GetBytes( $file.InnerText.Trim() ) ) ); } $UUID = (Get-CimInstance Win32_ComputerSystemProduct).UUID -replace '[^A-F0-9]', '' $systemType = (Get-CimInstance Win32_ComputerSystem).PCSystemType $prefix = if ($systemType -eq 1) { 'D-' } elseif ($systemType -eq 2) { 'N-' } else { 'U-' } return $prefix + $UUID.Substring(0, 8) $newName = Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\ComputerName.txt' -Raw; $ErrorActionPreference = 'Stop'; Set-StrictMode -Version 'Latest'; & { $newName = $newName.Trim(); if( [string]::IsNullOrWhitespace( $newName ) ) { throw "No computer name was provided."; } $keys = @( @{ LiteralPath = 'Registry::HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName'; Name = 'ComputerName'; }; @{ LiteralPath = 'Registry::HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'; Name = 'Hostname'; }; @{ LiteralPath = 'Registry::HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'; Name = 'NV Hostname'; }; ); while( $true ) { foreach( $key in $keys ) { Set-ItemProperty @key -Type 'String' -Value $newName; } Start-Sleep -Milliseconds 50; } } *>&1 >> 'C:\Windows\Setup\Scripts\SetComputerName.log'; $selectors = @( 'Microsoft.Microsoft3DViewer'; 'Microsoft.BingSearch'; 'Microsoft.WindowsCamera'; 'Clipchamp.Clipchamp'; 'Microsoft.WindowsAlarms'; 'Microsoft.549981C3F5F10'; 'Microsoft.Windows.DevHome'; 'MicrosoftCorporationII.MicrosoftFamily'; 'Microsoft.WindowsFeedbackHub'; 'Microsoft.GetHelp'; 'Microsoft.Getstarted'; 'microsoft.windowscommunicationsapps'; 'Microsoft.WindowsMaps'; 'Microsoft.MixedReality.Portal'; 'Microsoft.BingNews'; 'Microsoft.MicrosoftOfficeHub'; 'Microsoft.Office.OneNote'; 'Microsoft.OutlookForWindows'; 'Microsoft.MSPaint'; 'Microsoft.People'; 'Microsoft.Windows.Photos'; 'Microsoft.PowerAutomateDesktop'; 'MicrosoftCorporationII.QuickAssist'; 'Microsoft.SkypeApp'; 'Microsoft.MicrosoftSolitaireCollection'; 'Microsoft.MicrosoftStickyNotes'; 'MicrosoftTeams'; 'MSTeams'; 'Microsoft.Todos'; 'Microsoft.WindowsSoundRecorder'; 'Microsoft.Wallet'; 'Microsoft.BingWeather'; 'Microsoft.WindowsTerminal'; 'Microsoft.Xbox.TCUI'; 'Microsoft.XboxApp'; 'Microsoft.XboxGameOverlay'; 'Microsoft.XboxGamingOverlay'; 'Microsoft.XboxIdentityProvider'; 'Microsoft.XboxSpeechToTextOverlay'; 'Microsoft.GamingApp'; 'Microsoft.YourPhone'; 'Microsoft.ZuneMusic'; 'Microsoft.ZuneVideo'; ); $getCommand = { Get-AppxProvisionedPackage -Online; }; $filterCommand = { $_.DisplayName -eq $selector; }; $removeCommand = { [CmdletBinding()] param( [Parameter( Mandatory, ValueFromPipeline )] $InputObject ); process { $InputObject | Remove-AppxProvisionedPackage -AllUsers -Online -ErrorAction 'Continue'; } }; $type = 'Package'; $logfile = 'C:\Windows\Temp\remove-packages.log'; & { $installed = & $getCommand; foreach( $selector in $selectors ) { $result = [ordered] @{ Selector = $selector; }; $found = $installed | Where-Object -FilterScript $filterCommand; if( $found ) { $result.Output = $found | & $removeCommand; if( $? ) { $result.Message = "$type removed."; } else { $result.Message = "$type not removed."; $result.Error = $Error[0]; } } else { $result.Message = "$type not installed."; } $result | ConvertTo-Json -Depth 3 -Compress; } } *>&1 >> $logfile; $selectors = @( 'Browser.InternetExplorer'; 'MathRecognizer'; 'OpenSSH.Client'; 'Microsoft.Windows.PowerShell.ISE'; 'App.Support.QuickAssist'; 'App.StepsRecorder'; 'Media.WindowsMediaPlayer'; 'Microsoft.Windows.WordPad'; ); $getCommand = { Get-WindowsCapability -Online; }; $filterCommand = { ($_.Name -split '~')[0] -eq $selector; }; $removeCommand = { [CmdletBinding()] param( [Parameter( Mandatory, ValueFromPipeline )] $InputObject ); process { $InputObject | Remove-WindowsCapability -Online -ErrorAction 'Continue'; } }; $type = 'Capability'; $logfile = 'C:\Windows\Temp\remove-caps.log'; & { $installed = & $getCommand; foreach( $selector in $selectors ) { $result = [ordered] @{ Selector = $selector; }; $found = $installed | Where-Object -FilterScript $filterCommand; if( $found ) { $result.Output = $found | & $removeCommand; if( $? ) { $result.Message = "$type removed."; } else { $result.Message = "$type not removed."; $result.Error = $Error[0]; } } else { $result.Message = "$type not installed."; } $result | ConvertTo-Json -Depth 3 -Compress; } } *>&1 >> $logfile; $selectors = @( 'Microsoft-RemoteDesktopConnection'; 'Recall'; ); $getCommand = { Get-WindowsOptionalFeature -Online; }; $filterCommand = { $_.FeatureName -eq $selector; }; $removeCommand = { [CmdletBinding()] param( [Parameter( Mandatory, ValueFromPipeline )] $InputObject ); process { $InputObject | Disable-WindowsOptionalFeature -Online -Remove -NoRestart -ErrorAction 'Continue'; } }; $type = 'Feature'; $logfile = 'C:\Windows\Temp\remove-features.log'; & { $installed = & $getCommand; foreach( $selector in $selectors ) { $result = [ordered] @{ Selector = $selector; }; $found = $installed | Where-Object -FilterScript $filterCommand; if( $found ) { $result.Output = $found | & $removeCommand; if( $? ) { $result.Message = "$type removed."; } else { $result.Message = "$type not removed."; $result.Error = $Error[0]; } } else { $result.Message = "$type not installed."; } $result | ConvertTo-Json -Depth 3 -Compress; } } *>&1 >> $logfile; if( [System.Environment]::OSVersion.Version.Build -lt 20000 ) { # Windows 10 reg.exe load 'HKU\DefaultUser' 'C:\Users\Default\NTUSER.DAT'; Set-ItemProperty -LiteralPath 'Registry::HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Explorer' -Name 'EnableAutoTray' -Type 'DWord' -Value 0 -Force; reg.exe unload 'HKU\DefaultUser'; } else { # Windows 11 Register-ScheduledTask -TaskName 'ShowAllTrayIcons' -Xml $( Get-Content -LiteralPath "C:\Windows\Setup\Scripts\ShowAllTrayIcons.xml" -Raw; ); } <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <Triggers> <LogonTrigger> <Repetition> <Interval>PT1M</Interval> <StopAtDurationEnd>false</StopAtDurationEnd> </Repetition> <Enabled>true</Enabled> </LogonTrigger> </Triggers> <Principals> <Principal id="Author"> <GroupId>S-1-5-32-545</GroupId> <RunLevel>LeastPrivilege</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT72H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\Windows\System32\wscript.exe</Command> <Arguments>C:\Windows\Setup\Scripts\ShowAllTrayIcons.vbs</Arguments> </Exec> </Actions> </Task> HKCU = &H80000001 key = "Control Panel\NotifyIconSettings" Set reg = GetObject("winmgmts://./root/default:StdRegProv") If reg.EnumKey(HKCU, key, names) = 0 Then If Not IsNull(names) Then For Each name In names reg.SetDWORDValue HKCU, key + "\" + name, "IsPromoted", 1 Next End If End If Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband' -Name '*'; $ErrorActionPreference = 'Stop'; & { try { $params = @{ LiteralPath = 'C:\Windows\System32\IntegratedServicesRegionPolicySet.json'; Encoding = 'Utf8'; }; $o = Get-Content @params | ConvertFrom-Json; $o.policies | ForEach-Object -Process { if( $_.guid -eq '{1bca278a-5d11-4acf-ad2f-f9ab6d7f93a6}' ) { $_.defaultState = 'enabled'; } }; $o | ConvertTo-Json -Depth 9 | Out-File @params; } catch { $_; } } *>&1 >> 'C:\Windows\Setup\Scripts\MakeEdgeUninstallable.log'; $json = '{"pinnedList":[]}'; if( [System.Environment]::OSVersion.Version.Build -lt 20000 ) { return; } $key = 'Registry::HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start'; New-Item -Path $key -ItemType 'Directory' -ErrorAction 'SilentlyContinue'; Set-ItemProperty -LiteralPath $key -Name 'ConfigureStartPins' -Value $json -Type 'String'; <LayoutModificationTemplate Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification"> <LayoutOptions StartTileGroupCellWidth="6" /> <DefaultLayoutOverride> <StartLayoutCollection> <StartLayout GroupCellWidth="6" xmlns="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" /> </StartLayoutCollection> </DefaultLayoutOverride> </LayoutModificationTemplate> $lightThemeSystem = 0; $lightThemeApps = 0; $accentColorOnStart = 0; $enableTransparency = 0; $htmlAccentColor = '#0065B3'; & { $params = @{ LiteralPath = 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize'; Force = $true; Type = 'DWord'; }; Set-ItemProperty @params -Name 'SystemUsesLightTheme' -Value $lightThemeSystem; Set-ItemProperty @params -Name 'AppsUseLightTheme' -Value $lightThemeApps; Set-ItemProperty @params -Name 'ColorPrevalence' -Value $accentColorOnStart; Set-ItemProperty @params -Name 'EnableTransparency' -Value $enableTransparency; }; & { Add-Type -AssemblyName 'System.Drawing'; $accentColor = [System.Drawing.ColorTranslator]::FromHtml( $htmlAccentColor ); function ConvertTo-DWord { param( [System.Drawing.Color] $Color ); [byte[]] $bytes = @( $Color.R; $Color.G; $Color.B; $Color.A; ); return [System.BitConverter]::ToUInt32( $bytes, 0); } $startColor = [System.Drawing.Color]::FromArgb( 0xD2, $accentColor ); Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent' -Name 'StartColorMenu' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force; Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent' -Name 'AccentColorMenu' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force; Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\DWM' -Name 'AccentColor' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force; $params = @{ LiteralPath = 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent'; Name = 'AccentPalette'; }; $palette = Get-ItemPropertyValue @params; $index = 20; $palette[ $index++ ] = $accentColor.R; $palette[ $index++ ] = $accentColor.G; $palette[ $index++ ] = $accentColor.B; $palette[ $index++ ] = $accentColor.A; Set-ItemProperty @params -Value $palette -Type 'Binary' -Force; }; $htmlColor = '#000000'; Add-Type -TypeDefinition ' using System.Drawing; using System.Runtime.InteropServices; public static class ColorSetter { [DllImport("user32.dll")] private static extern bool SetSysColors( int cElements, int[] lpaElements, int[] lpaRgbValues ); [DllImport("user32.dll")] private static extern bool SystemParametersInfo( uint uiAction, uint uiParam, string pvParam, uint fWinIni ); public static void SetDesktopBackground(Color color) { SystemParametersInfo(20, 0, "", 0); SetSysColors(1, new int[] { 1 }, new int[] { ColorTranslator.ToWin32(color) }); } } ' -ReferencedAssemblies 'System.Drawing'; $color = [System.Drawing.ColorTranslator]::FromHtml( $htmlColor ); [ColorSetter]::SetDesktopBackground( $color ); Set-ItemProperty -Path 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers' -Name 'BackgroundType' -Type 'DWord' -Value 1 -Force; Set-ItemProperty -Path 'Registry::HKCU\Control Panel\Desktop' -Name 'WallPaper' -Type 'String' -Value '' -Force; Set-ItemProperty -Path 'Registry::HKCU\Control Panel\Colors' -Name 'Background' -Type 'String' -Value "$($color.R) $($color.G) $($color.B)" -Force; # Ativar “Obter atualizacoes assim que disponiveis” no Windows Update Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "IsContinuousInnovationOptedIn" -Value 1 # Desativando a Assistencia Remota Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Value 0 -Force # Enable the Ultimate Performance power plan powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61 & ([ScriptBlock]::Create((irm https://get.activated.win))) /HWID /S # Ativar historico de area de transferencia Set-ItemProperty -Path "HKCU:\Software\Microsoft\Clipboard" -Name "EnableClipboardHistory" -Value 1 -Type DWord # Ativar caixa de selecao no Windows Explorer New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "AutoCheckSelect" -Value 1 -PropertyType DWord -Force # Alterar o layout do Menu Iniciar para priorizar aplicativos fixados Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value 1 Stop-Process -Name explorer -Force Start-Process explorer & { Get-AppxPackage -Name 'Microsoft.Windows.Ai.Copilot.Provider' | Remove-AppxPackage; Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\TaskbarIcons.ps1' -Raw | Invoke-Expression; $params = @{ Path = 'Registry::HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32'; ErrorAction = 'SilentlyContinue'; Force = $true; }; New-Item @params; Set-ItemProperty @params -Name '(Default)' -Value '' -Type 'String'; Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'LaunchTo' -Type 'DWord' -Value 1; Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Search' -Name 'SearchboxTaskbarMode' -Type 'DWord' -Value 0; Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\SetColorTheme.ps1' -Raw | Invoke-Expression; Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\SetWallpaper.ps1' -Raw | Invoke-Expression; Get-Process -Name 'explorer' -ErrorAction 'SilentlyContinue' | Where-Object -FilterScript { $_.SI -eq ( Get-Process -Id $PID ).SI; } | Stop-Process -Force; } *>&1 >> "$env:TEMP\UserOnce.log"; ```
cschneegans commented 2 days ago

I tested both solutions you gave me and neither worked.

This link will add the Chrome install script from above to your existing autounattend.xml file. Note how I pasted the script in the form:

image