Skip to content
Open
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
15 changes: 11 additions & 4 deletions module/EntraBeta/customizations/Set-EntraBetaUserLicense.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
Parameters = $null
Outputs = $null
CustomScript = @'
param (
[Alias("ObjectId")]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $UserId,
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Microsoft.Open.AzureAD.Model.AssignedLicenses] $AssignedLicenses
)
PROCESS {
$params = @{}
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand
if($null -ne $PSBoundParameters["ObjectId"])
if($null -ne $PSBoundParameters["UserId"])
{
$params["UserId"] = $PSBoundParameters["ObjectId"]
$UserId = $PSBoundParameters["ObjectId"]
$params["UserId"] = $PSBoundParameters["UserId"]
$UserId = $PSBoundParameters["UserId"]
}
$jsonBody = @{
addLicenses = @(if ($PSBoundParameters.AssignedLicenses.AddLicenses) {
Expand All @@ -39,7 +46,7 @@

$response | ForEach-Object {
if($null -ne $_) {
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
Add-Member -InputObject $_ -MemberType AliasProperty -Name UserId -Value Id
}
}
$response
Expand Down
22 changes: 16 additions & 6 deletions module/EntraBeta/customizations/Set-EntraBetaUserPassword.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
Parameters = $null
Outputs = $null
CustomScript = @'
param (
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Boolean] $ForceChangePasswordNextLogin,
[Alias("ObjectId")]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $UserId,
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Security.SecureString] $Password,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Boolean] $EnforceChangePasswordPolicy
)
PROCESS {
$params = @{}
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand

if($null -ne $PSBoundParameters["ObjectId"])
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
if($null -ne $PSBoundParameters["UserId"])
{
$userId = $PSBoundParameters["ObjectId"]
$userId = $PSBoundParameters["UserId"]
}
if($PSBoundParameters.ContainsKey("Verbose"))
{
Expand Down Expand Up @@ -76,7 +86,7 @@

$PasswordProfile = @{}
if($null -ne $PSBoundParameters["ForceChangePasswordNextLogin"]) { $PasswordProfile["ForceChangePasswordNextSignIn"] = $ForceChangePasswordNextSignIn }
if($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $ForceChangePasswordNextSignInWithMfa }
if($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $EnforceChangePasswordPolicy }
if($null -ne $PSBoundParameters["Password"]) { $PasswordProfile["password"] = $PlainPassword }

Write-Debug("============================ TRANSFORMATIONS ============================")
Expand All @@ -87,4 +97,4 @@
$response
}
'@
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Sets a user extension.

```powershell
Set-EntraBetaUserExtension
-ExtensionName <String>
-ObjectId <String>
-ExtensionId <String>
-UserId <String>
-ExtensionValue <String>
[<CommonParameters>]
```
Expand All @@ -38,7 +38,7 @@ Set-EntraBetaUserExtension

```powershell
Set-EntraBetaUserExtension
-ObjectId <String>
-UserId <String>
-ExtensionNameValues <System.Collections.Generic.Dictionary`2[System.String,System.String]>
[<CommonParameters>]
```
Expand All @@ -54,24 +54,24 @@ The `Set-EntraBetaUserExtension` cmdlet updates a user extension in Microsoft En
```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
$params = @{
ObjectId = 'SawyerM@contoso.com'
ExtensionName = 'extension_e5e29b8a85d941eab8d12162bd004528_extensionAttribute8'
UserId = 'SawyerM@contoso.com'
ExtensionId = 'extension_e5e29b8a85d941eab8d12162bd004528_extensionAttribute8'
ExtensionValue = 'New Value'
}
Set-EntraBetaUserExtension @params
```

This example shows how to update the value of the extension attribute for a specified user.

- `-ObjectId` parameter specifies the user Id.
- `-ExtensionName` parameter specifies the name of an extension.
- `-ExtensionValue` parameter specifies the extension name values.
- `-UserId` parameter specifies the user Id.
- `-ExtensionId` parameter specifies the Id of an extension.
- `-ExtensionValue` parameter specifies the extension Id values.

## Parameters

### -ExtensionName
### -ExtensionId

Specifies the name of an extension.
Specifies the Id of an extension.

```yaml
Type: System.String
Expand Down Expand Up @@ -117,9 +117,9 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### -ObjectId
### -UserId

Specifies the ID of an object.
Specifies the ID of a User.

```yaml
Type: System.String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Adds or removes licenses for a Microsoft online service to the list of assigned

```powershell
Set-EntraBetaUserLicense
-ObjectId <String>
-UserId <String>
-AssignedLicenses <AssignedLicenses>
[<CommonParameters>]
```
Expand All @@ -50,13 +50,13 @@ For delegated scenarios, the calling user needs at least one of the following Mi

```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
$LicensedUser = Get-EntraBetaUser -ObjectId 'TemplateUser@contoso.com'
$LicensedUser = Get-EntraBetaUser -UserId 'TemplateUser@contoso.com'
$License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License.SkuId = $LicensedUser.AssignedLicenses.SkuId
$Licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$Licenses.AddLicenses = $License
$Params = @{
ObjectId = 'SawyerM@contoso.com'
UserId = 'SawyerM@contoso.com'
AssignedLicenses = $Licenses
}
Set-EntraBetaUserLicense @Params
Expand All @@ -82,15 +82,15 @@ isLicenseReconciliationNeeded False

This example demonstrates how to assign a license to a user based on a template user.

- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId).
- `-UserId` parameter specifies the Id of a user(as a UserPrincipalName or UserId).
- `-AssignedLicenses` parameter specifies a list of licenses to assign or remove.

### Example 2: Add a license to a user by copying license from another user

```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
$LicensedUser = Get-EntraBetaUser -ObjectId 'AdeleV@contoso.com'
$User = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com'
$LicensedUser = Get-EntraBetaUser -UserId 'AdeleV@contoso.com'
$User = Get-EntraBetaUser -UserId 'SawyerM@contoso.com'
$License1 = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License1.SkuId = $LicensedUser.AssignedLicenses.SkuId[0]
$License2 = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
Expand All @@ -101,7 +101,7 @@ $addLicensesArray += $License2
$Licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$Licenses.AddLicenses = $addLicensesArray
$Params = @{
ObjectId = $User.ObjectId
UserId = $User.UserId
AssignedLicenses = $Licenses
}
Set-EntraBetaUserLicense @Params
Expand All @@ -127,19 +127,19 @@ isLicenseReconciliationNeeded False

This example demonstrates how to assign a license to a user by copying license from another user.

- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId).
- `-UserId` parameter specifies the Id of a user(as a UserPrincipalName or UserId).
- `-AssignedLicenses` parameter specifies a list of licenses to assign or remove.

### Example 3: Remove an assigned User's License

```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
$UserPrincipalName = 'SawyerM@contoso.com'
$User = Get-EntraBetaUser -ObjectId $UserPrincipalName
$SkuId = (Get-EntraBetaUserLicenseDetail -ObjectId $UserPrincipalName).SkuId
$User = Get-EntraBetaUser -UserId $UserPrincipalName
$SkuId = (Get-EntraBetaUserLicenseDetail -UserId $UserPrincipalName).SkuId
$Licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$Licenses.RemoveLicenses = $SkuId
Set-EntraBetaUserLicense -ObjectId $User.ObjectId -AssignedLicenses $Licenses
Set-EntraBetaUserLicense -UserId $User.UserId -AssignedLicenses $Licenses
```

```Output
Expand All @@ -161,7 +161,7 @@ givenName Sawyer

This example demonstrates how to remove a user's license by retrieving the user details.

- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId).
- `-UserId` parameter specifies the Id of a user(as a UserPrincipalName or UserId).
- `-AssignedLicenses` parameter specifies a list of licenses to assign or remove.

