SAM IT
asked on
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\Desk top\folder test\proje ct.csv'
foreach ($row in $rows) {
$folderName = $row.DisplayName
md -Path C:\$folderName
}
__________________________
$rows=Import-Csv 'C:\Users\Narasimha.s\Desk
foreach ($row in $rows) {
$folderName = $row.DisplayName
md -Path C:\$folderName
}
ASKER
I have initiated given error getting error. error message screen shot attached
errorfolder.jpg
errorfolder.jpg
Try:
Set-Location "c:\data\groups"
$Folders = Import-Csv c:\scripts\GroupdOnTRG.csv
ForEach ($Folder in $Folders) {
New-Item -path $Folder -type directory
}
~bp
ASKER
Again getting same error. attached
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
}
~bp
Can you also show here what the CSV looks like.
~bp
~bp
ASKER
Please attach the actual CSV file, not a picture of it opened as a spreadsheet, need to see the text file.
~bp
~bp
ASKER
CSV attached
project.csv
project.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
Sounds like a new question, and be sure to include the "Active Directory" topic when you create it.
~bp
~bp
ASKER
quick response and resolution
Open in new window