SharePoint: Create Managed Path through powershell

Following function can be used to create managed paths in SharePoint using Powershell.

function Create-SPManagedPath
{
    param ($webApplicationUrl, $managedPathName)
    $managedPath = Get-SPManagedPath -WebApplication $webApplicationUrl -Identity $managedPathName -ErrorAction SilentlyContinue
    if ($managedPath -ne $null)
    {
        Write-Host "Managed path $managedPathName already exists."
        return
    }

    Write-Host "Creating managed path $managedPathName ..."
    New-SPManagedPath RelativeURL $managedPathName -WebApplication $webApplicationUrl
    Write-Host "Managed path $managedPathName created sucessfully" -foregroundcolor Green
}

The function can be called as follows:
Create-SPManagedPath "http://demo2010a"  "Regions"

Above call creates a managed path named Regions in "http://demo2010a" web application.