## Parameters
Expand All @@ -182,9 +182,9 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### -ObjectId
### -UserId

Specifies the ID of a user (as a UserPrincipalName or ObjectId) in Microsoft Entra ID.
Specifies the ID of a user (as a UserPrincipalName or UserId) in Microsoft Entra ID.

```yaml
Type: System.String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Sets the password of a user.

```powershell
Set-EntraBetaUserPassword
-ObjectId <String>
-UserId <String>
-Password <SecureString>
[-ForceChangePasswordNextLogin <Boolean>]
[-EnforceChangePasswordPolicy <Boolean>]
Expand All @@ -47,12 +47,12 @@ Any user can update their password without belonging to any administrator role.
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword = '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraBetaUserPassword -ObjectId 'SawyerM@contoso.com' -Password $securePassword
Set-EntraBetaUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword
```

This command sets the specified user's password.

- `-ObjectId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-UserId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-Password` parameter specifies the password to set.

### Example 2: Set a user's password with EnforceChangePasswordPolicy parameter
Expand All @@ -61,12 +61,12 @@ This command sets the specified user's password.
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword= '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraBetaUserPassword -ObjectId 'SawyerM@contoso.com' -Password $securePassword -EnforceChangePasswordPolicy $True
Set-EntraBetaUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword -EnforceChangePasswordPolicy $True
```

This command sets the specified user's password with EnforceChangePasswordPolicy parameter.

- `-ObjectId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-UserId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-Password` parameter specifies the password to set.
- `-EnforceChangePasswordPolicy` parameter force the user to change their password, if set to true.

Expand All @@ -81,7 +81,7 @@ Set-EntraBetaUserPassword -ObjectId 'SawyerM@contoso.com' -Password $securePassw

This command sets the specified user's password with ForceChangePasswordNextLogin parameter.

- `-ObjectId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-UserId` parameter specifies the ID of a user in Microsoft Entra ID.
- `-Password` parameter specifies the password to set.
- `-ForceChangePasswordNextLogin` parameter forces a user to change their password during their next log in.

Expand Down Expand Up @@ -119,9 +119,9 @@ Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```

### -ObjectId
### -UserId

Specifies the ID of an object.
Specifies the UserId

```yaml
Type: System.String
Expand Down
2 changes: 0 additions & 2 deletions src/CompatibilityAdapterBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class CompatibilityAdapterBuilder {
'Get-EntraBetaApplicationTemplate',
'Select-EntraBetaGroupIdsContactIsMemberOf',
'Set-EntraBetaCustomSecurityAttributeDefinitionAllowedValue',
'Set-EntraBetaUserLicense',
'Set-EntraBetaTrustFrameworkPolicy',
'Remove-EntraBetaUserAppRoleAssignment',
'Get-EntraBetaApplicationPolicy',
Expand Down Expand Up @@ -128,7 +127,6 @@ class CompatibilityAdapterBuilder {
'Set-EntraBetaPolicy',
'Set-EntraBetaCustomSecurityAttributeDefinition',
'Get-EntraBetaPrivilegedResource',
'Set-EntraBetaUserPassword',
'New-EntraBetaApplicationFromApplicationTemplate',
'Set-EntraBetaPrivilegedRoleSetting',
'Remove-EntraBetaApplicationKey',
Expand Down
Loading