From f45a823e6866c94f44d2b8be5e0303f107dfa2a6 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Fri, 30 Dec 2022 23:18:23 +0200 Subject: [PATCH 1/2] Fix: issue with userinfo cmdlets not working --- src/Commands/Principals/ExportUserInfo.cs | 4 ++-- src/Commands/Principals/RemoveUserInfo.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Commands/Principals/ExportUserInfo.cs b/src/Commands/Principals/ExportUserInfo.cs index 2b5129dec..bb9e847b2 100644 --- a/src/Commands/Principals/ExportUserInfo.cs +++ b/src/Commands/Principals/ExportUserInfo.cs @@ -19,7 +19,7 @@ public class ExportUserInfo : PnPAdminCmdlet protected override void ExecuteCmdlet() { var siteUrl = Connection.Url; - if(ParameterSpecified(Site)) + if (ParameterSpecified(nameof(Site))) { siteUrl = Site; } @@ -28,7 +28,7 @@ protected override void ExecuteCmdlet() { hostUrl = hostUrl.Substring(0, hostUrl.Length - 1); } - var site = this.Tenant.GetSiteByUrl(siteUrl); + var site = Tenant.GetSiteByUrl(siteUrl); ClientContext.Load(site); ClientContext.ExecuteQueryRetry(); var normalizedUserName = UrlUtilities.UrlEncode($"i:0#.f|membership|{LoginName}"); diff --git a/src/Commands/Principals/RemoveUserInfo.cs b/src/Commands/Principals/RemoveUserInfo.cs index 64c8d5464..32cef3488 100644 --- a/src/Commands/Principals/RemoveUserInfo.cs +++ b/src/Commands/Principals/RemoveUserInfo.cs @@ -22,7 +22,7 @@ public class RemoveUserInfo : PnPAdminCmdlet protected override void ExecuteCmdlet() { var siteUrl = Connection.Url; - if (ParameterSpecified(Site)) + if (ParameterSpecified(nameof(Site))) { siteUrl = Site; } @@ -31,18 +31,18 @@ protected override void ExecuteCmdlet() { hostUrl = hostUrl.Substring(0, hostUrl.Length - 1); } - var site = this.Tenant.GetSiteByUrl(siteUrl); + var site = Tenant.GetSiteByUrl(siteUrl); ClientContext.Load(site); ClientContext.ExecuteQueryRetry(); var normalizedUserName = UrlUtilities.UrlEncode($"i:0#.f|membership|{LoginName}"); RestResultCollection results = null; if (!ParameterSpecified(nameof(RedactName))) { - results = RestHelper.PostAsync>(this.HttpClient, $"{hostUrl}/_api/sp.userprofiles.peoplemanager/RemoveSPUserInformation(accountName=@a,siteId=@b)?@a='{normalizedUserName}'&@b='{site.Id}'", this.AccessToken, false).GetAwaiter().GetResult(); + results = RestHelper.PostAsync>(HttpClient, $"{hostUrl}/_api/sp.userprofiles.peoplemanager/RemoveSPUserInformation(accountName=@a,siteId=@b)?@a='{normalizedUserName}'&@b='{site.Id}'", this.AccessToken, false).GetAwaiter().GetResult(); } else { - results = RestHelper.PostAsync>(this.HttpClient, $"{hostUrl}/_api/sp.userprofiles.peoplemanager/RemoveSPUserInformation(accountName=@a,siteId=@b,redactName=@c)?@a='{normalizedUserName}'&@b='{site.Id}'&@c='{RedactName}'", this.AccessToken, false).GetAwaiter().GetResult(); + results = RestHelper.PostAsync>(HttpClient, $"{hostUrl}/_api/sp.userprofiles.peoplemanager/RemoveSPUserInformation(accountName=@a,siteId=@b,redactName=@c)?@a='{normalizedUserName}'&@b='{site.Id}'&@c='{RedactName}'", this.AccessToken, false).GetAwaiter().GetResult(); } var record = new PSObject(); foreach (var item in results.Items) From 0c98696eff1458ac85f71c49da45634f772ccc47 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Fri, 30 Dec 2022 23:21:53 +0200 Subject: [PATCH 2/2] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7fa00c21..d9c95fbda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed issue with -CreateDrive on `Connect-PnPOnline` throwing exception on non-existing context - Fixed issue with non-existing ItemProxy cmdlet aliases being registered - Fixed issue with `-TranslationLanguageCode` failures in `Add-PnPPage` and `Set-PnpPage` cmdlets. [#2634](https://github.com/pnp/powershell/pull/2634) +- Fixed issue with `Export-PnPUserInfo` and `Remove-PnPUserInfo` cmdlets not working due to issue with parameter validation. [#2688](https://github.com/pnp/powershell/pull/2688) ### Contributors