I am trying to create a lookup field via Sharpoint PNP PowerShell module.
And here is my script:
$URL = "https://testing.sharepoint.com/sites/sitename"
Connect-PnPOnline -url $URL -Credential credentialname
$targetlistname = "users" ## Name of the target list
$sourcelistname = "testlist" ## Name of the list which contains the lookup field
$sourcefieldname = "Title" ## Name of the lookup column
$lookupfielddisplayname = "JustTesting" ## Name of the new column
$lookupfieldinternalname = "justtesting" ## Name of the internal name of the new column
Add-PnPField -List $targetlistname -DisplayName $lookupfielddisplayname -InternalName $lookupfieldinternalname -Type Lookup -LookUpList $sourcelistname -LookUpValue $sourcefieldname
I would like to achieve this:
Can someone help me with the correct syntax?