Create multiple public folders
Hello,
I'm trying to create a number of public folders (2000) that will contain a folder and then a sub folder in Exchange 2010. I'm in nt way a script guy so I'm having some trouble trying to do this. I have a CSV file that looks like this:
Project,Extension
999999,100
999999,200
999988,100
And below is the code I'm using, the problem is the 2nd part of the code where it is trying to create the sub folder (100, 200) under the project number. I can't get it to read the $_.Project variable into the -Path parameter? I'm sure there is a better
way to do this but this is what I have pieced together with my limited knowledge.
Import-Csv test.txt | ForEach-Object{New-PublicFolder -Name $_."project"}
Import-Csv test.txt | ForEach-Object{New-PublicFolder -Name $_."Extension" -Path '\Project Email\$_."Project"'}
October 9th, 2012 4:58pm
got it! Below is the code I used:
#Used to import multiple public folders with subfolders.
#IMPORT TXT file must have headers called Project,Extension with a comma between each project and extension
#Project,Extension
#99988,100
#99988,200
#99888,100
Import-Csv MTE.txt | ForEach{New-PublicFolder -Name $_."project" -Path '\Project Email'}
Import-Csv MTE.txt | ForEach{
$path = '\Project Email\'
$project = $_.project
$fullpath = $path + $project
New-PublicFolder -Name $_.Extension -Path $fullpath}
Free Windows Admin Tool Kit Click here and download it now
October 10th, 2012 11:29am
Great, thanks for sharing your solution, it is very helpful for us.
Wendy Liu
TechNet Community Support
October 10th, 2012 11:02pm