Skip to content

Commit 2f3ed02

Browse files
committed
fix best practice deviations
1 parent b98897f commit 2f3ed02

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

d365fo.tools/functions/request-d365databasejitaccess.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@
127127
It will authenticate with the specified ClientId parameter: "dea8d7a9-1602-4429-b138-111111111111".
128128
It will authenticate with the specified ClientSecretAsPlainString parameter: "Vja/VmdxaLOPR+alkjfsadffelkjlfw234522".
129129
130+
.EXAMPLE
131+
PS C:\> Request-D365DatabaseJITAccess -Url "https://operations-acme-uat.crm4.dynamics.com/" -Tenant "e674da86-7ee5-40a7-b777-1111111111111" -ClientId "dea8d7a9-1602-4429-b138-111111111111" -ClientSecretAsPlainString "Vja/VmdxaLOPR+alkjfsadffelkjlfw234522" -RawOutput
132+
133+
This will request JIT database access for the D365FO environment and display the result as object with the content as it was received from the endpoint.
134+
It will contact the D365FO instance specified in the Url parameter: "https://operations-acme-uat.crm4.dynamics.com/".
135+
It will authenticate against the Azure Active Directory with the specified Tenant parameter: "e674da86-7ee5-40a7-b777-1111111111111".
136+
It will authenticate with the specified ClientId parameter: "dea8d7a9-1602-4429-b138-111111111111".
137+
It will authenticate with the specified ClientSecretAsPlainString parameter: "Vja/VmdxaLOPR+alkjfsadffelkjlfw234522".
138+
130139
.EXAMPLE
131140
PS C:\> $clientSecretSecure = Read-Host -AsSecureString "Enter the Client Secret"
132141
PS C:\> Request-D365DatabaseJITAccess -Url "https://operations-acme-uat.crm4.dynamics.com/" -Tenant "e674da86-7ee5-40a7-b777-1111111111111" -ClientId "dea8d7a9-1602-4429-b138-111111111111" -ClientSecretAsSecureString $clientSecretSecure
@@ -166,6 +175,9 @@
166175
167176
#>
168177
function Request-D365DatabaseJITAccess {
178+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
179+
'PSAvoidUsingConvertToSecureStringWithPlainText', '',
180+
Justification = 'Converting plain text to Secure.String provides protection against accidental exposure in logs etc. when used correctly. Encrypting the plain text first would make it too difficult to use.')]
169181
[CmdletBinding(DefaultParameterSetName = 'ByInteractiveLogin')]
170182
[OutputType([System.String])]
171183
param (
@@ -245,7 +257,7 @@ function Request-D365DatabaseJITAccess {
245257
}
246258

247259
$bearer = Invoke-ClientCredentialsGrant @bearerParms | Get-BearerToken
248-
}
260+
}
249261
else {
250262
try {
251263
# Check if already connected
@@ -321,7 +333,7 @@ function Request-D365DatabaseJITAccess {
321333
# Extract the relevant information from the response
322334
$selectParams = @{
323335
TypeName = "D365FO.TOOLS.UDE.JITDatabaseAccess"
324-
Property = @{Name = "SQLJITCredential"; Expression = {
336+
Property = @{Name = "SQLJITCredential"; Expression = {
325337
$password = $_.sqljitpassword | ConvertTo-SecureString -AsPlainText -Force
326338
New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($_.sqljitusername, $password)
327339
}},

0 commit comments

Comments
 (0)