functions/UnRegister-Repository.ps1

function UnRegister-Repository {
[CmdletBinding()]
Param (
    [Parameter(Mandatory=$true)]
    [string]
    $RepositoryName
)

begin {

$repo = Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue
}
process {
if($repo -ne $null)
{
    Write-Debug "Removing the Repository $RepositoryName"
    Unregister-PSRepository -Name $RepositoryName
}
else
{
    Write-Debug "The repository $RepositoryName does not exist. Skipped removal."
}
}
end {}
}