Functions/Uninstall-AllChocolateyPackages.ps1

function Uninstall-AllChocolateyPackages {
    # List all packages installed and then uninstall them (-x = manage dependencies)

    if (Get-Command choco.exe -ErrorAction SilentlyContinue) {
        Write-Output "Chocolatey is installed. Uninstalling all packages and chocholatey itself. Please wait..."
        choco list -l | foreach-object { $_.Split(" ")[0] } | foreach-object { choco uninstall $_ -x }
    }
    else {
        Write-Output "Chocolatey is not installed."
    }
}