Search This Blog
Friday, May 02, 2025
Remove .appx from some newly converted to LTSC computers
$ErrorActionPreference= 'silentlycontinue'
$cred = Get-Credential -Message "Please enter admin credentials valid on target computers";
if($cred -isnot [PSCredential]) {Write-Host -ForegroundColor Red -BackgroundColor DarkBlue "No valid credentials provided. Exiting!" ; exit 1}
foreach($comp in Get-Content -Path C:\temp\complist.txt) {
Write-Host -ForegroundColor Blue -NoNewline " `nStart on $comp : "
$sess = New-PSSession -Credential $cred $comp
if ($?) { Write-Host -ForegroundColor Green "session to $comp established";
Invoke-Command -Session $sess -scriptblock { Get-AppxPackage -AllUsers | Remove-AppxPackage -ErrorAction Continue; Get-AppxProvisionedPackage -Online | Remove-AppxProvisionedPackage -Online; }
if ($?) { Write-Host -ForegroundColor Green "RAN on $sess" } else { Write-Host -ForegroundColor Red "FAIL on $sess" }
}else{ Write-Host -ForegroundColor Red "Unable to connect to $comp" }
}
Write-Host -ForegroundColor Yellow -BackgroundColor DarkGreen "`nScript Done!`n"
exit
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment