PoshCode Archive  Artifact [eeb892f6a5]

Artifact eeb892f6a55f6b1f457bb956b08655c58fef8b5e4f36cdced7a9743d930317b8:

  • File New-UrlFile.ps1 — part of check-in [097624294a] at 2018-06-10 13:35:48 on branch trunk — Use this to create a .url file which can then be opened in your default browser using the Invoke-Item cmdlet. Usage: New-UrlFile $url # or invoke-item (new-urlfile $url) (user: halr9000 size: 749)

# encoding: ascii
# api: powershell
# title: New-UrlFile
# description: Use this to create a .url file which can then be opened in your default browser using the Invoke-Item cmdlet.  Usage: New-UrlFile $url # or invoke-item (new-urlfile $url)
# version: 0.1
# type: function
# author: halr9000
# license: CC0
# function: New-UrlFile
# x-poshcode-id: 407
# x-archived: 2016-04-19T06:38:14
# x-published: 2009-05-23T05:38:00
#
#
function New-UrlFile
{
	param( $URL = "http://www.google.com")
	$UrlFile = [system.io.Path]::ChangeExtension([system.io.Path]::GetTempFileName(),".url")
	$UrlFileContents = `
		"[InternetShortcut]",
		"URL=$URL"
	Write-Host $URL
	$UrlFileContents | Set-Content -Path $UrlFile
	Get-Item $UrlFile
}