String wildcards

This topic contains 12 replies, has 6 voices, and was last updated by Profile photo of Adnan Rashid Adnan Rashid 2 years, 5 months ago.

  • Author
    Posts
  • #16726
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    Hello,

    I was wondering if someone could help me with a particular issue I'm having, can't seem to work this out.

    So i have a share on a SAN, lets say the share at the top level is '\\Share01' and that share contains lots of projects for example the structure might be like this

    Top Level: \\Share01
    Child Level: \\Share01\Project_One
    Child Level: \\Share01\Project_Two
    Child Level: \\Share01\Project_Three

    Now, keep in mind i cannot do the following with these shares

    1. I cannot map to the share \\Share01, therefore you can't go to My Computer map it is X drive and try and browse it – This is not permitted
    2. The only thing you can map to is directly to \\Share01\Project_One or \\Share01\Project_Two but NOT \\Share01 directly

    What i want to do is pretty simple, check the permissions for each of the Project folders. In order to do this i would imagine its something like

    (sudo code)
    for each share in shares
    grab the permissions

    simple.

    The problem is how do i send in this wild card for the projects? So in my mind it would be something like

    (sudo code)
    shares are \\share01\project_* (* being the wildcard)
    for each share in shares
    get permissions

    im struggling to understand how to do this. Any ideas how to go abouts this.

    This should be pretty simple.. but i can't seem to cycle around the wildcard, it will just ask for the path..

    Sorry if anything confusing there, let me know if anything don't make sense, cheers!

  • #16727
    Profile photo of Adam Bertram
    Adam Bertram
    Participant

    How about something like this?

    Get-ChildItem \\Share01 -Include Project* -Folder

    That will let you iterate over the Project folders.

  • #16728
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    Hello,

    Good suggestion however that won't work the error that comes back with

    get-childItem \\Share -Include Project* is:

    Get-ChildItem: Cannot process argument because the value of the argument "path" is not valid. Change the value of the path and run again.

    -Folder also does not exist.

    Cheers

  • #16729
    Profile photo of Adam Bertram
    Adam Bertram
    Participant

    There is no parent folder that you can iterate over like \\SHARE01\SHARE?

    How would you see these Project folders via the GUI? Just going to \\SHARE01 in Windows Explorer?

  • #16730
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    There is no parent folder thats the issue... Its directly to \\SHARE01 and you can go to that on the GUI

    however you cannot map to it and i can't get to directly on command line either..

    So its a matter of.. go to '\\SHARE01\Project_ [whatever is first here anything starting with A, lets say – grab that share and bring back permissions then go to next share]

    There is a lot of folders in here... the alternative way is for me to export that list into a CSV file and then cycle through them.. but i can't seem to get to it on command line so thats out of the question also.

    im stumped lol

  • #16731
    Profile photo of Adam Bertram
    Adam Bertram
    Participant

    Try to see if your SAN vendor has a Powershell module. If you can get one, look for a cmdlet that you can use to enumerate the shares. Once you've got that, you're golden.

  • #16732
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    Thanks – explaining the problem popped another idea into my head.

    just realised we create AD groups for each share which contains the project name so i've just exported that

    I just tested it now and cycled through them with a test-path and it returns true! so i think this might just work!

    Although it would be nice how to know how we could tackle this if AD wasn't involved. It really shouldn't be that hard... but it is! lol

  • #16750
    Profile photo of Peter Jurgens
    Peter Jurgens
    Participant

    What about:

    Get-childitem "\\share01\project_*"
    
    • #16754
      Profile photo of Adnan Rashid
      Adnan Rashid
      Participant

      that doesn't do anything im afraid...

  • #16761
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    If it's a NAS with a CIF server, you may be able to access it with an admin share (e.g. \\server\h$\...). Another possibility is DFS is you have available and some kind of logical structure ("\\domain\projects\project1" = target "server\project1") and WMI (Win32_DFSTarget) can enumerate the target path. I've tried a couple iterations trying to connect to even a Windows-based UNC and nothing is enumerated, but Windows I can use Win32_Share to enumerate and get a UNC path.

  • #16822
    Profile photo of Martin Nielsen
    Martin Nielsen
    Participant

    Since it's a non-Windows storage device, I doubt there are any easy ways of showing a list of shares.

    The easiest solution would be to create a new share on the parent folder and giving only a service account read access to that.

    Alternatively you can browse through manuals and documentation to see if your device supports any kind of WMI/CIM remote management. Or perhaps contacting the vendor would be faster.

    Now if it was a Windows server hosting the shares then things would be a lot easier.

  • #16831
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Have you tried "net view \\share01" ? It's an old way of displaying shared folders, printers, etc on an SMB endpoint. You'd have to do some string parsing to pull out the share names, but it might work.

  • #16833
    Profile photo of Adnan Rashid
    Adnan Rashid
    Participant

    Dave Wyatt! what a genius! That works perfectly – String manipulation is no problem i can see all the shares!

    Thanks very much thats very helpful!

You must be logged in to reply to this topic.