Skip to content

Instantly share code, notes, and snippets.

@gravejester
Created October 26, 2015 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravejester/794a364279b33ee562f8 to your computer and use it in GitHub Desktop.
Save gravejester/794a364279b33ee562f8 to your computer and use it in GitHub Desktop.
function ConvertTo-UNCPath {
<#
.SYNOPSIS
Convert a path to UNC path
.DESCRIPTION
Convert a path to UNC path
.NOTES
Author: Øyvind Kallstad
Date: 26.10.2015
Version: 1.0
.INPUTS
System.String
.OUTPUTS
System.String
.LINK
https://communary.wordpress.com/
#>
[CmdletBinding()]
param (
[Parameter(Position = 2, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[string] $Path,
[Parameter(Position = 1)]
[ValidateNotNullOrEmpty()]
[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