Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify additional properties to include in Get-PnPSiteCollectionAdmin #3521

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Commands/Site/GetSiteCollectionAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace PnP.PowerShell.Commands.Site
{
[Cmdlet(VerbsCommon.Get, "PnPSiteCollectionAdmin")]
[OutputType(typeof(User))]
public class GetSiteCollectionAdmin : PnPWebCmdlet
public class GetSiteCollectionAdmin : PnPWebRetrievalsCmdlet<User>
{
protected override void ExecuteCmdlet()
{
var retrievalExpressions = new Expression<Func<User, object>>[]
{
DefaultRetrievalExpressions = new Expression<Func<User, object>>[]
{
u => u.Id,
u => u.Title,
u => u.LoginName,
Expand All @@ -31,10 +31,10 @@ protected override void ExecuteCmdlet()
g => g.Id,
g => g.Title,
g => g.LoginName)
};
};

var siteCollectionAdminUsersQuery = CurrentWeb.SiteUsers.Where(u => u.IsSiteAdmin);
var siteCollectionAdminUsers = ClientContext.LoadQuery(siteCollectionAdminUsersQuery.Include(retrievalExpressions));
var siteCollectionAdminUsers = ClientContext.LoadQuery(siteCollectionAdminUsersQuery.Include(RetrievalExpressions));
ClientContext.ExecuteQueryRetry();

WriteObject(siteCollectionAdminUsers, true);
Expand Down