pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 662 forks source link

Get-PnPGroup not Showing Groups per Web #969

Open westerdaled opened 7 years ago

westerdaled commented 7 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

Reporting an Issue or Missing Feature

I want to list onlythe groups per web but all I can list is the all Site Groups regardless of which Web ( Sub Site) I am sitting on. Note, all sub sites have broken inheritance and may have more than one group with the same permission level .

Expected behavior

My intention is to list each group with its permission level per web ( sub site) . foreach($subweb in $subwebs) { Connect-PnPOnline $subWeb.Url -Credentials $cred $thisWeb = Get-PnPWeb $groups=Get-PNPGroup -Identity $thisWeb.Title

Actual behavior

I get the a list of all the site groups regardless of what web I am actually connected to. If I use straight CSOM ( in PnPCommandlets) I get the same behaviour .

Steps to reproduce behavior

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable) 2.16.1706.1

How did you install the PnP-PowerShell Cmdlets?

redhotbelgian commented 7 years ago

I have the same issue (and same requirement). The documentation with Get-PnPGroup has -Web as a parameter but I can't see anyway to use it.

westerdaled commented 7 years ago

Indeed, also @NPrice99 as the same issue . Can we notify @erwinvanhunen to see what he thinks . I have a feeling this is not going to be easy to resolve.

westerdaled commented 7 years ago

Doh!

aboninn commented 7 years ago

Hi, same kind of problem with the latest version 2.19.1710 and SharePoint Online. I cannot manage to use -Web parameter, which seems to be taken into account, giving following error: Get-PnPGroup : The object is used in the context different from the one associated with the object.

erwinvanhunen commented 7 years ago

We fixed this through PR https://github.com/SharePoint/PnP-PowerShell/pull/1108. It will be made available in the next release.

westerdaled commented 7 years ago

Thank you @erwinvanhunen . @NPrice99 , hopefully you have also had the update on this now?

NPrice99 commented 7 years ago

Yes - Thanks

From: Daniel Westerdale [mailto:notifications@github.com] Sent: 20 October 2017 09:45 To: SharePoint/PnP-PowerShell PnP-PowerShell@noreply.github.com Cc: Nigel Price pricen@njpenterprises.com; Mention mention@noreply.github.com Subject: Re: [SharePoint/PnP-PowerShell] Get-PnPGroup not Showing Groups per Web (#969)

Thank you @erwinvanhunenhttps://github.com/erwinvanhunen . @NPrice99https://github.com/nprice99 , hopefully you have also had the update on this now?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SharePoint/PnP-PowerShell/issues/969#issuecomment-338145438, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIF00MmDGRLrdiGTHgXpZmcOrwE2ibETks5suF1wgaJpZM4Oofsp.

maru-sama commented 6 years ago

I am still facing this issue with the latest version. While I do not get an error with the -web parameter I am stil getting the site related groups and not the specific web groups. Ok I had a look at #1108 and apparently this is expected behaviour.

As this command uses the User Information List which is sitecollection scoped anyway, being able to use the -Web argument makes no sense anyway, but if it's supported to be used as it is here, it should at least not return an exception. That's fixed now.

What is the correct way now to get the assigned groups for each subweb?

roennes commented 6 years ago

you can use the RoleAssignmentCollection.Groups property to get groups of a web. (Gets the groups that directly belong to the access control list (ACL). for this securable object.) https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.roleassignmentcollection.groups(v=office.15).aspx

$spoCtx = Get-PnPContext
$spoCtx.Load($spoCtx.Web.RoleAssignments.Groups)
Execute-PnPQuery -ErrorAction Stop
$webGroups = $spoCtx.Web.RoleAssignments.Groups
$webGroups