@@ -1105,12 +1105,14 @@ Function EnableConnectionSharing {
1105
1105
Function DisableRemoteAssistance {
1106
1106
Write-Output " Disabling Remote Assistance..."
1107
1107
Set-ItemProperty - Path " HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" - Name " fAllowToGetHelp" - Type DWord - Value 0
1108
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " App.Support.QuickAssist*" } | Remove-WindowsCapability - Online | Out-Null
1108
1109
}
1109
1110
1110
1111
# Enable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed)
1111
1112
Function EnableRemoteAssistance {
1112
1113
Write-Output " Enabling Remote Assistance..."
1113
1114
Set-ItemProperty - Path " HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" - Name " fAllowToGetHelp" - Type DWord - Value 1
1115
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " App.Support.QuickAssist*" } | Add-WindowsCapability - Online | Out-Null
1114
1116
}
1115
1117
1116
1118
# Enable Remote Desktop
@@ -3300,46 +3302,50 @@ Function DisableDeveloperMode {
3300
3302
# Uninstall Windows Media Player
3301
3303
Function UninstallMediaPlayer {
3302
3304
Write-Output " Uninstalling Windows Media Player..."
3303
- Disable-WindowsOptionalFeature - Online - FeatureName " WindowsMediaPlayer" - NoRestart - WarningAction SilentlyContinue | Out-Null
3305
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -eq " WindowsMediaPlayer" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3306
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Media.WindowsMediaPlayer*" } | Remove-WindowsCapability - Online | Out-Null
3304
3307
}
3305
3308
3306
3309
# Install Windows Media Player
3307
3310
Function InstallMediaPlayer {
3308
3311
Write-Output " Installing Windows Media Player..."
3309
- Enable-WindowsOptionalFeature - Online - FeatureName " WindowsMediaPlayer" - NoRestart - WarningAction SilentlyContinue | Out-Null
3312
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -eq " WindowsMediaPlayer" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3313
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Media.WindowsMediaPlayer*" } | Add-WindowsCapability - Online | Out-Null
3310
3314
}
3311
3315
3312
3316
# Uninstall Internet Explorer
3313
3317
Function UninstallInternetExplorer {
3314
3318
Write-Output " Uninstalling Internet Explorer..."
3315
- Disable-WindowsOptionalFeature - Online - FeatureName " Internet-Explorer-Optional-$env: PROCESSOR_ARCHITECTURE " - NoRestart - WarningAction SilentlyContinue | Out-Null
3319
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -like " Internet-Explorer-Optional*" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3320
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Browser.InternetExplorer*" } | Remove-WindowsCapability - Online | Out-Null
3316
3321
}
3317
3322
3318
3323
# Install Internet Explorer
3319
3324
Function InstallInternetExplorer {
3320
3325
Write-Output " Installing Internet Explorer..."
3321
- Enable-WindowsOptionalFeature - Online - FeatureName " Internet-Explorer-Optional-$env: PROCESSOR_ARCHITECTURE " - NoRestart - WarningAction SilentlyContinue | Out-Null
3326
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -like " Internet-Explorer-Optional*" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3327
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Browser.InternetExplorer*" } | Add-WindowsCapability - Online | Out-Null
3322
3328
}
3323
3329
3324
3330
# Uninstall Work Folders Client - Not applicable to Server
3325
3331
Function UninstallWorkFolders {
3326
3332
Write-Output " Uninstalling Work Folders Client..."
3327
- Disable -WindowsOptionalFeature - Online - FeatureName " WorkFolders-Client" - NoRestart - WarningAction SilentlyContinue | Out-Null
3333
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " WorkFolders-Client" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3328
3334
}
3329
3335
3330
3336
# Install Work Folders Client - Not applicable to Server
3331
3337
Function InstallWorkFolders {
3332
3338
Write-Output " Installing Work Folders Client..."
3333
- Enable -WindowsOptionalFeature - Online - FeatureName " WorkFolders-Client" - NoRestart - WarningAction SilentlyContinue | Out-Null
3339
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " WorkFolders-Client" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3334
3340
}
3335
3341
3336
- # Uninstall PowerShell 2.0 Environment.
3342
+ # Uninstall PowerShell 2.0 Environment
3337
3343
# PowerShell 2.0 is deprecated since September 2018. This doesn't affect PowerShell 5 or newer which is the default PowerShell environment.
3338
3344
# May affect Microsoft Diagnostic Tool and possibly other scripts. See https://blogs.msdn.microsoft.com/powershell/2017/08/24/windows-powershell-2-0-deprecation/
3339
3345
Function UninstallPowerShellV2 {
3340
3346
Write-Output " Uninstalling PowerShell 2.0 Environment..."
3341
3347
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3342
- Disable -WindowsOptionalFeature - Online - FeatureName " MicrosoftWindowsPowerShellV2Root" - NoRestart - WarningAction SilentlyContinue | Out-Null
3348
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " MicrosoftWindowsPowerShellV2Root" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3343
3349
} Else {
3344
3350
Uninstall-WindowsFeature - Name " PowerShell-V2" - WarningAction SilentlyContinue | Out-Null
3345
3351
}
@@ -3349,7 +3355,7 @@ Function UninstallPowerShellV2 {
3349
3355
Function InstallPowerShellV2 {
3350
3356
Write-Output " Installing PowerShell 2.0 Environment..."
3351
3357
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3352
- Enable -WindowsOptionalFeature - Online - FeatureName " MicrosoftWindowsPowerShellV2Root" - NoRestart - WarningAction SilentlyContinue | Out-Null
3358
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " MicrosoftWindowsPowerShellV2Root" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3353
3359
} Else {
3354
3360
Install-WindowsFeature - Name " PowerShell-V2" - WarningAction SilentlyContinue | Out-Null
3355
3361
}
@@ -3360,20 +3366,20 @@ Function InstallPowerShellV2 {
3360
3366
# For automated Linux distribution installation, see https://docs.microsoft.com/en-us/windows/wsl/install-on-server
3361
3367
Function InstallLinuxSubsystem {
3362
3368
Write-Output " Installing Linux Subsystem..."
3363
- Enable -WindowsOptionalFeature - Online - FeatureName " Microsoft-Windows-Subsystem-Linux" - NoRestart - WarningAction SilentlyContinue | Out-Null
3369
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Microsoft-Windows-Subsystem-Linux" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3364
3370
}
3365
3371
3366
3372
# Uninstall Linux Subsystem - Applicable since Win10 1607 and Server 1709
3367
3373
Function UninstallLinuxSubsystem {
3368
3374
Write-Output " Uninstalling Linux Subsystem..."
3369
- Disable -WindowsOptionalFeature - Online - FeatureName " Microsoft-Windows-Subsystem-Linux" - NoRestart - WarningAction SilentlyContinue | Out-Null
3375
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Microsoft-Windows-Subsystem-Linux" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3370
3376
}
3371
3377
3372
3378
# Install Hyper-V - Not applicable to Home
3373
3379
Function InstallHyperV {
3374
3380
Write-Output " Installing Hyper-V..."
3375
3381
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3376
- Enable -WindowsOptionalFeature - Online - FeatureName " Microsoft-Hyper-V-All" - NoRestart - WarningAction SilentlyContinue | Out-Null
3382
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Microsoft-Hyper-V-All" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3377
3383
} Else {
3378
3384
Install-WindowsFeature - Name " Hyper-V" - IncludeManagementTools - WarningAction SilentlyContinue | Out-Null
3379
3385
}
@@ -3383,7 +3389,7 @@ Function InstallHyperV {
3383
3389
Function UninstallHyperV {
3384
3390
Write-Output " Uninstalling Hyper-V..."
3385
3391
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3386
- Disable -WindowsOptionalFeature - Online - FeatureName " Microsoft-Hyper-V-All" - NoRestart - WarningAction SilentlyContinue | Out-Null
3392
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Microsoft-Hyper-V-All" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3387
3393
} Else {
3388
3394
Uninstall-WindowsFeature - Name " Hyper-V" - IncludeManagementTools - WarningAction SilentlyContinue | Out-Null
3389
3395
}
@@ -3395,7 +3401,7 @@ Function UninstallSSHClient {
3395
3401
Get-WindowsCapability - Online | Where-Object { $_.Name -like " OpenSSH.Client*" } | Remove-WindowsCapability - Online | Out-Null
3396
3402
}
3397
3403
3398
- # Install OpenSSH Client
3404
+ # Install OpenSSH Client - Applicable since 1803
3399
3405
Function InstallSSHClient {
3400
3406
Write-Output " Installing OpenSSH Client..."
3401
3407
Get-WindowsCapability - Online | Where-Object { $_.Name -like " OpenSSH.Client*" } | Add-WindowsCapability - Online | Out-Null
@@ -3409,7 +3415,7 @@ Function InstallSSHServer {
3409
3415
Start-Service " sshd" - WarningAction SilentlyContinue
3410
3416
}
3411
3417
3412
- # Uninstall OpenSSH Server
3418
+ # Uninstall OpenSSH Server - Applicable since 1809
3413
3419
Function UninstallSSHServer {
3414
3420
Write-Output " Uninstalling OpenSSH Server..."
3415
3421
Stop-Service " sshd" - WarningAction SilentlyContinue
@@ -3420,7 +3426,7 @@ Function UninstallSSHServer {
3420
3426
Function InstallNET23 {
3421
3427
Write-Output " Installing .NET Framework 2.0, 3.0 and 3.5 runtimes..."
3422
3428
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3423
- Enable -WindowsOptionalFeature - Online - FeatureName " NetFx3" - NoRestart - WarningAction SilentlyContinue | Out-Null
3429
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " NetFx3" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3424
3430
} Else {
3425
3431
Install-WindowsFeature - Name " NET-Framework-Core" - WarningAction SilentlyContinue | Out-Null
3426
3432
}
@@ -3430,7 +3436,7 @@ Function InstallNET23 {
3430
3436
Function UninstallNET23 {
3431
3437
Write-Output " Uninstalling .NET Framework 2.0, 3.0 and 3.5 runtimes..."
3432
3438
If ((Get-CimInstance - Class " Win32_OperatingSystem" ).ProductType -eq 1 ) {
3433
- Disable -WindowsOptionalFeature - Online - FeatureName " NetFx3" - NoRestart - WarningAction SilentlyContinue | Out-Null
3439
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " NetFx3" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3434
3440
} Else {
3435
3441
Uninstall-WindowsFeature - Name " NET-Framework-Core" - WarningAction SilentlyContinue | Out-Null
3436
3442
}
@@ -3490,25 +3496,25 @@ Function RemovePhotoViewerOpenWith {
3490
3496
# Uninstall Microsoft Print to PDF
3491
3497
Function UninstallPDFPrinter {
3492
3498
Write-Output " Uninstalling Microsoft Print to PDF..."
3493
- Disable -WindowsOptionalFeature - Online - FeatureName " Printing-PrintToPDFServices-Features" - NoRestart - WarningAction SilentlyContinue | Out-Null
3499
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Printing-PrintToPDFServices-Features" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3494
3500
}
3495
3501
3496
3502
# Install Microsoft Print to PDF
3497
3503
Function InstallPDFPrinter {
3498
3504
Write-Output " Installing Microsoft Print to PDF..."
3499
- Enable -WindowsOptionalFeature - Online - FeatureName " Printing-PrintToPDFServices-Features" - NoRestart - WarningAction SilentlyContinue | Out-Null
3505
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Printing-PrintToPDFServices-Features" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3500
3506
}
3501
3507
3502
3508
# Uninstall Microsoft XPS Document Writer
3503
3509
Function UninstallXPSPrinter {
3504
3510
Write-Output " Uninstalling Microsoft XPS Document Writer..."
3505
- Disable -WindowsOptionalFeature - Online - FeatureName " Printing-XPSServices-Features" - NoRestart - WarningAction SilentlyContinue | Out-Null
3511
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Printing-XPSServices-Features" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3506
3512
}
3507
3513
3508
3514
# Install Microsoft XPS Document Writer
3509
3515
Function InstallXPSPrinter {
3510
3516
Write-Output " Installing Microsoft XPS Document Writer..."
3511
- Enable -WindowsOptionalFeature - Online - FeatureName " Printing-XPSServices-Features" - NoRestart - WarningAction SilentlyContinue | Out-Null
3517
+ Get -WindowsOptionalFeature - Online | Where-Object { $_ . FeatureName -eq " Printing-XPSServices-Features" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3512
3518
}
3513
3519
3514
3520
# Remove Default Fax Printer
@@ -3526,21 +3532,15 @@ Function AddFaxPrinter {
3526
3532
# Uninstall Windows Fax and Scan Services - Not applicable to Server
3527
3533
Function UninstallFaxAndScan {
3528
3534
Write-Output " Uninstalling Windows Fax and Scan Services..."
3529
- If ([System.Environment ]::OSVersion.Version.Build -ge 19041 ) {
3530
- Get-WindowsCapability - Online | Where-Object { $_.Name -like " Print.Fax.Scan*" } | Remove-WindowsCapability - Online | Out-Null
3531
- } Else {
3532
- Disable-WindowsOptionalFeature - Online - FeatureName " FaxServicesClientPackage" - NoRestart - WarningAction SilentlyContinue | Out-Null
3533
- }
3535
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -eq " FaxServicesClientPackage" } | Disable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3536
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Print.Fax.Scan*" } | Remove-WindowsCapability - Online | Out-Null
3534
3537
}
3535
3538
3536
3539
# Install Windows Fax and Scan Services - Not applicable to Server
3537
3540
Function InstallFaxAndScan {
3538
3541
Write-Output " Installing Windows Fax and Scan Services..."
3539
- If ([System.Environment ]::OSVersion.Version.Build -ge 19041 ) {
3540
- Get-WindowsCapability - Online | Where-Object { $_.Name -like " Print.Fax.Scan*" } | Add-WindowsCapability - Online | Out-Null
3541
- } Else {
3542
- Enable-WindowsOptionalFeature - Online - FeatureName " FaxServicesClientPackage" - NoRestart - WarningAction SilentlyContinue | Out-Null
3543
- }
3542
+ Get-WindowsOptionalFeature - Online | Where-Object { $_.FeatureName -eq " FaxServicesClientPackage" } | Enable-WindowsOptionalFeature - Online - NoRestart - WarningAction SilentlyContinue | Out-Null
3543
+ Get-WindowsCapability - Online | Where-Object { $_.Name -like " Print.Fax.Scan*" } | Add-WindowsCapability - Online | Out-Null
3544
3544
}
3545
3545
3546
3546
# #########
0 commit comments