PoshCode Archive  Artifact Content

Artifact e8decfbf66f8ecd8abaf56272632867a489c8190080a6af9198ce4f826fecaf8:

  • File whatis.ps1 — part of check-in [dab7698723] at 2018-06-10 13:50:20 on branch trunk — Looks for online information about file with it extension. (user: greg zakharov size: 1017)

# 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
}