Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSGraph] add new parameter set to new-azaduser, fix issues with get-azaduser #19308

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Resources/MSGraph.Autorest/custom/Get-AzADUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ function Get-AzADUser {
[System.String[]]
# Select properties to be returned
${Select},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Category('Query')]
[System.Management.Automation.SwitchParameter]
# Include count of items
${Count},

[Parameter(ParameterSetName='List')]
[Parameter(ParameterSetName='StartsWithParameterSet')]
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/MSGraph.Autorest/custom/New-AzADUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ https://docs.microsoft.com/powershell/module/az.resources/new-azaduser
#>
function New-AzADUser {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphUser])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[CmdletBinding(DefaultParameterSetName='WithPassword', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Category('Body')]
Expand Down Expand Up @@ -273,7 +273,7 @@ param(
# The two may be specified together; for example: DisablePasswordExpiration, DisableStrongPassword.Supports $filter (ne, NOT).
${PasswordPolicy},

[Parameter()]
[Parameter(ParameterSetName="WithPasswordProfile", Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile]
# passwordProfile
Expand Down Expand Up @@ -391,12 +391,12 @@ param(
# Supports $filter (eq, ne, NOT, in,).
${UserType},

[Parameter(Mandatory)]
[Parameter(ParameterSetName="WithPassword", Mandatory)]
[SecureString]
# Password for the user. It must meet the tenant's password complexity requirements. It is recommended to set a strong password.
${Password},

[Parameter()]
[Parameter(ParameterSetName="WithPassword")]
[System.Management.Automation.SwitchParameter]
# It must be specified if the user must change the password on the next successful login (true). Default behavior is (false) to not change the password on the next successful login.
${ForceChangePasswordNextLogin},
Expand Down
21 changes: 18 additions & 3 deletions src/Resources/MSGraph.Autorest/docs/Get-AzADUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Lists entities from users or get entity from users by key

### List (Default)
```
Get-AzADUser [-AppendSelected] [-ConsistencyLevel <String>] [-DefaultProfile <PSObject>] [-Expand <String[]>]
[-Filter <String>] [-First <UInt64>] [-Orderby <String[]>] [-Search <String>] [-Select <String[]>]
[-Skip <UInt64>] [<CommonParameters>]
Get-AzADUser [-Count] [-AppendSelected] [-ConsistencyLevel <String>] [-DefaultProfile <PSObject>]
[-Expand <String[]>] [-Filter <String>] [-First <UInt64>] [-Orderby <String[]>] [-Search <String>]
[-Select <String[]>] [-Skip <UInt64>] [<CommonParameters>]
```

### DisplayNameParameterSet
Expand Down Expand Up @@ -114,6 +114,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Count
Include count of items

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: List
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

Expand Down
50 changes: 38 additions & 12 deletions src/Resources/MSGraph.Autorest/docs/New-AzADUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Adds new entity to users

## SYNTAX

### WithPassword (Default)
```
New-AzADUser -DisplayName <String> -MailNickname <String> -Password <SecureString> -UserPrincipalName <String>
[-AboutMe <String>] [-AccountEnabled <Boolean>] [-AgeGroup <String>] [-Birthday <DateTime>] [-City <String>]
Expand All @@ -21,25 +22,50 @@ New-AzADUser -DisplayName <String> -MailNickname <String> -Password <SecureStrin
[-FaxNumber <String>] [-ForceChangePasswordNextLogin] [-GivenName <String>] [-HireDate <DateTime>]
[-ImmutableId <String>] [-Interest <String[]>] [-IsResourceAccount] [-JobTitle <String>] [-Mail <String>]
[-MobilePhone <String>] [-MySite <String>] [-OfficeLocation <String>] [-OtherMail <String[]>]
[-PasswordPolicy <String>] [-PasswordProfile <IMicrosoftGraphPasswordProfile>] [-PostalCode <String>]
[-PreferredLanguage <String>] [-PreferredName <String>] [-Responsibility <String[]>] [-School <String[]>]
[-ShowInAddressList] [-Skill <String[]>] [-State <String>] [-StreetAddress <String>] [-Surname <String>]
[-UsageLocation <String>] [-UserType <String>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf]
[<CommonParameters>]
[-PasswordPolicy <String>] [-PostalCode <String>] [-PreferredLanguage <String>] [-PreferredName <String>]
[-Responsibility <String[]>] [-School <String[]>] [-ShowInAddressList] [-Skill <String[]>] [-State <String>]
[-StreetAddress <String>] [-Surname <String>] [-UsageLocation <String>] [-UserType <String>]
[-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### WithPasswordProfile
```
New-AzADUser -DisplayName <String> -MailNickname <String> -PasswordProfile <IMicrosoftGraphPasswordProfile>
-UserPrincipalName <String> [-AboutMe <String>] [-AccountEnabled <Boolean>] [-AgeGroup <String>]
[-Birthday <DateTime>] [-City <String>] [-CompanyName <String>] [-ConsentProvidedForMinor <String>]
[-Country <String>] [-DeletedDateTime <DateTime>] [-Department <String>] [-DeviceEnrollmentLimit <Int32>]
[-EmployeeHireDate <DateTime>] [-EmployeeId <String>] [-EmployeeType <String>] [-ExternalUserState <String>]
[-ExternalUserStateChangeDateTime <DateTime>] [-FaxNumber <String>] [-GivenName <String>]
[-HireDate <DateTime>] [-ImmutableId <String>] [-Interest <String[]>] [-IsResourceAccount]
[-JobTitle <String>] [-Mail <String>] [-MobilePhone <String>] [-MySite <String>] [-OfficeLocation <String>]
[-OtherMail <String[]>] [-PasswordPolicy <String>] [-PostalCode <String>] [-PreferredLanguage <String>]
[-PreferredName <String>] [-Responsibility <String[]>] [-School <String[]>] [-ShowInAddressList]
[-Skill <String[]>] [-State <String>] [-StreetAddress <String>] [-Surname <String>] [-UsageLocation <String>]
[-UserType <String>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

## DESCRIPTION
Adds new entity to users

## EXAMPLES

### Example 1: Create user
### Example 1: Create user with password profile
```powershell
$password = "xxxxxxxxxx"
$pp = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile" -Property @{Password=$password}
New-AzADUser -DisplayName $uname -PasswordProfile $pp -AccountEnabled $true -MailNickname $nickname -UserPrincipalName $upn
```

Create user
Create user with password profile

### Example 2: Create user with password
```powershell
$password = "xxxxxxxxxx"
$password = ConvertTo-SecureString -AsPlainText -Force $password
New-AzADUser -DisplayName $uname -Password $password -AccountEnabled $true -MailNickname $nickname -UserPrincipalName $upn
```

Create user with password

## PARAMETERS

Expand Down Expand Up @@ -363,7 +389,7 @@ Default behavior is (false) to not change the password on the next successful lo

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Parameter Sets: WithPassword
Aliases:

Required: False
Expand Down Expand Up @@ -585,7 +611,7 @@ It is recommended to set a strong password.

```yaml
Type: System.Security.SecureString
Parameter Sets: (All)
Parameter Sets: WithPassword
Aliases:

Required: True
Expand Down Expand Up @@ -619,10 +645,10 @@ To construct, see NOTES section for PASSWORDPROFILE properties and create a hash

```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile
Parameter Sets: (All)
Parameter Sets: WithPasswordProfile
Aliases:

Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Expand Down Expand Up @@ -903,7 +929,7 @@ COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.


PASSWORDPROFILE <IMicrosoftGraphPasswordProfile>: passwordProfile
`PASSWORDPROFILE <IMicrosoftGraphPasswordProfile>`: passwordProfile
- `[(Any) <Object>]`: This indicates any property can be added to this object.
- `[ForceChangePasswordNextSignIn <Boolean?>]`: true if the user must change her password on the next login; otherwise false. If not set, default is false. NOTE: For Azure B2C tenants, set to false and instead use custom policies and user flows to force password reset at first sign in. See Force password reset at first logon.
- `[ForceChangePasswordNextSignInWithMfa <Boolean?>]`: If true, at next sign-in, the user must perform a multi-factor authentication (MFA) before being forced to change their password. The behavior is identical to forceChangePasswordNextSignIn except that the user is required to first perform a multi-factor authentication before password change. After a password change, this property will be automatically reset to false. If not set, default is false.
Expand Down
14 changes: 12 additions & 2 deletions src/Resources/MSGraph.Autorest/examples/New-AzADUser.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
### Example 1: Create user
### Example 1: Create user with password profile
```powershell
$password = "xxxxxxxxxx"
$pp = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordProfile" -Property @{Password=$password}
New-AzADUser -DisplayName $uname -PasswordProfile $pp -AccountEnabled $true -MailNickname $nickname -UserPrincipalName $upn
```

Create user
Create user with password profile

### Example 2: Create user with password
```powershell
$password = "xxxxxxxxxx"
$password = ConvertTo-SecureString -AsPlainText -Force $password
New-AzADUser -DisplayName $uname -Password $password -AccountEnabled $true -MailNickname $nickname -UserPrincipalName $upn
```

Create user with password
18 changes: 18 additions & 0 deletions src/Resources/OpenApiSpecs/v1.0/Users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,8 @@ components:
type: string
description: 'The employee identifier assigned to the user by the organization. Supports $filter (eq, ne, NOT , ge, le, in, startsWith).'
nullable: true
employeeOrgData:
$ref: '#/components/schemas/microsoft.graph.employeeOrgData'
employeeType:
type: string
description: 'Captures enterprise worker type. For example, Employee, Contractor, Consultant, or Vendor. Supports $filter (eq, ne, NOT , ge, le, in, startsWith).'
Expand Down Expand Up @@ -1285,6 +1287,8 @@ components:
readOnly: true
description: 'Used by enterprise applications to determine the legal age group of the user. This property is read-only and calculated based on ageGroup and consentProvidedForMinor properties. Allowed values: null, minorWithOutParentalConsent, minorWithParentalConsent, minorNoParentalConsentRequired, notAdult and adult. Refer to the legal age group property definitions for further information. Returned only on $select.'
nullable: true
manager:
$ref: '../CommonTypes.yml#/components/schemas/microsoft.graph.directoryObject'
mail:
type: string
description: 'The SMTP address for the user, for example, [email protected]. Changes to this property will also update the user''s proxyAddresses collection to include the value as an SMTP address. While this property can contain accent characters, using them can cause access issues with other Microsoft applications for the user. Supports $filter (eq, ne, NOT, ge, le, in, startsWith, endsWith).'
Expand Down Expand Up @@ -1396,6 +1400,20 @@ components:
additionalProperties:
type: object
description: Represents an Azure Active Directory user object.
microsoft.graph.employeeOrgData:
title: employeeOrgData
type: object
properties:
costCenter:
type: string
description: The cost center associated with the user. Returned only on $select. Supports $filter.
nullable: true
division:
type: string
description: The name of the division in which the user works. Returned only on $select. Supports $filter.
nullable: true
additionalProperties:
type: object
microsoft.graph.objectIdentity:
title: objectIdentity
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
"Az.Resources","Get-AzADAppFederatedIdentityCredential","Get-AzADAppFederatedIdentityCredential","0","1000","The cmdlet 'Get-AzADAppFederatedIdentityCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADAppFederatedIdentityCredential' back to the module, or add an alias to the original cmdlet name."
"Az.Resources","New-AzADAppFederatedIdentityCredential","New-AzADAppFederatedIdentityCredential","0","1000","The cmdlet 'New-AzADAppFederatedIdentityCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADAppFederatedIdentityCredential' back to the module, or add an alias to the original cmdlet name."
"Az.Resources","Remove-AzADAppFederatedIdentityCredential","Remove-AzADAppFederatedIdentityCredential","0","1000","The cmdlet 'Remove-AzADAppFederatedIdentityCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADAppFederatedIdentityCredential' back to the module, or add an alias to the original cmdlet name."
"Az.Resources","Update-AzADAppFederatedIdentityCredential","Update-AzADAppFederatedIdentityCredential","0","1000","The cmdlet 'Update-AzADAppFederatedIdentityCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Update-AzADAppFederatedIdentityCredential' back to the module, or add an alias to the original cmdlet name."
"Az.Resources","Update-AzADAppFederatedIdentityCredential","Update-AzADAppFederatedIdentityCredential","0","1000","The cmdlet 'Update-AzADAppFederatedIdentityCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Update-AzADAppFederatedIdentityCredential' back to the module, or add an alias to the original cmdlet name."
"Az.Resources","New-AzADUser","New-AzADUser","0","1050","The parameter set '__AllParameterSets' for cmdlet 'New-AzADUser' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'New-AzADUser'."