Bläddra i källkod

Added $SysPrep switch parameter and function

I added a $SysPrep switch parameter and function on lines 7 - 17. This will run the following command: get-appxpackage | remove-appxpackage. This is required in order to be used successfully with SysPrep.

I also added a $StopEdgePDF parameter, for those who do not wish to stop Edge from being used as the default PDF viewer, or for those who worry about unintended consequences (not being able to potentially choose Edge without removing the specified registry keys).

You can now run the script with the switch parameter -SysPrep, along with -Debloat, and -StopEdgePDF.
Richard Newton 7 år sedan
förälder
incheckning
12fe2f5aef
1 ändrade filer med 17 tillägg och 2 borttagningar
  1. 17 2
      Windows10SilentDebloater.ps1

+ 17 - 2
Windows10DebloaterSilent.ps1 → Windows10SilentDebloater.ps1

@@ -4,12 +4,24 @@
 #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
 #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
 param([switch]$Debloat)
 param([switch]$Debloat)
 
 
+param([switch]$SysPrep)
+
+param([switch]$StopEdgePDF)
+
+#This will run get-appxpackage | remove-appxpackage which is required for sysprep to provision the apps.
+Function Begin-SysPrep {
+
+    param([switch]$SysPrep)
+
+    get-appxpackage | remove-appxpackage
+
+}
+
 #Creates a PSDrive to be able to access the 'HKCR' tree
 #Creates a PSDrive to be able to access the 'HKCR' tree
 New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
 New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
 Function Start-Debloat {
 Function Start-Debloat {
     
     
-    param
-    ([switch]$Debloat)
+    param([switch]$Debloat)
 
 
     #Removes AppxPackages
     #Removes AppxPackages
     Get-AppxPackage -AllUsers | 
     Get-AppxPackage -AllUsers | 
@@ -27,6 +39,7 @@ Function Start-Debloat {
         Where-Object {$_.packagename -notlike "*Microsoft.Windows.Photos*"} |
         Where-Object {$_.packagename -notlike "*Microsoft.Windows.Photos*"} |
         Remove-AppxProvisionedPackage -online -ErrorAction SilentlyContinue
         Remove-AppxProvisionedPackage -online -ErrorAction SilentlyContinue
 }
 }
+
 Function Remove-Keys {
 Function Remove-Keys {
         
         
     Param([switch]$Debloat)    
     Param([switch]$Debloat)    
@@ -209,6 +222,8 @@ Function Stop-EdgePDF {
         Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
         Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_ -Verbose
     }
     }
 }
 }
+Write-Output "Initiating Sysprep"
+Begin-SysPrep
 Write-Output "Removing bloatware apps."
 Write-Output "Removing bloatware apps."
 Start-Debloat
 Start-Debloat
 Write-Output "Removing leftover bloatware registry keys."
 Write-Output "Removing leftover bloatware registry keys."