functions/appdev/Get-FilenameFromContentDisposition.ps1

function Get-FilenameFromContentDisposition {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [string]$ContentDisposition
    )

    if ($ContentDisposition -match 'filename\*?=([^;]+)') {
        return $matches[1] -replace "^''", ""
    } elseif ($ContentDisposition -match 'filename="(.+?)"') {
        return $matches[1]
    }
}