PoshCode Archive  Artifact [1095ba36ea]

Artifact 1095ba36eadbfb32f94b20a4a767a89266a05c5c036bf68b54c47fc3152a10d3:

  • File Get-UNCPath.ps1 — part of check-in [68fe568905] at 2018-06-10 13:58:37 on branch trunk — Simple function that returns the UNC path (administrative share) of a local path. (user: dragonmc77 size: 646)

# encoding: ascii
# api: powershell
# title: Get-UNCPath
# description: Simple function that returns the UNC path (administrative share) of a local path.
# version: 0.1
# type: function
# author: dragonmc77
# license: CC0
# function: Get-UNCPath
# x-poshcode-id: 5655
# x-archived: 2015-11-26T03:22:38
# x-published: 2015-12-30T18:53:00
#
#
function Get-UNCPath {param(	[string]$HostName,
				[string]$LocalPath)
	$NewPath = $LocalPath -replace(":","$")
	#delete the trailing \, if found
	if ($NewPath.EndsWith("\")) {
		$NewPath = [Text.RegularExpressions.Regex]::Replace($NewPath, "\\$", "")
	}
	"\\$HostName\$NewPath"
}