Script edit

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Karbonatom Karbonatom 1 year, 5 months ago.

  • Author
    Posts
  • #32780
    Profile photo of Karbonatom
    Karbonatom
    Participant

    So I have this script from a former coworker and i'm trying to learn powershell. This is great for making directory's but now I have 20 folders beneath the set directory, they all have different names. What i'm wondering is it possible to adapt this script to create folders under the existing structure with out having to edit the script 20 times.

    My folders look like:
    \\server\directory\folders 1-20
    and I want to add two folders called "users" and "Community" under each of the folders above. Does anyone have some suggestion? or can point me in the right direction?

    Get-Content "C:\PS_SCRIPTS\dir.txt" |
        ForEach-Object {
            $dirPath = Join-Path "\\server\Directory" $_ 
            New-Item $dirPath -ItemType Directory
    		}
    
  • #32781
    Profile photo of Mark Hammonds
    Mark Hammonds
    Participant

    Maybe 😀

    Get-Content "C:\PS_SCRIPTS\dir.txt" |
        ForEach-Object {
            $dirPath = Join-Path "\\server\Directory" $_
            New-Item ($dirPath + "\Community") -ItemType Directory
            New-Item ($dirPath + "\users") -ItemType Directory
    		}
    
    
  • #32782
    Profile photo of Karbonatom
    Karbonatom
    Participant

    Thanks mark!

You must be logged in to reply to this topic.