Cannot bind argument to parameter 'Title' because it is null

Anonymous
2023-07-12T17:21:52.3133333+00:00

I am attempting to bulk create multiple document librariesin a site but when I run it I keep getting the error

"Cannot bind argument to parameter 'Name' because it is null"

The CSV is formatted like;

User's image

I'm not sure what they are referring to;

#Set Parameters 
$SiteURL = "https://xxxxxx.sharepoint.com/sites/DEVPOC/NERPOC/" 
$CSVFilePath = "C:\Users\xxxxx\Documents\DocumentLibs.csv"    

#Connect to PnP Online 
Connect-PnPOnline -Url $SiteURL -Interactive   
#Get the CSV file 
$CSVFile = Import-Csv $CSVFilePath    

#Read CSV file and create new library 
ForEach($Line in $CSVFile) 
{     
	Try {         
		#Create document library         
		Write-host -f Yellow "Creating Document Library:"$Line.DisplayName         
		New-PnPList -Title $Line.DisplayName -Template DocumentLibrary -Url $Line.LoginID -ErrorAction Stop           
		
		#Set Library Properties         
		Set-PnPList -Identity $Line.DisplayName -EnableVersioning $True -EnableMinorVersions $True -CopyRoleAssignments:$False -BreakRoleInheritance -ListExperience NewExperience         
		$Library  = Get-PnPList -Identity $Line.DisplayName           
		
		#Exclude from Search Results         
		$Library.NoCrawl = $True         
		$Library.Update()           

		#Grant permission on List to User         
		$UserID = $Line.LoginID+"******@Tenant.com"         
		Set-PnPListPermission -Identity $Line.DisplayName -AddRole "Full Control" -User $UserID           

		Write-host -f Green "`tCreated Document Library:"$Line.DisplayName     
	}     
	Catch {         										    		       
		write-host -f Red "`tError:" $_.Exception.Message     
	} 

}

Any ideas on how i can fix this?

I Appreciate any help.

Thank you,

DWTKBrook

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-07-13T05:46:54.4733333+00:00

    Hi @Anonymous ,

    As the Q&A forum is an open platform, please pay attention to protecting your privacy information. When posting a question, cover or code your private information. Thanks.

    According to your description, it should be a parameter reference problem, please change $Line.DisplayName to $Line.LibraryName and try again.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.