Create Sharepoint Online libraries using Powershell

I am trying to create around 100 libraries in a Office 365 Team Site.

I have been following this guide but have got a bit stuck.

I have got the Client-side SharePoint PowerShell working and can create individual libraries by running

Add-DocumentLibrary -listTitle Accounts

Open in new window

for example which creates a "Accounts" library.

My question is how do I tell it to use the .csv of the folder names to create all 100 libraries in one go.

I tried pasting this into powershell and it creates some libraries but misses the ones which have a spacce in the library name

Add-DocumentLibrary -listTitle Historic Info
Add-DocumentLibrary -listTitle Home Group Presentations
Add-DocumentLibrary -listTitle Independant Vetcare
Add-DocumentLibrary -listTitle Insurance
Add-DocumentLibrary -listTitle Interview Confirmation Documents
Add-DocumentLibrary -listTitle Invoices

Open in new window

Can someone advice me please
Who is Participating?

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

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.

Rainer JeschorCommented:
for the names with spaces, you have to encapsulate them with quotation marks like
Add-DocumentLibrary -listTitle "Historic Info"
Add-DocumentLibrary -listTitle "Home Group Presentations"
Add-DocumentLibrary -listTitle "Independant Vetcare"
Add-DocumentLibrary -listTitle "Interview Confirmation Documents"

Open in new window

For getting the content of a CSV file:
$csv = Import-Csv c:\path\of\your\file.csv
foreach ($library in $csv) {
    Add-DocumentLibrary -listTitle $library.LibraryName

Open in new window

Assuming the the CSV has a header row and the header of the column containing the document library name is named "LibraryName".


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
roy_battyDirectorAuthor Commented:
That did it. Many thanks
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

From novice to tech pro — start learning today.