Skip to content

Instantly share code, notes, and snippets.

@hiono
Last active January 27, 2022 09:22
Show Gist options
  • Save hiono/15d2a5d667118afd941f31b9a6835a3e to your computer and use it in GitHub Desktop.
Save hiono/15d2a5d667118afd941f31b9a6835a3e to your computer and use it in GitHub Desktop.
Vagrant provisioner
param()
#---------------
# Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://gist.github.com/hiono/15d2a5d667118afd941f31b9a6835a3e/raw/base_setup.ps1'))
#---------------
# Set-PSDebug -Trace 2
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_base_setup.txt" -append
# Expand Disk
[string]$DriveLetter = 'c'
$Partition = Get-Partition | Where-Object -Property 'DriveLetter' -Value $DriveLetter -EQ
Write-Host "Current patition size:" $Partition.Size
if ($Partition) {
$PartitionSupportedSize = $Partition | Get-PartitionSupportedSize
Write-Host "Current patition max size:" $PartitionSupportedSize.SizeMax
if ($PartitionSupportedSize.SizeMax -gt $Partition.Size) {
Resize-Partition -DiskNumber $Partition.DiskNumber -PartitionNumber $Partition.PartitionNumber -Size $PartitionSupportedSize.SizeMax
$Partition = Get-Partition | Where-Object -Property 'DriveLetter' -Value $DriveLetter -EQ
Write-Host "New patition size:" $Partition.Size
}
}
# Disable firewall
Write-Host "Firewall Profile"
Get-NetFirewallProfile | Format-table -Property Name,Enabled
if ((Get-NetFirewallProfile -Profile Domain, Public, Private).Enabled -eq "True", "True", "True") {
Write-Host "Disable firewall"
Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False
}
Write-Host "Firewall disabled"
Write-Host "Firewall Profile"
Get-NetFirewallProfile | Format-table -Property Name,Enabled
# Enable Feature
$Dism = New-Module -AsCustomObject -ScriptBlock {
function EnableFeature($feature) {
& dism @('/online', '/enable-feature', "/featurename:$feature", '/all', '/norestart')
}
}
$BcdEdit = New-Module -AsCustomObject -ScriptBlock {
function HypervisorLaunchType($type) {
& bcdedit @('/set', 'hypervisorlaunchtype', $type)
}
}
$Dism.EnableFeature('Microsoft-Windows-Subsystem-Linux')
$Dism.EnableFeature('VirtualMachinePlatform')
$BcdEdit.HypervisorLaunchType('auto')
# Uninstall Apps
$ErrorActionPreference = "Stop"
Write-Host "Uninstall Apps"
$apps = @(
"Microsoft.BingWeather",
"Microsoft.GetHelp",
"Microsoft.Getstarted",
"Microsoft.Microsoft3DViewer",
"Microsoft.MicrosoftOfficeHub",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.MicrosoftStickyNotes",
"Microsoft.MixedReality.Portal",
"Microsoft.MSPaint",
"Microsoft.Office.OneNote",
"Microsoft.People",
"Microsoft.WindowsAlarms",
"Microsoft.WindowsCamera",
"microsoft.windowscommunicationsapps",
"Microsoft.WindowsFeedbackHub",
"Microsoft.WindowsMaps",
"Microsoft.Xbox.TCUI",
"Microsoft.XboxApp",
"Microsoft.XboxGameOverlay",
"Microsoft.XboxGamingOverlay",
"Microsoft.XboxIdentityProvider",
"Microsoft.XboxSpeechToTextOverlay",
"Microsoft.YourPhone",
"Microsoft.ZuneMusic",
"Microsoft.ZuneVideo",
"Microsoft.Advertising.Xaml",
"Microsoft.549981C3F5F10",
"Microsoft.SkypeApp",
# "SpotifyAB.SpotifyMusic",
"Microsoft.WindowsSoundRecorder"
);
Foreach ($app in $apps) {
try {
Write-Host "Uninstalling: " $app
if ( (Get-AppxPackage -Name $app).PackageFullName -ne '' ) {
Remove-AppxPackage -Package (Get-AppxPackage -Name $app).PackageFullName
}
} catch [Exception] {
Write-Host "Exception: " $error[0]
}
}
# fEnableTimeZoneRedirection:RDS デスクトップにクライアントのローカルタイムを表示
Write-Host "Show client's local time on RDS desktop"
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"
$name = "fEnableTimeZoneRedirection"
$value = 1
$propertytype = 'DWord'
If (-NOT (Test-Path $registryPath)) { New-Item $registryPath | Out-Null }
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType $propertytype -Force | Out-Null
# StoragePolicy:ストレージセンサーを無効にする
Write-Host "Disable the storage sensor"
## Enable Storage Sense
## Ensure the StorageSense key exists
$key = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense"
If (!(Test-Path "$key")) { New-Item -Path "$key" | Out-Null }
If (!(Test-Path "$key\Parameters")) { New-Item -Path "$key\Parameters" | Out-Null }
If (!(Test-Path "$key\Parameters\StoragePolicy")) { New-Item -Path "$key\Parameters\StoragePolicy" | Out-Null }
## Set Storage Sense settings
## Disable Storage Sense
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "01" -Type DWord -Value 0
## Set 'Run Storage Sense' to Every Week
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "2048" -Type DWord -Value 7
## Enable 'Delete temporary files that my apps aren't using'
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "04" -Type DWord -Value 1
## Set 'Delete files in my recycle bin if they have been there for over' to 14 days
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "08" -Type DWord -Value 1
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "256" -Type DWord -Value 14
## Set 'Delete files in my Downloads folder if they have been there for over' to 60 days
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "32" -Type DWord -Value 1
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "512" -Type DWord -Value 60
## Set value that Storage Sense has already notified the user
Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "StoragePoliciesNotified" -Type DWord -Value 1
# NoAutoUpdate:Windows Update の自動更新を無効にする
Write-Host "Disable automatic updates for Windows Update"
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
$name = 'NoAutoUpdate'
$value = 1
$propertytype = 'DWord'
If (-NOT (Test-Path $registryPath)) { New-Item $registryPath | Out-Null }
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType $propertytype -Force | Out-Null
Stop-Transcript
Start-Transcript "c:\tmp\log_firewall.txt" -append
Write-Host "Firewall Profile"
Get-NetFirewallProfile | Format-table -Property Name,Enabled
if ((Get-NetFirewallProfile -Profile Domain, Public, Private).Enabled -eq "True", "True", "True") {
Write-Host "Disable firewall"
Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False
}
Write-Host "Firewall disabled"
Get-NetFirewallProfile | Format-table -Property Name,Enabled
Stop-Transcript
Start-Transcript "c:\tmp\log_uac.txt" -append
$value = get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA
if ($value.EnableLUA -ne 0) {
Write-Host "Disable UAC"
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
}
Write-Host "UAC disabled"
Stop-Transcript
Start-Transcript "c:\tmp\log_wsl.txt" -append
$Dism = New-Module -AsCustomObject -ScriptBlock {
function EnableFeature($feature) {
& "dism" @('/online', '/enable-feature', "/featurename:$feature", '/all', '/norestart')
}
}
$BcdEdit = New-Module -AsCustomObject -ScriptBlock {
function HypervisorLaunchType($type) {
& "bcdedit" @('/set', 'hypervisorlaunchtype', $type)
}
}
$Dism.EnableFeature('Microsoft-Windows-Subsystem-Linux')
$Dism.EnableFeature('VirtualMachinePlatform')
$BcdEdit.HypervisorLaunchType('auto')
Stop-Transcript
Start-Transcript "c:\tmp\log_uac.txt" -append
$value = get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA
if ($value.EnableLUA -ne 1) {
Write-Host "Enable UAC"
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 1
}
Write-Host "UAC enabled"
Stop-Transcript
param()
#---------------
# Set-PSDebug -Trace 2
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_apps.txt" -append
$ChocoInstallPath = "$env:SystemDrive\ProgramData\Chocolatey\bin"
if (!(Test-Path $ChocoInstallPath)) {
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
chocolatey feature enable -n=allowGlobalConfirmation # GlobalConfirmation off
}
$env:PATH +=";$ChocoInstallPath"
# https://github.com/chocolatey/choco/issues/512
$Choco = New-Module -AsCustomObject -ScriptBlock {
function Install($apps) {
try {
Write-Host "Installing of " $apps
& "choco" @('install', '-y', '--no-progress', $apps)
} catch [Exception] {
Write-Host "Exception: " $error[0]
}
}
function Upgrade($apps) {
try {
Write-Host "Upgrading of " $apps
& "chocolatey" @('upgrade', '-y', $apps)
} catch [Exception] {
Write-Host "Exception: " $error[0]
}
}
function list($app) {
try {
$list = & "chocolatey" @('list', '-l', $app)
} catch [Exception] {
}
return $list
}
}
Write-Host "Upgrade Apps"
$Choco.Upgrade(@('all'))
Write-Host "Install Apps"
$stack = @()
Foreach ($app in $args) {
#check if the app is already installed
$listApp = $Choco.list($app)
if (![String]::Join("", $listApp).Contains($app)) {
$stack += $app
}
}
if ($stack.count -gt 0) {
$Choco.install($stack -join ';')
}
$exitCode = $LASTEXITCODE
chocolatey feature disable -n=allowGlobalConfirmation
Write-Host "Exit code was $exitCode"
Stop-Transcript
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
param
(
[string]$matlab_version,
[string]$fileInstallationKey,
[string]$network_license_serv1,
[string]$network_license_serv2,
[string]$network_license_serv3
)
#---------------
Set-PSDebug -Trace 2
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_matlab.txt" -append
Write-Host "Installing matlab"
Write-Host "setup license.dat"
$license_file = "$Env:USERPROFILE\Documents\network_license\license.dat"
$license_dir = Split-Path $license_file -Parent
if ( -not (Test-Path $license_dir )) {
New-Item $license_dir -ItemType Directory
}
# license.dat
$license_dat = @"
SERVER $network_license_serv1
SERVER $network_license_serv2
SERVER $network_license_serv3
USE_SERVER
"@;
$license_dat | Out-File $license_file -Encoding utf8
# installer_input
Write-Host "setup installer_input.txt"
$installer_input_file = "C:\tmp\installer_input.txt"
$base_input = @"
destinationFolder=$Env:ProgramFiles\MATLAB\$matlab_version
fileInstallationKey=$fileInstallationKey
agreeToLicense=yes
outputFile=C:\tmp\setuplog_matlab.txt
lmgrFiles=$license_file
lmgrFiles=$license_file
enableLNU=yes
mode=silent
"@;
$installer_input = ($base_input + $args) -join "`n"
$installer_input | Out-File $installer_input_file -Encoding utf8
# install MATLAB
if ( -not (Test-Path -Path 'C:\Program Files\MATLAB\*\bin\matlab.exe')) {
Write-Host "Begin matlab installation"
Start-Process -NoNewWindow -Wait -FilePath D:\setup.exe -ArgumentList @('-inputFile', $installer_input_file)
Write-Host "Finish matlab installation"
}
Stop-Transcript
param()
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "C:\tmp\log_winget.txt" -append
Write-Host "Installing matlab"
# Based on this gist: https://gist.github.com/crutkas/6c2096eae387e544bd05cde246f23901
$hasPackageManager = Get-AppPackage -name 'Microsoft.DesktopAppInstaller'
if (!$hasPackageManager -or [version]$hasPackageManager.Version -lt [version]"1.10.0.0") {
"Installing winget Dependencies"
Add-AppxPackage -Path 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
$releases_url = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releases = Invoke-RestMethod -uri $releases_url
$latestRelease = $releases.assets | Where { $_.browser_download_url.EndsWith('msixbundle') } | Select -First 1
"Installing winget from $($latestRelease.browser_download_url)"
Add-AppxPackage -Path $latestRelease.browser_download_url
}
else {
"winget already installed"
}
# Configure WinGet
Write-Host "Configuring winget"
# winget config path from: https://github.com/microsoft/winget-cli/blob/master/doc/Settings.md#file-location
$settingsPath = "$env:LOCALAPPDATA/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json";
$settingsJson =
@"
{
// For documentation on these settings, see: https://aka.ms/winget-settings
"experimentalFeatures": {
"experimentalMSStore": true,
}
}
"@;
$settingsJson | Out-File $settingsPath -Encoding utf8
Stop-Transcript
param()
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_wsl.txt" -append
$Wsl = New-Module -AsCustomObject -ScriptBlock {
function Command($feature) {
& wsl @($args)
}
}
# Install Ubuntu Distro
if ( -not (wsl --list --quiet) ) {
Write-Host "Download Ubuntu 2004 Distribution"
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile c:/tmp/Ubuntu.appx -UseBasicParsing
Write-Host "Install Ubuntu 2004 Distribution"
Add-AppxPackage -Path c:/tmp/Ubuntu.appx
$Wsl.Command('--install', '--root')
$Wsl.Command('--set-version', 'Ubuntu-20.04', '2')
$Wsl.Command('--update', '--status')
$Wsl.Command('--shutdown')
} else {
Write-Host "Installed"
}
Stop-Transcript
param()
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_wsl.txt" -append
$path = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
);
Write-Host "Check WSL Update"
if (-not ((Get-ItemProperty $path).DisplayName | Select-String 'Windows Subsystem for Linux Update')) {
Write-Host "Install WSL Update"
$webDeployInstallerFilePath = "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
$arguments = "/i `"$webDeployInstallerFilePath`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
} else {
Write-Host "Installed"
}
Stop-Transcript
param
(
[string]$user,
[string]$pass,
[string]$description
)
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
if ( -not ((Get-LocalUser).Name | Select-String "^$user$") ) {
New-LocalUser -Name $user -Password (ConvertTo-SecureString "$pass" -AsPlainText -Force) -PasswordNeverExpires -Description "$description"
}
if ( -not ((Get-LocalGroupMember -Group 'Administrators').Name | Select-String "\\$user$") ) {
Add-LocalGroupMember -Group 'Administrators' -Member $user
}
# autologin
$winLogging ='HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
New-ItemProperty -Path $winLogging -Name AutoAdminLogon -PropertyType String -Value 1 -force | Out-Null
New-ItemProperty -Path $winLogging -Name DefaultUserName -PropertyType String -Value $user -force | Out-Null
New-ItemProperty -Path $winLogging -Name DefaultPassword -PropertyType String -Value $pass -force | Out-Null
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
trap {
Write-Output "ERROR: $_"
Write-Output (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
Exit 1
}
#---------------
Start-Transcript "c:\tmp\log_setting_emacs.txt" -append
if ( Test-Path "$Env:APPDATA\.emacs.d" ) {
if ( -not ( Test-Path "$Env:APPDATA\.emacs.d\.git" ) ) {
Write-Host "Removing..."
Remove-Item -Force -Recurse -Path "$Env:APPDATA\.emacs.d"
Write-Host "CLone .emacs.d"
$Git = New-Module -AsCustomObject -ScriptBlock {
function Clone {
& git @('clone', '-q', 'https://github.com/hiono/.emacs.d.git', "$Env:APPDATA\.emacs.d")
}
}
$Git.Clone()
}
}
Stop-Transcript
param
(
[string]$GIT_AUTHOR_NAME,
[string]$GIT_AUTHOR_EMAIL
)
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
trap {
Write-Output "ERROR: $_"
Write-Output (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
Exit 1
}
#---------------
Start-Transcript "c:\tmp\log_setting_git.txt" -append
git config --global user.name $GIT_AUTHOR_NAME
git config --global user.email $GIT_AUTHOR_EMAIL
git config --global credential.helper manager-core
Stop-Transcript
param()
#---------------
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
trap {
$exitCode = $LASTEXITCODE
Write-Host "Exit code was $exitCode"
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
}
setx.exe trigger 1 # run arbitrary win32 application so LASTEXITCODE is 0
#---------------
Start-Transcript "c:\tmp\log_remove_apps.txt" -append
$ErrorActionPreference = "Stop"
Write-Host "Uninstall Apps"
$apps = @(
"Microsoft.BingWeather",
"Microsoft.GetHelp",
"Microsoft.Getstarted",
"Microsoft.Microsoft3DViewer",
"Microsoft.MicrosoftOfficeHub",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.MicrosoftStickyNotes",
"Microsoft.MixedReality.Portal",
"Microsoft.MSPaint",
"Microsoft.Office.OneNote",
"Microsoft.People",
"Microsoft.WindowsAlarms",
"Microsoft.WindowsCamera",
"microsoft.windowscommunicationsapps",
"Microsoft.WindowsFeedbackHub",
"Microsoft.WindowsMaps",
"Microsoft.Xbox.TCUI",
"Microsoft.XboxApp",
"Microsoft.XboxGameOverlay",
"Microsoft.XboxGamingOverlay",
"Microsoft.XboxIdentityProvider",
"Microsoft.XboxSpeechToTextOverlay",
"Microsoft.YourPhone",
"Microsoft.ZuneMusic",
"Microsoft.ZuneVideo",
"Microsoft.Advertising.Xaml",
"Microsoft.549981C3F5F10",
"Microsoft.SkypeApp",
"SpotifyAB.SpotifyMusic",
"Microsoft.WindowsSoundRecorder"
);
Foreach ($app in $apps) {
try {
Write-Host "Uninstalling: " $app
if ( -not (Get-AppxPackage -Name $app ) ) {
Remove-AppxPackage -AllUsers -Package (Get-AppxPackage -Name $app)..PackageFullName
}
} catch [Exception] {
Write-Host "Exception: " $error[0]
}
}
Stop-Transcript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment