Remove-ChocolateyPackage.ps1

function Remove-ChocolateyPackage() {
    [cmdletbinding(SupportsShouldProcess=$True)]
    Param(
        [Parameter(ValueFromPipeline = $true, Position = 0)]
        [string[]] $Packages,
        [Alias("f")]
        [switch] $Force,
        [Alias("y")]
        [switch] $Accept,
        [switch] $Pre,
        [string] $Version,
        [Alias("s")]
        [string] $Source,
        [Alias("u")]
        [string] $User,
        [Alias("p")]
        [string] $Password,
        [Alias("n")]
        [switch] $NoInstall,
        [Alias("m")]
        [switch] $Multiple,
        [string[]] $Params,
        [string[]] $InstallerArgs
    )

    Process {
        if(! (Test-Path Env:\ChocolateyInstall)) {
            Write-Warning "Chocolatey is not installed or the ChocolateyInstall environment variable is missing."
            Write-Warning "Verify that chocolatey is installed and that ChocolateyInstall exists in your environment variables."
            return;
        }

        if($Packages -eq $Null -or $Packages.Length -eq 0) {
            $package = Read-Host -Prompt "Enter Package Name"
            if([string]::IsNullOrWhiteSpace($package)) {
                Write-Warning "PackageName was empty. Exiting operation. =("
                return;
            }

            $Packages = @($package);
        }

        $d = $PSBoundParameters.Debug.IsPresent;
        $v = $PSBoundParameters.Verbose.IsPresent;
        $whatIf = $PSBoundParameters.WhatIf.IsPresent;
        $yes = $Accept.ToBool()
        
        if($yes -eq $false) {
            $yes = Get-ChocolateyAccept;
        }

        $flags = "";
        if($yes -or $f) {
            $flags += "y"
        }

        if($f) {
            $flags += "f";
        }

        if($d) {
            $flags += "d";
        }

        if($v) {
            $flags += "v";
        }

        if($NoInstall.ToBool()) {
            $flags += "n"
        }

        if($Multiple.ToBool()) {
            $flags += "m";
        }

        if($flags.Length -gt 0) {
            $flags = "-$flags";
        }
    
        if($Pre.ToBool()) {
            $flags += " --pre"
        }

        if(![string]::IsNullOrWhiteSpace($Source)) {
            $flags += " -s=`"$Source`""
        }

        if(![string]::IsNullOrWhiteSpace($User)) {
            $flags += " -u=`"$User`""
        }

        if(![string]::IsNullOrWhiteSpace($Password)) {
            $flags += " -p=`"$Password`""
        }

        if($whatIf) {
            $flags += " --whatif"
        }
        
        if($Params -ne $Null -and $Params.Length -gt 0) {
            $parameters = [String]::Join(" ", $Params);
            $flags += " --params=`"$parameters`""
        }

        if($InstallerArgs -ne $null -and $InstallerArgs.Length -gt 0) {
            $parameters = [String]::Join(" ", $InstallerArgs);
            $flags += " --installer-args=`"$parameters`""
        }

        foreach($packageName in $Packages) {
            $cmd = "choco uninstall $packageName $flags"

            if($PSCmdlet.ShouldProcess($cmd)) {
                & $cmd;
            }
        }
    }
}