PoshCode Archive  Artifact [96c4cb1e1a]

Artifact 96c4cb1e1a947bf941824347f063f9ca7e991bb6b14d5bfb2a5cc861fb07343b:

  • File Get-UNCPath.ps1 — part of check-in [ded95ee2e1] at 2018-06-10 13:58:39 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: 5656
# x-archived: 2015-11-24T08:32:51
# 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"
}