Script - Win10Setup - V 1.2.2.1

The other day I found that my Script was not correctly getting the application names from the Apps to remove list so I corrected that issue in a newer version of my script. I have also added the ability to disable OneDrive and Cortana in the script

Full resource files can be found HERE

The original script is HERE

<#
.SYNOPSIS
Removes built in windows apps and imports a start menu layout.

.DESCRIPTION
The script will look to the AppsToRemove.txt file for a list of apps to uninstalls from the curent user profile 
and will prevent the apps installing for all new user profiles. The script will also import a xml file for a 
start menu default lay out for all new user logins. You can also remove OneDrive and Cortana with this script.

.PARAMETER Apps
Specifyes the list of apps to be removed defaults to AppsToRemove.txt 

.PARAMETER StartMenuLayout
Specifyes the xml file for the start menu layout

.PARAMETER DisableOneDrive
Disables OneDrive on the computer

.PARAMETER DisableCortana
Disables Cortana on the computer

.EXAMPLE
.\Win10Setup.ps1 -Apps AppsList.txt
Removes all apps in the AppsList.txt file

.EXAMPLE
.\Win10Setup.ps1 -StartMenuLayout StartMenuLayout.xml
Imports the xml file to use as the default start menu layout for all new users
To build your xml run Export-StartLayout -Path "C:\example\StartMenuLayout.xml"

.EXAMPLE 
.\Win10Setup.ps1 -StartMenuLayout StartMenuLayout.xml -Apps AppsToRemove.txt -DisableOneDrive -DisableCortana
Imports the start menu config removes apps listed in the txt file disbales one drive and cortana.

.NOTES
Created By: Kris Gross
Contact: Krisgross@sccmtst.com
Twitter: @kmgamd
Version 1.2.2.1

.LINK
You can get updates to this script and others from here
http://www.sccmtst.com/
#>

Param(
    $Apps,
    $StartMenuLayout,
    [Switch]$DisableOneDrive,
    [Switch]$DisableCortana

    )
#If a list file is specifyed will run the uninstall process
IF ($Apps)
{
    #Removes some windows apps
    $AppsList = Get-Content $Apps
    Foreach ($App in ($AppsList))
        {
            $item = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -Like "*$App*"}
            Write-Host "Removing $App"
            Remove-AppxProvisionedPackage -Online -PackageName $item.PackageName
            Get-AppxPackage -AllUsers | Where-Object Name -Like "*$App*" | Remove-AppxPackage
        }
}

#If a config file is specifed will import it 
IF ($StartMenuLayout)
{
    #Configures the start menu layout
    Write-Host importing $StartMenuLayout
    #Copyies a IE Shortcut to the all users start menu so all users will have it the start menu config
    # Copy-Item -Path "Internet Explorer.lnk" -Destination "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
    Import-StartLayout -LayoutPath $StartMenuLayout -MountPath C:\
}

If ($DisableOneDrive)
{
    Write-Host 'Disabling OneDrive'
    $RegPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive"
    $Name = "DisableFileSyncNGSC"
    $Value = "1"
    $Type = "DWORD"

    Set-Location HKLM:
    if (!(test-Path .\SOFTWARE\Policies\Microsoft\Windows\OneDrive)) {New-Item .\SOFTWARE\Policies\Microsoft\Windows\OneDrive}
    New-ItemProperty -Path $RegPath -Name $Name -Value $Value -PropertyType $Type -Force | Out-Null
    Set-Location $PSScriptRoot
}

If ($DisableCortana)
{
    Write-Host "Disabling Cortana"
    $RegPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
    $Name = "AllowCortana"
    $Value = "0"
    $Type = "DWORD"

    Set-Location HKLM:
    if (!(test-Path .\SOFTWARE\Policies\Microsoft\Windows\"Windows Search")) {New-Item .\SOFTWARE\Policies\Microsoft\Windows\"Windows Search"}
    New-ItemProperty -Path $RegPath -Name $Name -Value $Value -PropertyType $Type -Force | Out-Null
    Set-Location $PSScriptRoot
}

Popular posts from this blog

SCCM Task Sequence GUI - How to set up the TS to work with a GUI

SCCM Applications vs. SCCM Packages: Understanding the Key Differences

Faster PXE boot times in SCCM 1606 and later