|
127 | 127 | It will authenticate with the specified ClientId parameter: "dea8d7a9-1602-4429-b138-111111111111". |
128 | 128 | It will authenticate with the specified ClientSecretAsPlainString parameter: "Vja/VmdxaLOPR+alkjfsadffelkjlfw234522". |
129 | 129 | |
| 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 | + |
130 | 139 | .EXAMPLE |
131 | 140 | PS C:\> $clientSecretSecure = Read-Host -AsSecureString "Enter the Client Secret" |
132 | 141 | 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 | 175 | |
167 | 176 | #> |
168 | 177 | 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.')] |
169 | 181 | [CmdletBinding(DefaultParameterSetName = 'ByInteractiveLogin')] |
170 | 182 | [OutputType([System.String])] |
171 | 183 | param ( |
@@ -245,7 +257,7 @@ function Request-D365DatabaseJITAccess { |
245 | 257 | } |
246 | 258 |
|
247 | 259 | $bearer = Invoke-ClientCredentialsGrant @bearerParms | Get-BearerToken |
248 | | - } |
| 260 | + } |
249 | 261 | else { |
250 | 262 | try { |
251 | 263 | # Check if already connected |
@@ -321,7 +333,7 @@ function Request-D365DatabaseJITAccess { |
321 | 333 | # Extract the relevant information from the response |
322 | 334 | $selectParams = @{ |
323 | 335 | TypeName = "D365FO.TOOLS.UDE.JITDatabaseAccess" |
324 | | - Property = @{Name = "SQLJITCredential"; Expression = { |
| 336 | + Property = @{Name = "SQLJITCredential"; Expression = { |
325 | 337 | $password = $_.sqljitpassword | ConvertTo-SecureString -AsPlainText -Force |
326 | 338 | New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($_.sqljitusername, $password) |
327 | 339 | }}, |
|
0 commit comments