0
votes

I'm trying to get Get-Acl to work but it seems that when I use UNC path, it returns false. I ran Test-Path and it also returns false.

I tested Test-Path on my local folders and still the same. UNC path returns false but when normal path it returns true. What am I doing wrong?

PS C:\windows\system32> Get-Acl \\computername\Asset
Get-Acl : Cannot find path '\\phmangang01\Asset' because it does not exist.
At line:1 char:1
+ Get-Acl \\phmangang01\Asset
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-Acl], ItemNotFoundException
    + FullyQualifiedErrorId : GetAcl_PathNotFound_Exception,Microsoft.PowerShell.Commands.GetAclCommand

PS C:\windows\system32> Get-Acl C:\Asset

    Directory: C:\

Path  Owner                  Access
----  -----                  ------
Asset BUILTIN\Administrators BUILTIN\Administrators Allow  FullControl...

PS C:\windows\system32> Test-Path \\computer name\Asset
False
PS C:\windows\system32> Test-Path C:\Asset
True
1
You are missing a backslash \ > should be test-path \\ComputerName\C$ - T-Me
sorry, I've must deleted it while editing the computername PS C:\windows\system32> Test-Path \\computername\Asset False PS C:\windows\system32> Test-Path C:\Asset True - Gang12
try to add the drive test-path \\ComputerName\C$\Asset - T-Me
ohh now it is working. Why is that? I tried it on a fileshare both returns false PS C:\windows\system32> Test-Path \\server\C$\nartools False PS C:\windows\system32> Test-Path \\server\nartools False - Gang12
Has the folder been shared in the first place? What does net share on the server show? - Ansgar Wiechers

1 Answers

0
votes

If you don't have any shares on your target machine, your have to add the drive in the unc path. But if so you further have to mask the $-symbol with a tick mark, because it's a special regex-character: "\\ComputerName\C`$\Asset"