0
votes

I am struggling to write powershell scripts to copy files/ directories from my network drive to another share. During the investigations, I found that the powershell is unable to recognize UNC path in my environment.

For example, I can access \tfsbuildServer02\drop path from the explorer. but while trying to test this path in Powershell script, it returns False

Test-Path -Path "\\tfsbuildServer02\drop"

As a result, the Copy-Item commands are also not working.

Can anyone please suggest what could be the issue?

I am running Powershell ISE in Administrator mode only.

3
This looks like NTFS or share permissions problem. Double-check that you have good permissions (not relying on, say, administrators group membership only.)vonPryz

3 Answers

0
votes

powershell command works fine with UNC paths , have been using Test-Path command on UNC path with out any issue, copied files from local to remote using UNC path.

Check below conditions :

  1. you need to use valid UNC paths [\tfsbuildServer02\drop can be \tfsbuildServer02\e$\drop]

  2. you need to have write access on that folder , check your permissions on folder using powershell command Icacls

0
votes

I'd have to concur with vonPryz; I'm getting a valid path for my environment. I'd double check permissions as suggested. Please report back though.

0
votes

I've run into this when I am connected to another customer's VPN. PowerShell can access network UNCs on my LAN normally, but when I connect to a customer's VPN, PowerShell doesn't see them. The odd thing is that Windows Explorer sometimes does. My work around is to use a fully qualified domain name. So instead of "\tfsbuildServer02\drop", I use "\tfsbuildServer02.mycompany.local\drop" instead.