CSV values not applying when Doument Set Created

%3CLINGO-SUB%20id%3D%22lingo-sub-2249324%22%20slang%3D%22en-US%22%3ECSV%20values%20not%20applying%20when%20Doument%20Set%20Created%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2249324%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20attempting%20to%20create%20Document%20Sets%20from%20powershell%20running%20the%20below%20code.%20The%20doc%20sets%20are%20created%20with%20Title%20and%20name%20but%20the%20other%20fields%20are%20not%20getting%20their%20values%20from%20the%20csv%2C%20at%20a%20loss%20why%20the%20csv%20values%20are%20not%20being%20applied.%20Thanks%20in%20advance%20for%20any%20help%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24ErrorActionPreference%20%3D%20%22Stop%22%3CBR%20%2F%3E%24ver%20%3D%20%24host%20%7C%20select%20version%3CBR%20%2F%3Eif(%24Ver.version.major%20-gt%201)%20%7B%24Host.Runspace.ThreadOptions%20%3D%20%22ReuseThread%22%7D%3CBR%20%2F%3Eif(!(Get-PSSnapin%20Microsoft.SharePoint.PowerShell%20-ea%200))%3CBR%20%2F%3E%7B%3CBR%20%2F%3EWrite-Progress%20-Activity%20%22Loading%20Modules%22%20-Status%20%22Loading%20Microsoft.SharePoint.PowerShell%22%3CBR%20%2F%3EAdd-PSSnapin%20Microsoft.SharePoint.PowerShell%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%24DestinationWebURL%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fmyweb.mine.com%2Fcustmgmt%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmyweb.mine.com%2Fcustmgmt%3C%2FA%3E%22%3CBR%20%2F%3E%24DestinationLibraryTitle%20%3D%20%22Customers%22%3CBR%20%2F%3E%24docSetInfos%20%3D%20Import-CSV%20C%3A%5CUsers%5CFarm%5CDesktop%5Ccustomerstest.csv%20-Header%20'Title'%2C'Name'%2C'Description'%2C'CustCode'%2C'CustNam'%20-Delimiter%20%22%2C%22%3C%2FP%3E%3CP%3E%24dWeb%20%3D%20Get-SPWeb%20%24DestinationWebURL%3CBR%20%2F%3E%24dList%20%3D%20%24dWeb.Lists%20%7C%20%3F%20%7B%24_.title%20-like%20%24DestinationLibraryTitle%7D%3C%2FP%3E%3CP%3E%24cType%20%3D%20%24dList.ContentTypes%5B%22Customer%22%5D%3C%2FP%3E%3CP%3Eforeach(%24docSetInfo%20in%20%24docSetInfos)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23Build%20properties%20hash%20table%20from%20%24docSetInfos%5B%5D%3CBR%20%2F%3E%24docsetProperties%20%3D%20%40%7B%7D%3C%2FP%3E%3CP%3E%24docsetProperties.Add('Title'%2C%24docSetInfo.Title)%3CBR%20%2F%3E%24docsetProperties.Add('Name'%2C%24docSetInfo.Name)%3CBR%20%2F%3E%24docsetProperties.Add('Description'%2C%24docSetInfo.Description)%3CBR%20%2F%3E%24docsetProperties.Add('Customer%20Code'%2C%24docSetInfo.CustCode)%3CBR%20%2F%3E%24docsetProperties.Add('Customer%20Name'%2C%24docSetInfo.CustName)%3C%2FP%3E%3CP%3E%24NewFolder%20%3D%20%5BMicrosoft.Office.DocumentManagement.DocumentSets.DocumentSet%5D%3A%3ACreate(%24dlist.RootFolder%2C%24docSetInfo.CustCode%2C%20%24cType.Id%2C%20%24docsetProperties)%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I am attempting to create Document Sets from powershell running the below code. The doc sets are created with Title and name but the other fields are not getting their values from the csv, at a loss why the csv values are not being applied. Thanks in advance for any help

 

$ErrorActionPreference = "Stop"
$ver = $host | select version
if($Ver.version.major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ea 0))
{
Write-Progress -Activity "Loading Modules" -Status "Loading Microsoft.SharePoint.PowerShell"
Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$DestinationWebURL = "https://myweb.mine.com/custmgmt"
$DestinationLibraryTitle = "Customers"
$docSetInfos = Import-CSV C:\Users\Farm\Desktop\customerstest.csv -Header 'Title','Name','Description','CustCode','CustNam' -Delimiter ","

$dWeb = Get-SPWeb $DestinationWebURL
$dList = $dWeb.Lists | ? {$_.title -like $DestinationLibraryTitle}

$cType = $dList.ContentTypes["Customer"]

foreach($docSetInfo in $docSetInfos)
{
#Build properties hash table from $docSetInfos[]
$docsetProperties = @{}

$docsetProperties.Add('Title',$docSetInfo.Title)
$docsetProperties.Add('Name',$docSetInfo.Name)
$docsetProperties.Add('Description',$docSetInfo.Description)
$docsetProperties.Add('Customer Code',$docSetInfo.CustCode)
$docsetProperties.Add('Customer Name',$docSetInfo.CustName)

$NewFolder = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($dlist.RootFolder,$docSetInfo.CustCode, $cType.Id, $docsetProperties)
}

2 Replies

@ccroasmun67  The hashtable is loading because I can change the value in the Name column by changing the column variable in the create statement at the bottom of the script. To clarify, Title and Name get values, Description, CustCode, and CustName do not load data. Also this is SharePoint 2019, I know DocSet internal field names were changed in 2013, I am researching that.

Internal Column Name was the issue, Thanks to those who at least looked!!