0

I am trying to list out all directories and their sub directories on the network share. Issue I am facing is the roots1.txt file has just network folders for example \\xxxx and not \\xxxx\xx and i need the list of subfolders in \\xxxx This code works when i use it with \\xxxx\xx but when I try it with \\xxxx it gives the error

get-childitem : Cannot find path '\\' because it does not exist.

 $RootPath = Get-Content -Path "$PSScriptRoot\roots1.txt" $hash = Get-ChildItem -Path $RootPath -Directory -Recurse -force | Group-Object directoryname -AsHashTable -AsString $hash.GetEnumerator() | ForEach-Object { [PSCustomobject]@{Path = $_.value.fullname -join '|'}} | Export-Csv -Path C:\Users\darpan.vedi\Desktop\paths.csv -NoTypeInformation 
4
  • \\xxxx is not a folder or share - it's a host, and you can't enumerate its contents like a normal folder. Commented Jul 16, 2018 at 14:04
  • @MathiasR.Jessen Is there any way to enumerate the folders present in the host? Commented Jul 16, 2018 at 14:16
  • Yes, please see my answer to the linked duplicate question Commented Jul 16, 2018 at 14:42
  • @MathiasR.Jessen I checked it, the issue I am facing is I do not have escalated privileges on the machine I want to run this script, I want to use something like Net View to create a CSV file. Can you tell me how would I do that as I am very new to powershell. Commented Jul 16, 2018 at 14:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.