Forum Discussion
Fred Y
Dec 06, 2018Iron Contributor
Add Folders with metadata using PowerShell script
Hi,
Any code samples for creating SharePoint folders with metadata into a document library? I'd like to import a list from CSV but I've only seen a sample where it adds the folder and changes permission.
Thanks!
Fred
3 Replies
- Thuyavan GanesanIron ContributorHello Fred,
If you are talking about a folder with the metadata in SP library.And assume you have 3 metadata for each folder.
$web = Get-SPWeb http://webapp.com/site/
$list = $web.GetList("/site/Library Name")
Create a folder with defined metadata:
$spFolder = $list.AddItem("",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,"Folder Name")
$spFolder["Col 1"]="Cont 1"
$spFolder["Col 2"]="Cont 2"
$spFolder["Col 3"]="Cont 3"
$spFolder.Update()
Please let me know if that works
Thanks,
Thuyavan
----------------------------------------------------------------------------------
Your “Likes” are energy boosters for us to keep blogging and the feedback is very valuable- Fred YIron Contributor
Hi, Thuyavan Ganesan
Do I need to specify in the script if I'm using custom folder content type with the metadata, or will the default SPFileSystemObjectType::Folder work?
Thanks,
Fred
- Thuyavan GanesanIron Contributor
Hi Fred,
keep the default SPFileSystemObjectType::Folder .
Thanks,
Thuyavan