Replies: 1 comment
-
it seems to work if i do it like this? $fix2 = New-PnPList -Title $Row.Liberyname -Template DocumentLibrary -OnQuickLaunch But now i then get the error
|
Beta Was this translation helpful? Give feedback.
-
it seems to work if i do it like this? $fix2 = New-PnPList -Title $Row.Liberyname -Template DocumentLibrary -OnQuickLaunch But now i then get the error
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
i am trying to make a PS script that creates a list and then set a AzureAD group to it.
But my ps keeps failing with :
format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
+ CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefaultCommand
My powershell looks like this::
Loop that gets security group an libery name from a CSV file
foreach($Row in $CSVFile) {
LOGIN TO AZUREAD TO CREATE NEW GROUPS
Connect-AzureAD -Credential $Credential
Create azuread group
Write-Host $Row.Securytigroup
New-AzureADGroup -DisplayName $Row.Securytigroup -MailEnabled $false -SecurityEnabled $true -MailNickName "NotSet"
Write-Host "Sikkerhedsgruppe oprettet"
Start-Sleep -s 2
Get the ObjectId of your Azure AD group
$GroupId = (Get-AzureADGroup | Where { $_.DisplayName -eq $Row.Securytigroup }).ObjectID
Write-Host $GroupId
Write-Host "ID oprettet"
Start-Sleep -s 2
Connect to sharepoint online
Connect-PnPOnline -Url "$sharepoint/$sharepointsite" –Credentials $Credential
New-PnPList -Title $Row.Liberyname -Template DocumentLibrary -OnQuickLaunch
Write-Host $Row.liberyname
Write-Host "Created"
Start-Sleep -s 5
Set-PnPList -Identity $Row.Liberyname -BreakRoleInheritance
Write-Host "RoleInhertance disable"
Start-Sleep -s 2
Set-PnPListPermission -Identity $Row.Liberyname -user "c:0t.c|tenant|$GroupId" -AddRole "Må redigere"
Write-Host "Permissions set"
Start-Sleep -s 2
}
Beta Was this translation helpful? Give feedback.
All reactions