Windows 10/11 pe pre-installed aur unwanted app packages ko manage karna ek mushkil kaam ho sakta hai. Ye packages, jise hum "bloatware" kehte hain, valuable system resources consume karte hain aur user interface ko clutter kar dete hain. Windows kuch tools provide karta hai in packages ko manage karne ke liye, par ye process PowerShell script se aur bhi easy ho sakta hai.
Is article mein di gayi PowerShell script ek simple aur effective method offer karti hai AppX packages ko uninstall karne ka, including those jo Windows ke sath pre-installed hote hain. Ye script unwanted packages ko identify, list aur remove karne ka process automate karti hai, jisse users apne systems ko declutter kar sakein.
Ye script kuch straightforward steps mein kaam karti hai:
Ye saare installed AppX packages ko list karti hai. Ye user ko prompt karti hai ki wo uninstall karne wale packages ki ek list banaye. Ye is list se package names ko read karti hai aur har ek ko uninstall karne ki koshish karti hai. Ye feedback deti hai kisi bhi package ke baare mein jo found nahi ho paya ya uninstall nahi ho paya. Ye guide aapko script ke through walk-through karega, har step ko detail mein explain karega, taaki aap ise effectively use kar sakein aur apne Windows 10/11 system se unwanted app packages ko manage aur remove kar sakein.
Maine apko puri script ka detailed breakdown niche diya hai ap ise copy karke apne kaam mein bhi le sakte hai aur ise samajh bhi sakte hai. Is Script ka use apko kaise karna hai iska detail mein demonstration humne video ke madhayam se bhi diya hai jise ap dekh sakte hai.
Get-AppxPackage | Select Name, PackageFullName | Out-Host
Write-Host "Please create a text file called debloatlist.txt, then copy the names of the packages you want to uninstall into it, one per line." Write-Host "NOTE: Some of the packages listed above are important. Do not uninstall any packages if you're unsure about their function!" Write-Host "" Write-Host "Then press any key to continue ..." Read-Host if (-not (Test-Path -Path 'debloatlist.txt')) { Write-Host "Error: debloatlist.txt not found. Please create it in the same directory as this script, and add the packages you want to uninstall." return } $lines = Get-Content -Path 'debloatlist.txt' $notFound = @() foreach ($line in $lines) { $line = $line.Trim() if (-not [string]::IsNullOrWhiteSpace($line)) { $package = Get-AppxPackage | Where-Object { $_.Name -eq $line -or $_.PackageFullName -eq $line } if ($package) { try { $package | Remove-AppxPackage -ErrorAction Stop } catch { Write-Host "Error while trying to uninstall $($line): $_" $notFound += $line } } else { $notFound += $line } } } if ($notFound) { Write-Host "[!!!] WARNING: The following packages were not found and could not be uninstalled:" Write-Host "" foreach ($package in $notFound) { Write-Host "`t$package" } Write-Host "" Write-Host "Please re-check the names to ensure they exactly match a package's 'Name' or 'PackageFullName'." Write-Host "(Also check if the Full Name was truncated with '...', and if so try the shorter 'Name' string.)" Write-Host "" }Explanation of Script
Get-AppxPackage | Select Name, PackageFullName | Out-HostThis command retrieves all installed AppX packages on the system and displays their Name and PackageFullName properties.
Write-Host "Please create a text file called debloatlist.txt, then copy the names of the packages you want to uninstall into it, one per line." Write-Host "NOTE: Some of the packages listed above are important. Do not uninstall any packages if you're unsure about their function!" Write-Host "" Write-Host "Then press any key to continue ..." Read-HostThis section of the script displays instructions to the user, asking them to create a text file named debloatlist.txt and populate it with the names of the packages they wish to uninstall, one per line. The script then pauses and waits for the user to press a key to continue.
if (-not (Test-Path -Path 'debloatlist.txt')) { Write-Host "Error: debloatlist.txt not found. Please create it in the same directory as this script, and add the packages you want to uninstall." return }The script checks if debloatlist.txt exists in the same directory. If the file is not found, it displays an error message and stops execution.
$lines = Get-Content -Path 'debloatlist.txt'This line reads the contents of debloatlist.txt into an array called $lines, where each element is a line from the file.
$notFound = @()
foreach ($line in $lines) { $line = $line.Trim() if (-not [string]::IsNullOrWhiteSpace($line)) { $package = Get-AppxPackage | Where-Object { $_.Name -eq $line -or $_.PackageFullName -eq $line } if ($package) { try { $package | Remove-AppxPackage -ErrorAction Stop } catch { Write-Host "Error while trying to uninstall $($line): $_" $notFound += $line } } else { $notFound += $line } } }Trim Whitespace:
if ($notFound) { Write-Host "[!!!] WARNING: The following packages were not found and could not be uninstalled:" Write-Host "" foreach ($package in $notFound) { Write-Host "`t$package" } Write-Host "" Write-Host "Please re-check the names to ensure they exactly match a package's 'Name' or 'PackageFullName'." Write-Host "(Also check if the Full Name was truncated with '...', and if so try the shorter 'Name' string.)" Write-Host "" }If there were any packages that could not be found or uninstalled, the script displays a warning message listing those packages. It advises the user to check the names for exact matches and to be aware of potential truncations in package names.
0 टिप्पणियाँ