Advertisement
Guest User

Untitled

a guest
May 25th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Function Join-AdminUNC {
  2. <#
  3. .SYNOPSIS
  4. Parses a path to make it an admin UNC.
  5.  
  6. .EXAMPLE
  7. Join-AdminUNC sqlserver C:\windows\system32
  8. Output: \\sqlserver\c$\windows\system32
  9.  
  10. .OUTPUTS
  11. String
  12.  
  13. #>
  14. [CmdletBinding()]
  15. param(
  16. [Parameter(Mandatory = $true)]
  17. [ValidateNotNullOrEmpty()]
  18. [string]$servername,
  19.  
  20. [Parameter(Mandatory = $true)]
  21. [ValidateNotNullOrEmpty()]
  22. [string]$filepath
  23.  
  24. )
  25.  
  26. if (!$filepath) { return }
  27. if ($filepath.StartsWith("\\")) { return $filepath }
  28.  
  29. if ($filepath.length -gt 0 -and $filepath -ne [System.DBNull]::Value) {
  30. $newpath = Join-Path "\\$servername\" $filepath.replace(':\','$\')
  31. return $newpath
  32. }
  33. else { return }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement