-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aymeric Mouillé
committed
Dec 22, 2024
1 parent
6ad3a56
commit 69dbdff
Showing
4 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<# | ||
.SYNOPSIS | ||
Retrieve current user id. | ||
.DESCRIPTION | ||
Get system user unique identifier. | ||
.PARAMETER XrmClient | ||
Xrm connector initialized to target instance. Use latest one by default. (Dataverse ServiceClient) | ||
#> | ||
function Get-XrmWhoAmI { | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $false, ValueFromPipeline)] | ||
[Microsoft.PowerPlatform.Dataverse.Client.ServiceClient] | ||
$XrmClient = $Global:XrmClient | ||
) | ||
begin { | ||
$StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); | ||
Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); | ||
} | ||
process { | ||
|
||
$request = new-xrmrequest -Name "WhoAmI"; | ||
$response = Invoke-xrmRequest -XrmClient $XrmClient -Request $request; | ||
|
||
$userId = $response.Results["UserId"].Guid; | ||
$userId; | ||
} | ||
end { | ||
$StopWatch.Stop(); | ||
Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; | ||
} | ||
} | ||
Export-ModuleMember -Function Get-XrmWhoAmI -Alias *; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters