0

I have SP 2013 sites. I want to read the group on user.aspx page with permission level. But I am getting error on get permission. some one help me with this.

$SiteGroups = Get-PnPGroup 
 
Write-host "Total Number of Groups Found:"$SiteGroups.Count

ForEach($Group in $SiteGroups)
{
    $GName = $Group.Title
    $GID = $Group.Id

    $Role = Get-PnPGroupPermissions -Identity $Group.Title #I am getting error here
 }

enter image description here

3
  • What is the error message? Do you have site collection administrator or site owner permissions? Jul 20 at 16:28
  • yes i am SCA of the site
    – Liz
    Jul 21 at 4:49
  • I have attached that error message, you can see that
    – Liz
    Jul 21 at 5:07
1

Please run the below powershell script as an admin:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$SPSiteUrl = Read-Host "Enter the Url of the Site Collection"
$SPSite = Get-SPSite $SPSiteUrl -ErrorAction SilentlyContinue
 
if($SPSite -ne $null){

    $SPWebCollection = $SPSite.AllWebs

    foreach($SPWeb in $SPWebCollection){

        Write-Output "Site Title:" $SPWeb.Title "contains the following groups"
        Write-Output "======================================================"

        foreach($SPGroup in $SPWeb.Groups){
 
            Write-Output $SPGroup.Name
            Write-Output $SPGroup.ID
            Write-Output " "

        }
    }
}

else{

    Write-Host "Requested Site Could Not be found" -ForegroundColor DarkRed
}

enter image description here

enter image description here

======================== Update Answer =======================

Please run the below powershell script as an admin:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$sites = get-spsite "http://sp/sites/echo/"

foreach ($site in $sites)
{

    write-host -foregroundcolor Green "Working on Site Collection: "$site.RootWeb.Title "..."
    write-host ""

    foreach ($web in $site.AllWebs)
    {
        foreach($roleAssignment in $web.RoleAssignments)
        {
            $GroupName = $roleAssignment.Member.Name
           
            foreach($spgroup in $web.Groups)
            {
                if($spgroup.Name -eq $GroupName)
                {

                    write-host -foregroundcolor White "Group Name: "$GroupName "......"

                    foreach($roleDefinition in $roleAssignment.RoleDefinitionBindings)
                    {

                        write-host -foregroundcolor Yellow "Permission Level: "$roleDefinition.Name "..."

                    }
                }   
            }
        }
    }

       $web.Dispose()

}

enter image description here

======================== Updated Answer =======================

Here are two related articles that may help you.

7
  • Thanks for your code. But we are not using server side. Also, i can read the group, But group permission not able to get it.
    – Liz
    Jul 21 at 6:26
  • I have updated answer under initial My Answer. Hope this can help you to solve issue. Have a nice day! Jul 21 at 8:54
  • thanks @EchoDu_MSFT But i am looking for the code with pnp powershell, server side is not supporting in our environment. we dont have sharepoint farm in or server. if u help me with client side code that could be great. I have posted my code where i am getting the error. pls check it
    – Liz
    Jul 21 at 11:56
  • Hi Liz. The "Get-PnPGroupPermissions" command is applicable to SharePoint Online, not to SharePoint Server. Therefore, we cannot achieve your needs through the pnp command. Jul 22 at 6:53
  • okk thanks, then any CSOM Command is available
    – Liz
    Jul 22 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.