# encoding: ascii
# api: powershell
# title: Get-MimeType
# description: another way to retrieve mime type
# version: 0.1
# type: function
# author: greg zakharov
# license: CC0
# function: Get-MimeType
# x-poshcode-id: 4935
# x-archived: 2017-03-01T10:39:56
# x-published: 2014-02-27T14:50:00
#
#
#requires -version 2.0
function Get-MimeType {
  <#
    .NOTES
        Author: greg zakharov
  #>
  param(
    [Parameter(Mandatory=$true, ValueFromPipeLine=$true)]
    [ValidateScript({Test-Path $_})]
    [String]$FileName
  )
  
  begin {
    Add-Type -AssemblyName System.Web
    $FileName = cvpa $FileName
  }
  process {
    ([AppDomain]::CurrentDomain.GetAssemblies() | ? {
      $_.FullName.Contains('System.Web')
    }).GetType(
      'System.Web.MimeMapping'
    ).GetMethod(
      'GetMimeMapping', [Reflection.BindingFlags]40
    ).Invoke(
      $null, @($FileName)
    )
  }
  end {}
}
