# encoding: ascii
# api: powershell
# title: whatis
# description: Looks for online information about file with it extension.
# version: 0.1
# type: function
# author: greg zakharov
# license: CC0
# function: Get-ObjectType
# x-poshcode-id: 5122
# x-archived: 2014-08-29T23:46:27
# x-published: 2014-04-28T19:22:00
#
#
if (!(Test-Path alias:whatis)) { Set-Alias whatis Get-ObjectType }

function Get-ObjectType {
  <#
    .NOTES
        Author: greg zakharov
  #>
  param(
    [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
    [ValidateScript({Test-Path $_})]
    [String]$Object
  )
  
  $raw = gi (cvpa $Object)
  if ($raw.PSIsContainer) {
    "{0} - folder path`n" -f $raw
    return
  }
  
  if ([String]::IsNullOrEmpty($raw.Extension)) {
    "File has not an extension.`n"
    return
  }
  
  $raw = 'http://pc.net/extensions/file/' + $raw.Extension.Substring(1, $raw.Extension.Length - 1)
  &(cmd /c ftype (cmd /c assoc .htm).Split('=')[1]).Split('"')[1] $raw
}
