Skip to content

Commit

Permalink
Merge pull request #2688 from gautamdsheth/bugfix/user-info-fix
Browse files Browse the repository at this point in the history
Fix: issue with userinfo cmdlets not working
  • Loading branch information
gautamdsheth authored Dec 30, 2022
2 parents 2a040b7 + 0c98696 commit 432f77d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Principals/ExportUserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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}");
Expand Down
8 changes: 4 additions & 4 deletions src/Commands/Principals/RemoveUserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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<ExportEntity> results = null;
if (!ParameterSpecified(nameof(RedactName)))
{
results = RestHelper.PostAsync<RestResultCollection<ExportEntity>>(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<RestResultCollection<ExportEntity>>(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<RestResultCollection<ExportEntity>>(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<RestResultCollection<ExportEntity>>(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)
Expand Down

0 comments on commit 432f77d

Please sign in to comment.