Skip to content

Commit

Permalink
🤖 Fix best practice deviations
Browse files Browse the repository at this point in the history
This pull request was automatically created by the d365fo.tools-Generate-Text action'
  • Loading branch information
FH-Inway committed Nov 8, 2024
1 parent 2b59419 commit 3526b72
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 12 deletions.
20 changes: 18 additions & 2 deletions d365fo.tools/bin/d365fo.tools-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -5404,15 +5404,31 @@
true,
"false",
""
],
[
"EmailValue",
"Specify which field to use as EMAIL value when importing the users.\r\nAvailable options \u0027Mail\u0027 / \u0027UserPrincipalName\u0027\nDefault is \u0027Mail\u0027",
"",
false,
"false",
"Mail"
],
[
"TenantId",
"The TenantId to use when connecting to Azure Active Directory\nUses the tenant id of the current environment if not specified.",
"",
false,
"false",
"$Script:TenantId"
]
],
"Alias": "",
"Author": "Rasmus Andersen (@ITRasmus)",
"Synopsis": "Used to import Aad users into D365FO",
"Name": "Import-D365AadUser",
"Links": null,
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-D365AadUser -Users \"[email protected]\",\"[email protected]\"\nImports Claire and Allen as users\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$myPassword = ConvertTo-SecureString \"MyPasswordIsSecret\" -AsPlainText -Force\nPS C:\\\u003e $myCredentials = New-Object System.Management.Automation.PSCredential (\"MyEmailIsAlso\", $myPassword)\nPS C:\\\u003e Import-D365AadUser -Users \"[email protected]\",\"[email protected]\" -AzureAdCredential $myCredentials\nThis will import Claire and Allen as users.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupName \"CustomerTeam1\"\nif more than one group match the AadGroupName, you can use the ExactAadGroupName parameter\r\nImport-D365AadUser -AadGroupName \"CustomerTeam1\" -ForceExactAadGroupName\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupName \"CustomerTeam1\" -ForceExactAadGroupName\nThis is used to force the cmdlet to find the exact named group in Azure Active Directory.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupId \"99999999-aaaa-bbbb-cccc-9999999999\"\nImports all the users that is present in the AAD Group called CustomerTeam1\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eImport-D365AadUser -Users \"[email protected]\",\"[email protected]\" -SkipAzureAd\nImports Claire and Allen as users.\r\nWill NOT make you connect to the Azure Active Directory(AAD).\r\nThe needed details will be based on the e-mail address only, and the rest will be blanked.",
"Syntax": "Import-D365AadUser [-Users] \u003cString[]\u003e [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [[-SkipAzureAd]] [\u003cCommonParameters\u003e]\nImport-D365AadUser [-AadGroupName] \u003cString\u003e [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [[-ForceExactAadGroupName]] [\u003cCommonParameters\u003e]\nImport-D365AadUser [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [-AadGroupId] \u003cString\u003e [\u003cCommonParameters\u003e]"
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-D365AadUser -Users \"[email protected]\",\"[email protected]\"\nImports Claire and Allen as users\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$myPassword = ConvertTo-SecureString \"MyPasswordIsSecret\" -AsPlainText -Force\nPS C:\\\u003e $myCredentials = New-Object System.Management.Automation.PSCredential (\"MyEmailIsAlso\", $myPassword)\nPS C:\\\u003e Import-D365AadUser -Users \"[email protected]\",\"[email protected]\" -AzureAdCredential $myCredentials\nThis will import Claire and Allen as users.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupName \"CustomerTeam1\"\nif more than one group match the AadGroupName, you can use the ExactAadGroupName parameter\r\nImport-D365AadUser -AadGroupName \"CustomerTeam1\" -ForceExactAadGroupName\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupName \"CustomerTeam1\" -ForceExactAadGroupName\nThis is used to force the cmdlet to find the exact named group in Azure Active Directory.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eImport-D365AadUser -AadGroupId \"99999999-aaaa-bbbb-cccc-9999999999\"\nImports all the users that is present in the AAD Group called CustomerTeam1\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eImport-D365AadUser -Users \"[email protected]\",\"[email protected]\" -SkipAzureAd\nImports Claire and Allen as users.\r\nWill NOT make you connect to the Azure Active Directory(AAD).\r\nThe needed details will be based on the e-mail address only, and the rest will be blanked.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eImport-D365AadUser -Users \"[email protected]\",\"[email protected]\" -TenantId \"99999999-aaaa-bbbb-cccc-9999999999\"\nImports Claire and Allen as users. Uses tenant id \"99999999-aaaa-bbbb-cccc-9999999999\"\r\nwhen connecting to Azure Active Directory(AAD).",
"Syntax": "Import-D365AadUser [-Users] \u003cString[]\u003e [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [[-SkipAzureAd]] [[-EmailValue] \u003cString\u003e] [[-TenantId] \u003cString\u003e] [\u003cCommonParameters\u003e]\nImport-D365AadUser [-AadGroupName] \u003cString\u003e [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [[-ForceExactAadGroupName]] [[-EmailValue] \u003cString\u003e] [[-TenantId] \u003cString\u003e] [\u003cCommonParameters\u003e]\nImport-D365AadUser [[-StartupCompany] \u003cString\u003e] [[-DatabaseServer] \u003cString\u003e] [[-DatabaseName] \u003cString\u003e] [[-SqlUser] \u003cString\u003e] [[-SqlPwd] \u003cString\u003e] [[-IdPrefix] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-IdValue] \u003cString\u003e] [[-NameValue] \u003cString\u003e] [[-AzureAdCredential] \u003cPSCredential\u003e] [-AadGroupId] \u003cString\u003e [[-EmailValue] \u003cString\u003e] [[-TenantId] \u003cString\u003e] [\u003cCommonParameters\u003e]"
},
{
"CommandName": "Import-D365Bacpac",
Expand Down
8 changes: 4 additions & 4 deletions d365fo.tools/functions/import-d365aaduser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
Available options 'Mail' / 'UserPrincipalName'
Default is 'Mail'
.PARAMETER TenantId
The TenantId to use when connecting to Azure Active Directory
Uses the tenant id of the current environment if not specified.
.EXAMPLE
Expand Down Expand Up @@ -109,11 +109,11 @@
Imports Claire and Allen as users.
Will NOT make you connect to the Azure Active Directory(AAD).
The needed details will be based on the e-mail address only, and the rest will be blanked.
.EXAMPLE
PS C:\> Import-D365AadUser -Users "[email protected]","[email protected]" -TenantId "99999999-aaaa-bbbb-cccc-9999999999"
Imports Claire and Allen as users. Uses tenant id "99999999-aaaa-bbbb-cccc-9999999999"
Imports Claire and Allen as users. Uses tenant id "99999999-aaaa-bbbb-cccc-9999999999"
when connecting to Azure Active Directory(AAD).
.NOTES
Expand Down
32 changes: 29 additions & 3 deletions d365fo.tools/tests/functions/Import-D365AadUser.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,50 @@
$parameter.ParameterSets['GroupIdImport'].ValueFromPipelineByPropertyName | Should -Be $False
$parameter.ParameterSets['GroupIdImport'].ValueFromRemainingArguments | Should -Be $False
}
It 'Should have the expected parameter EmailValue' {
$parameter = (Get-Command Import-D365AadUser).Parameters['EmailValue']
$parameter.Name | Should -Be 'EmailValue'
$parameter.ParameterType.ToString() | Should -Be System.String
$parameter.IsDynamic | Should -Be $False
$parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
$parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
$parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 15
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
}
It 'Should have the expected parameter TenantId' {
$parameter = (Get-Command Import-D365AadUser).Parameters['TenantId']
$parameter.Name | Should -Be 'TenantId'
$parameter.ParameterType.ToString() | Should -Be System.String
$parameter.IsDynamic | Should -Be $False
$parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
$parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
$parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 16
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
}
}

