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 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)