PowerShell – Get an UNC of a remote folder

To Read/Write/Rename/Copy/Delete a file configured across ‘N’ of servers in the same path, this script is going to be very handy. One example – Citrix Migration – IMA data store

Input – ServerName and Input folder path.

$server =”Server01

$InputPath=”C:\Program Files\Citrix\Independent Management Architecture

Execute the below Powershell script

FUNCTION getUNCPath($infile)
{
$qualifier = Split-Path $infile -qualifier
$drive = $qualifier.substring(0,1)
$noqualifier = Split-Path $infile -noQualifier
“$drive`$$noqualifier”
}

$server =”Server01″

$InputPath=”C:\Program Files\Citrix\Independent Management Architecture”

$UNC=getUNCPath($infile)

$Path=”\\$Server\$UNC”

write-host $Path

Output – \\Server01\C$\Program Files\Citrix\Independent Management Architecture

About these ads

About Prashanth Jayaram

I’m a Database technologist having 8+ years of rich, hands-on experience on Database technologies. I am Microsoft Certified Professional and backed with a Degree in Master of Computer Application. My expertise lies in T-SQL programming, Replication and PowerShell. hobbies are playing sports and drawing.
This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s