Thursday, February 18, 2021

Removing Windows 10 Provisioned Universal Windows Platform (UWP) (AppX) apps

 

During a first logon to Windows 10 some time is taken to setup UWP apps for the user.  During the build phase you may wish to remove some of the ones you do not need.

Microsoft.549981C3F5F10
Microsoft.BingWeather
Microsoft.DesktopAppInstaller
Microsoft.GetHelp
Microsoft.Getstarted
Microsoft.HEIFImageExtension
Microsoft.Microsoft3DViewer
Microsoft.MicrosoftEdge.Stable
Microsoft.MicrosoftOfficeHub
Microsoft.MicrosoftSolitaireCollection
Microsoft.MicrosoftStickyNotes
Microsoft.MixedReality.Portal
Microsoft.MSPaint
Microsoft.Office.OneNote
Microsoft.People
Microsoft.ScreenSketch
Microsoft.SkypeApp
Microsoft.StorePurchaseApp
Microsoft.VCLibs.140.00
Microsoft.VP9VideoExtensions
Microsoft.Wallet
Microsoft.WebMediaExtensions
Microsoft.WebpImageExtension
Microsoft.Windows.Photos
Microsoft.WindowsAlarms
Microsoft.WindowsCalculator
Microsoft.WindowsCamera
microsoft.windowscommunicationsapps
Microsoft.WindowsFeedbackHub
Microsoft.WindowsMaps
Microsoft.WindowsSoundRecorder
Microsoft.WindowsStore
Microsoft.Xbox.TCUI
Microsoft.XboxApp
Microsoft.XboxGameOverlay
Microsoft.XboxGamingOverlay
Microsoft.XboxIdentityProvider
Microsoft.XboxSpeechToTextOverlay
Microsoft.YourPhone
Microsoft.ZuneMusic
Microsoft.ZuneVideo

Run this script logged in as admin and elevated.

#get provisioned apps
$AppxProv = Get-AppxProvisionedPackage -Online

#Enter the Apps you want to keep into this array

$AppsToKeep = @("Microsoft.MicrosoftOfficeHub","Microsoft.WindowsCalculator","Microsoft.Office.OneNote","Microsoft.WindowsCamera")

#loop through them

foreach ($AppxProvItem in $AppxProv)

    {
    
    $AppxprvDN = $AppxProvItem | Select -expand DisplayName

         if ($AppxprvDN -notin $AppsToKeep)

            {
            #Get the package full name
            $AppxTargetPFN = Get-AppxPackage -Name $AppxPrvDN | Select -expand PackageFullName

            #first remove the package from the logged on session
            Remove-AppxPackage -Package $AppxTargetPFN

            #then target the provisioned Appx version
            $AppxPrvTarget = Get-AppxProvisionedPackage -Online | where{$_.DisplayName -like $AppxPrvDN}

            $AppxPrvTargetPN = $AppxPrvTarget | Select -expand PackageName

            Remove-AppxProvisionedPackage -Online -PackageName $AppxPrvTargetPN

            }

    }

Monday, February 8, 2021

Suppress screen output errors

Insert this at the top of a script to stop error information appearing in the output that you are trying to read!

$ErrorActionPreference= 'silentlycontinue'

Tuesday, January 12, 2021

Change Permissions and overwrite img0.jpg

 C:\Windows\Web\Wallpaper\Windows\img0.jpg is typically the default wallpaper for Windows 10.  As part of the OS can be tricky to change unless you adjust the permissions.  This script was designed to run in an SCCM task sequence

$ScriptsPath = Split-Path - Parent $MyInvocation.MyCommand.Path

$img0new = $ScriptsPath+"\img0.jpg
$img0 = "C:\Windows\Web\Wallpaper\Windows\img0.jpg

#modify default permissions on img0.jpg
takeown /f $img0
icacls $img0 /Grant 'System:(F)'

Copy-Item -Path $img0new -Destination $img0 -Force

Wednesday, October 21, 2020

Powershell popup


Article on how to produce pop-ups in powershell.

 https://powershell.org/2013.04/powershell-popup


$wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
$wshell.Popup("Are you looking at me?",0,"Hey!",48+4)

Tuesday, March 10, 2020

Test-Connection has a TCPPort option in Powershell v6+


Powershell versions 6 and above provide the test-connection cmdlet with a port specification option

-TCPPort <portnumber>

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection/?view=powershell-7


Note that ISE is not used for versions of powershell above 5.1.
https://docs.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise?view=powershell-7


Visual Studio Code is recommended as the replacement for Powershell ISE
https://code.visualstudio.com/



Wednesday, January 22, 2020

Using Primary Group IDs



Primary Group IDs are the RIDs for the Domain groups. The full list is here: Interesting Windows Computer & Active Directory Well-Known Security Identifiers (SIDs).

515 – Domain Computers
516 – Domain Controllers (writable)
521 – Domain Controllers (Read-Only)
This information helps filter computer objects to return only the desired computer type.
https://adsecurity.org/?p=873


example

Get-ADComputer -Filter {PrimaryGroupID -eq 515} | where {$_.name -like "?????xw*" -or $_.name -like "DESKTOP*"} | select name | sort name | out-file $outputFile


Friday, December 6, 2019

alternative code not alternative facts



$winver = Get-wmiobject win32_operatingsystem | select -ExpandProperty version

The above produces the same value as the line below.  Below seems a much neater.

$winver = (get-wmiobject Win32_OperatingSystem).version




That's the alternative code but what is an alternative fact !?
Find out here: