Need to create Multiple folders by importing CSV file using powershell.

Need to create Multiple folders by importing CSV file  using powershell.  Below script is giving error in last line of script can any one help whats working in this script , please assist
____________________________________________________________________

$rows=Import-Csv 'C:\Users\Narasimha.s\Desktop\foldertest\project.csv'
foreach ($row in $rows) {
  $folderName = $row.DisplayName
  md -Path C:\$folderName
}
LVL 3
SAM ITAD windows Admin Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rajul RajInformation Security OfficerCommented:
Use this Script

Set-Location "c:\data\groups" 
 
$Folders = Import-Csv c:\scripts\GroupdOnTRG.csv 
 
ForEach ($Folder in $Folders) { 
 
New-Item $Folder.Name -type directory 
} 

Open in new window

0
SAM ITAD windows Admin  Author Commented:
I have initiated given error getting error. error message screen shot attached
errorfolder.jpg
0
Bill PrewCommented:
Try:

Set-Location "c:\data\groups" 
 
$Folders = Import-Csv c:\scripts\GroupdOnTRG.csv 
 
ForEach ($Folder in $Folders) { 
 
New-Item -path $Folder -type directory 
} 

Open in new window

~bp
1
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

SAM ITAD windows Admin  Author Commented:
Again getting same error. attached
0
Bill PrewCommented:
Unless you don't have the full path in the CSV, just the name of the new folder, in a column headed DisplayName, which I think would then be:

Set-Location "c:\data\groups" 
 
$Folders = Import-Csv c:\scripts\GroupdOnTRG.csv 
 
ForEach ($Folder in $Folders) { 
 
New-Item -name $Folder.DisplayName -type directory 
} 

Open in new window

~bp
0
Bill PrewCommented:
Can you also show here what the CSV looks like.

~bp
0
SAM ITAD windows Admin  Author Commented:
getting different error now . attached

CSV format also attached
csvformat.jpg
error1.jpg
0
Bill PrewCommented:
Please attach the actual CSV file, not a picture of it opened as a spreadsheet, need to see the text file.

~bp
0
SAM ITAD windows Admin  Author Commented:
CSV attached
project.csv
0
Bill PrewCommented:
Add a header line to the CSV, like this:

Name
a
b
c

Open in new window

And then use this script:
Set-Location "c:\data\groups" 
$Folders = Import-Csv c:\scripts\GroupdOnTRG.csv 
ForEach ($Folder in $Folders) { 
  New-Item -name $Folder.Name -type directory 
} 

Open in new window

~bp
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SAM ITAD windows Admin  Author Commented:
Perfect......

I have one query on this ......

Post creating the folders in the path security group permission has to be apply to created folders

Security Group Name: shr-projectsmodify This Group is part of Active directory. This group permission has to apply on created folders
0
Bill PrewCommented:
Sounds like a new question, and be sure to include the "Active Directory" topic when you create it.

~bp
0
SAM ITAD windows Admin  Author Commented:
quick  response and resolution
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.