How can I clean my org and uninstall all packages from a particular org as quickly and simply as possible?

1 Answer 1


Assuming there are only 2GMP packages installed in the org, and no unmanaged components refer the package components, the following simple script can be used:

for OUTPUT in $(sfdx force:package:beta:installed:list --json | jq '.result [] .SubscriberPackageVersionId'  -r)
    sfdx force:package:uninstall -w 500 -p  $OUTPUT

Otherwise you need to resolve dependencies first. For the 1GMP, it is possible to try to generate a destructiveChanges.xml with InstalledPackage metadata component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.