I removed the switch containing interactive/noninteractive choices since the noninteractive option only cut down the amount of interactive prompts by 2, and I saw no value with keeping it. I also fixed the formatting of the code and it should be a bit more presentable now.
#This switch will ask you if you'd like to run the script as interactive or silently. Depending on your selection, yes will be interactive, no will be silent.
Write-Output"How would you like to run this script?"
#Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
Write-Output"Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys."
Write-Output"Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
Sleep 1
FixWhitelistedApps
Sleep 1
Write-Output"Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
Protect-Privacy
Write-Output"Cortana disabled from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
Sleep 1;$PublishSettings=$Debloat
#This will debloat Windows 10
Debloat{
#Creates a "drive" to access the HKCR (HKEY_CLASSES_ROOT)
Write-Output"Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the removal and modification of specific registry keys."
Write-Output"Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
Start-Sleep1
FixWhitelistedApps
Start-Sleep1
Write-Output"Disabling Cortana from search, disabling feedback to Microsoft, and disabling scheduled tasks that are considered to be telemetry or unnecessary."
Protect-Privacy
Write-Output"Cortana disabled from search, feedback to Microsoft has been disabled, and scheduled tasks are disabled."
Start-Sleep1;$PublishSettings=$Debloat
Write-Output"Do you want to stop edge from taking over as the default PDF viewer?"
$ReadHost=Read-Host" (Yes / No ) "
Switch($ReadHost){
Yes{
Stop-EdgePDF
Write-Output"Edge will no longer take over as the default PDF viewer.";$PublishSettings=$Yes
}
No{
$PublishSettings=$No
}
}
#Switch statement asking if you'd like to reboot your machine
Write-Output"For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
$ReadHost=Read-Host" ( Yes / No ) "
Switch($Readhost){
Yes{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Sleep 1
Stop-Transcript
Write-Output"Initiating reboot."
Sleep 2
Restart-Computer;$PublishSettings=$Yes
}
No{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Sleep 1
Stop-Transcript
Write-Output"Script has finished. Exiting."
Sleep 2
Exit;$PublishSettings=$No
}
}
Write-Output"Do you want to stop edge from taking over as the default PDF viewer?"
$ReadHost=Read-Host" (Yes / No ) "
Switch($ReadHost){
Yes{
Stop-EdgePDF
Write-Output"Edge will no longer take over as the default PDF viewer.";$PublishSettings=$Yes
}
Revert{
Write-Output"Reverting changes..."
Write-Output"Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the modification of specific registry keys."
Write-Output"Do you want to revert changes that disabled Edge as the default PDF viewer?"
$ReadHost=Read-Host" (Yes / No ) "
Switch($ReadHost){
Yes{
Enable-EdgePDF
Write-Output"Edge will no longer be disabled from being used as the default Edge PDF viewer.";$PublishSettings=$Yes
}
No{$PublishSettings=$No}
No{
$PublishSettings=$No
}
}
#Switch statement asking if you'd like to reboot your machine
Write-Output"For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
$ReadHost=Read-Host" ( Yes / No ) "
Switch($Readhost){
Yes{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Start-Sleep1
Stop-Transcript
Write-Output"Initiating reboot."
Start-Sleep2
Restart-Computer;$PublishSettings=$Yes
}
#Switch statement asking if you'd like to reboot your machine
Write-Output"For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
$Readhost=Read-Host" ( Yes / No ) "
Switch($Readhost){
Yes{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Sleep 1
Write-Output"Initiating reboot."
Stop-Transcript
Sleep 2
Restart-Computer;$PublishSettings=$Yes
}
No{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Sleep 1
Write-Output"Script has finished. Exiting."
Stop-Transcript
Sleep 2
Exit;$PublishSettings=$No
}
}
No{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Start-Sleep1
Stop-Transcript
Write-Output"Script has finished. Exiting."
Start-Sleep2
Exit;$PublishSettings=$No
}
}
}
Noninteractive{
Write-Output"You will not be prompted for any other questions after this. With either option your machine will not automatically reboot and you will need to manually reboot. Would you like to Debloat or Revert changes?"
$Readhost=Read-Host" ( Debloat / Revert ) "
Revert{
Write-Output"Reverting changes..."
Write-Output"Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the modification of specific registry keys."
Write-Output"Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
Sleep 1
FixWhitelistedApps
Sleep 1
Write-Output"Stopping Edge from being used as the default PDF Viewer."
Sleep 1
Protect-Privacy
Write-Output"Script has finished. Exiting now."
Sleep 2
Yes{
Enable-EdgePDF
Write-Output"Edge will no longer be disabled from being used as the default Edge PDF viewer.";$PublishSettings=$Yes
}
No{$PublishSettings=$No}
}
#Switch statement asking if you'd like to reboot your machine
Write-Output"For some of the changes to properly take effect it is recommended to reboot your machine. Would you like to restart?"
$Readhost=Read-Host" ( Yes / No ) "
Switch($Readhost){
Yes{
Write-Output"Unloading the HKCR drive..."
Remove-PSDriveHKCR
Start-Sleep1
Write-Output"Initiating reboot."
Stop-Transcript
Exit;$PublishSettings=$Debloat
Start-Sleep2
Restart-Computer;$PublishSettings=$Yes
}
Revert{
Write-Output"Reverting changes..."
Write-Output"Creating PSDrive 'HKCR' (HKEY_CLASSES_ROOT). This will be used for the duration of the script as it is necessary for the modification of specific registry keys."