Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function ConvertTo-UNCPath {
Convert a path to UNC path
Convert a path to UNC path
Author: Øyvind Kallstad
Date: 26.10.2015
Version: 1.0
param (
[Parameter(Position = 2, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string] $Path,
[Parameter(Position = 1)]
[string] $ComputerName
$pathRoot = [System.IO.Path]::GetPathRoot($Path)
Write-Output ("\\$($ComputerName)$(($Path).Replace($pathRoot, "\$($Path[0])$\"))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment