PoshCode Archive  Artifact [06c22ed232]

Artifact 06c22ed23270c3792576f5714b9cd5a3a55e8e5180181b612503da72f990e5dc:

  • File Get-UNCPath.ps1 — part of check-in [9eef76be4b] at 2018-06-10 13:45:43 on branch trunk — Simple function that returns the UNC path (administrative share) of a local path. (user: dragonmc77 size: 645)

# 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: 478
# x-archived: 2015-12-25T19:17:41
# x-published: 2008-07-24T09:09: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"
}