Author Posts

December 9, 2015 at 8:37 am

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
		}

December 9, 2015 at 8:45 am

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
		}