如何使用 powershell 取消固定 Windows 10 開始功能表廣告

如何使用 powershell 取消固定 Windows 10 開始功能表廣告

有時我會為某人準備一台新電腦,並認為我可以使用 powershell 從選單開始取消固定程式和廣告。它有效,但只是部分有效。我能夠取消固定諸如“日曆和天氣”之類的程序,但不知道如何擺脫“狂野飆車 8:極速凌雲”等 Windows 商店遊戲廣告:

在此輸入影像描述

我應該在腳本中包含什麼名稱來取消固定那個東西(和類似的東西)?

這是我使用的腳本:

function Pin-App {    param(
        [string]$appname,
        [switch]$unpin
    )
    try{
        if ($unpin.IsPresent){
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Von "Start" lösen|Unpin from Start'} | %{$_.DoIt()}
            return "App '$appname' unpinned from Start"
        }else{
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'An "Start" anheften|Pin to Start'} | %{$_.DoIt()}
            return "App '$appname' pinned to Start"
        }
    }catch{
        Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
    }
}

Pin-App "Mail" -unpin
Pin-App "Store" -unpin
Pin-App "Calendar" -unpin
Pin-App "Microsoft Edge" -unpin
Pin-App "Photos" -unpin
Pin-App "Cortana" -unpin
Pin-App "Weather" -unpin
Pin-App "Phone Companion" -unpin
Pin-App "Twitter" -unpin
Pin-App "Skype Video" -unpin
Pin-App "Candy Crush Soda Saga" -unpin
Pin-App "xbox" -unpin
Pin-App "Groove music" -unpin
Pin-App "films & tv" -unpin
Pin-App "microsoft solitaire collection" -unpin
Pin-App "money" -unpin
Pin-App "get office" -unpin
Pin-App "onenote" -unpin
Pin-App "news" -unpin
Pin-App "Asphalt 8: Airborne" -unpin
Pin-App "This PC" -pin

答案1

如果您想部署標準化的開始功能表,您可以使用Export-StartLayoutImport-StartLayout

  1. 按照您想要的方式在測試機上手動設定開始功能表。
  2. 將該佈局匯出到 XML 文件,擴展名為Export-StartLayout.
  3. 將該檔案匯入到其他電腦上Import-StartLayout

微軟提供了更多詳細資訊:

https://blogs.technet.microsoft.com/deploymentguys/2016/03/07/windows-10-start-layout-customization/

答案2

這是我使用 PowerShell 編寫的簡單內容,用於使用 MDT 將自訂開始功能表佈局推送到 Windows 10,它首先是 MDT 在部署期間將 XML 部署到臨時資料夾。

    Clear-Host

# file path that the xml must live in 
    $filepath = "C:\users\default\AppData\Local\Microsoft\Windows\Shell"

# xml files that were copied to local machine
    $startxmlorig = "C:\Windows\Temp\startandtaskbar.xml"
    $layoutmod = "C:\Windows\Temp\LayoutModification.xml"

# test the path to see if it exists if yes then copy xmls to correct folder on if not then create the path and copy the xml files to the correct path.

    if (!(Test-Path -Path $filepath)) {
        Copy-Item -Path $startxmlorig -Destination $filepath
        Copy-Item -Path $layoutmod -Destination $filepath
        } else {
        New-Item -Force -ItemType Directory -Path $filepath
            Copy-Item -Path $startxmlorig -Destination $filepath
            Copy-Item -Path $layoutmod -Destination $filepath`

相關內容