Describe "Testing parameterset UserListImport" {
<#
UserListImport -Users
UserListImport -Users -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -SkipAzureAd
UserListImport -Users -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -SkipAzureAd -EmailValue -TenantId
#>
}
Describe "Testing parameterset GroupNameImport" {
<#
GroupNameImport -AadGroupName
GroupNameImport -AadGroupName -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -ForceExactAadGroupName
GroupNameImport -AadGroupName -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -ForceExactAadGroupName -EmailValue -TenantId
#>
}
Describe "Testing parameterset GroupIdImport" {
<#
GroupIdImport -AadGroupId
GroupIdImport -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -AadGroupId
GroupIdImport -StartupCompany -DatabaseServer -DatabaseName -SqlUser -SqlPwd -IdPrefix -NameSuffix -IdValue -NameValue -AzureAdCredential -AadGroupId -EmailValue -TenantId
#>
}

Expand Down
52 changes: 49 additions & 3 deletions docs/Import-D365AadUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ Used to import Aad users into D365FO
Import-D365AadUser [-Users] <String[]> [[-StartupCompany] <String>] [[-DatabaseServer] <String>]
[[-DatabaseName] <String>] [[-SqlUser] <String>] [[-SqlPwd] <String>] [[-IdPrefix] <String>]
[[-NameSuffix] <String>] [[-IdValue] <String>] [[-NameValue] <String>] [[-AzureAdCredential] <PSCredential>]
[-SkipAzureAd] [<CommonParameters>]
[-SkipAzureAd] [[-EmailValue] <String>] [[-TenantId] <String>] [<CommonParameters>]
```

### GroupNameImport
```
Import-D365AadUser [-AadGroupName] <String> [[-StartupCompany] <String>] [[-DatabaseServer] <String>]
[[-DatabaseName] <String>] [[-SqlUser] <String>] [[-SqlPwd] <String>] [[-IdPrefix] <String>]
[[-NameSuffix] <String>] [[-IdValue] <String>] [[-NameValue] <String>] [[-AzureAdCredential] <PSCredential>]
[-ForceExactAadGroupName] [<CommonParameters>]
[-ForceExactAadGroupName] [[-EmailValue] <String>] [[-TenantId] <String>] [<CommonParameters>]
```

### GroupIdImport
```
Import-D365AadUser [[-StartupCompany] <String>] [[-DatabaseServer] <String>] [[-DatabaseName] <String>]
[[-SqlUser] <String>] [[-SqlPwd] <String>] [[-IdPrefix] <String>] [[-NameSuffix] <String>]
[[-IdValue] <String>] [[-NameValue] <String>] [[-AzureAdCredential] <PSCredential>] [-AadGroupId] <String>
[<CommonParameters>]
[[-EmailValue] <String>] [[-TenantId] <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -90,6 +90,15 @@ Imports Claire and Allen as users.
Will NOT make you connect to the Azure Active Directory(AAD).
The needed details will be based on the e-mail address only, and the rest will be blanked.

### EXAMPLE 7
```
Import-D365AadUser -Users "[email protected]","[email protected]" -TenantId "99999999-aaaa-bbbb-cccc-9999999999"
```

Imports Claire and Allen as users.
Uses tenant id "99999999-aaaa-bbbb-cccc-9999999999"
when connecting to Azure Active Directory(AAD).

## PARAMETERS

### -AadGroupName
Expand Down Expand Up @@ -334,6 +343,41 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EmailValue
Specify which field to use as EMAIL value when importing the users.
Available options 'Mail' / 'UserPrincipalName'
Default is 'Mail'
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 16
Default value: Mail
Accept pipeline input: False
Accept wildcard characters: False
```
### -TenantId
The TenantId to use when connecting to Azure Active Directory
Uses the tenant id of the current environment if not specified.
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 17
Default value: $Script:TenantId
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand All @@ -348,6 +392,8 @@ Author: Rasmus Andersen (@ITRasmus)
Author: Charles Colombel (@dropshind)
Author: Mötz Jensen (@Splaxi)
Author: Miklós Molnár (@scifimiki)
Author: Gert Van der Heyden (@gertvdh)
Author: Florian Hopfner (@FH-Inway)
At no circumstances can this cmdlet be used to import users into a PROD environment.
Expand Down

0 comments on commit 3526b72

Please sign in to comment.