PoshCode Archive  Artifact [896aeea970]

Artifact 896aeea9706d53b4a57d8514d828f974ddd6f24701b3666dc2b730ad7c4f79df:

  • File Get-UNCPath.ps1 — part of check-in [63137c7920] at 2018-06-10 13:58:40 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: 5657
# x-archived: 2015-11-24T08:27:33
# 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"
}