Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Join-AdminUNC {
- <#
- .SYNOPSIS
- Parses a path to make it an admin UNC.
- .EXAMPLE
- Join-AdminUNC sqlserver C:\windows\system32
- Output: \\sqlserver\c$\windows\system32
- .OUTPUTS
- String
- #>
- [CmdletBinding()]
- param(
- [Parameter(Mandatory = $true)]
- [ValidateNotNullOrEmpty()]
- [string]$servername,
- [Parameter(Mandatory = $true)]
- [ValidateNotNullOrEmpty()]
- [string]$filepath
- )
- if (!$filepath) { return }
- if ($filepath.StartsWith("\\")) { return $filepath }
- if ($filepath.length -gt 0 -and $filepath -ne [System.DBNull]::Value) {
- $newpath = Join-Path "\\$servername\" $filepath.replace(':\','$\')
- return $newpath
- }
- else { return }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement