From c4c338a39cb073ab0bed2cec344784080e69a7c8 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Thu, 5 Sep 2024 14:00:39 +0530 Subject: [PATCH 01/64] added code for parameter renaming --- src/CompatibilityAdapterBuilder.ps1 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 8f154a301..9d4a57d98 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -565,7 +565,16 @@ Set-Variable -name MISSING_CMDS -value @('$($this.ModuleMap.MissingCommandsList $parameterDefinitions = $this.GetParametersDefinitions($Command) $ParamterTransformations = $this.GetParametersTransformations($Command) $OutputTransformations = $this.GetOutputTransformations($Command) - $function = @" + if ($parameterDefinitions.Contains('$ObjectId') -or $parameterDefinitions.Contains('$Id')) { + $function = @" +function $($Command.Generate) { +$($Command.CustomScript) +} + +"@ + } + else { + $function = @" function $($Command.Generate) { [CmdletBinding($($Command.DefaultParameterSet))] param ( @@ -575,7 +584,8 @@ $parameterDefinitions $($Command.CustomScript) } -"@ +"@ + } $codeBlock = [Scriptblock]::Create($function) return [CommandTranslation]::New($Command.Generate,$Command.Old,$codeBlock) } @@ -655,12 +665,18 @@ $OutputTransformations if($commonParameterNames.Contains($paramKey)) { continue } + $targetParam = $Command.Parameters[$paramKey] $param = $params[$paramKey] $paramType = $param.ParameterType.ToString() $paramtypeToCreate = $param.ParameterType.ToString() if($param.Name -eq 'All'){ $paramType = "switch" } + if(($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $targetParam.TargetName){ + if ($targetParam.TargetName) { + $param.Name = $targetParam.TargetName + } + } if(($null -ne $this.TypePrefix) -and ($paramType -like "*$($this.TypePrefix)*")){ if($paramType -like "*List*"){ $paramType = "System.Collections.Generic.List``1[$($param.ParameterType.GenericTypeArguments.FullName)]" @@ -771,7 +787,9 @@ $OutputTransformations $paramBlock = $this.GetParameterTransformationName($param.Name, $param.Name) } elseif([TransformationTypes]::Name -eq $param.ConversionType){ - $paramBlock = $this.GetParameterTransformationName($param.Name, $param.TargetName) + if(($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $param.TargetName){ + $paramBlock = $this.GetParameterTransformationName($param.TargetName, $param.TargetName) + } } elseif([TransformationTypes]::Bool2Switch -eq $param.ConversionType){ $paramBlock = $this.GetParameterTransformationBoolean2Switch($param.Name, $param.TargetName) From 6b41b60fa49aad7fbf7350bc27d804d1ac15fc4f Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Thu, 5 Sep 2024 18:13:14 +0530 Subject: [PATCH 02/64] added customscript example --- module/Entra/customizations/Get-EntraUser.ps1 | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/module/Entra/customizations/Get-EntraUser.ps1 b/module/Entra/customizations/Get-EntraUser.ps1 index 293f44cef..8aff55a82 100644 --- a/module/Entra/customizations/Get-EntraUser.ps1 +++ b/module/Entra/customizations/Get-EntraUser.ps1 @@ -7,6 +7,22 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $params = @{} @@ -40,9 +56,9 @@ $params["Uri"] += "&$SearchString" $customHeaders['ConsistencyLevel'] = 'eventual' } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $UserId = $PSBoundParameters["ObjectId"] + $UserId = $PSBoundParameters["UserId"] if ($UserId -match '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'){ $f = '$' + 'Filter' $Filter = "UserPrincipalName eq '$UserId'" @@ -67,7 +83,7 @@ $response = Invoke-GraphRequest @params -Headers $customHeaders if ($upnPresent -and ($null -eq $response.value -or $response.value.Count -eq 0)) { - Write-Error "Resource '$ObjectId' does not exist or one of its queried reference-property objects are not present. + Write-Error "Resource '$UserId' does not exist or one of its queried reference-property objects are not present. Status: 404 (NotFound) ErrorCode: Request_ResourceNotFound" } From 1ccc08dd7767bea459cbee3be9560bcf8a2ef055 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 6 Sep 2024 10:27:07 +0530 Subject: [PATCH 03/64] updated Get-EntraUser --- .../Entra/customizations/Set-EntraDevice.ps1 | 66 ++----------------- .../Microsoft.Graph.Entra/Get-EntraUser.md | 10 +-- test/module/Entra/Get-EntraUser.Tests.ps1 | 8 +-- 3 files changed, 13 insertions(+), 71 deletions(-) diff --git a/module/Entra/customizations/Set-EntraDevice.ps1 b/module/Entra/customizations/Set-EntraDevice.ps1 index ba06573b3..2247350d4 100644 --- a/module/Entra/customizations/Set-EntraDevice.ps1 +++ b/module/Entra/customizations/Set-EntraDevice.ps1 @@ -3,67 +3,9 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = "Update-MgDevice" - Parameters = @( - @{ - SourceName = "ApproximateLastLogonTimeStamp" - TargetName = "ApproximateLastSignInDateTime" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceId" - TargetName = "DeviceId1" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceObjectVersion" - TargetName = "DeviceVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSType" - TargetName = "OperatingSystem" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSVersion" - TargetName = "OperatingSystemVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DevicePhysicalIds" - TargetName = "PhysicalIds" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceTrustType" - TargetName = "TrustType" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "AlternativeSecurityIds" - TargetName = "BodyParameter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) - $Temp = @{ - alternativeSecurityIds = @( - @{ - type = $TmpValue.type - key = [System.Text.Encoding]::ASCII.GetBytes($key) - } - ) - } - $Value = $Temp -'@ - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' +'@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md index a98fce141..eb09a9d86 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md @@ -49,7 +49,7 @@ Get-EntraUser ```powershell Get-EntraUser - -ObjectId + -UserId [-All] [-Property ] [] @@ -82,7 +82,7 @@ This example demonstrates how to get top three users from Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUser -ObjectId 'SawyerM@contoso.com' +Get-EntraUser -UserId 'SawyerM@contoso.com' ``` ```Output @@ -143,7 +143,7 @@ In this example, we retrieve all users whose MailNickname starts with Ada. ```powershell Connect-Entra -Scopes 'User.Read.All','AuditLog.Read.All' -Get-EntraUser -ObjectId 'SawyerM@contoso.com' -Property 'SignInActivity' | Select-Object -ExpandProperty 'SignInActivity' +Get-EntraUser -UserId 'SawyerM@contoso.com' -Property 'SignInActivity' | Select-Object -ExpandProperty 'SignInActivity' ``` ```Output @@ -193,9 +193,9 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID (as a UserPrincipalName or ObjectId) of a user in Microsoft Entra ID. +Specifies the ID (as a UserPrincipalName or UserId) of a user in Microsoft Entra ID. ```yaml Type: System.String diff --git a/test/module/Entra/Get-EntraUser.Tests.ps1 b/test/module/Entra/Get-EntraUser.Tests.ps1 index fc91b8bd3..9f6761da5 100644 --- a/test/module/Entra/Get-EntraUser.Tests.ps1 +++ b/test/module/Entra/Get-EntraUser.Tests.ps1 @@ -61,7 +61,7 @@ BeforeAll { Describe "Get-EntraUser" { Context "Test for Get-EntraUser" { It "Should return specific user" { - $result = Get-EntraUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" Write-Verbose "Result : {$result}" -Verbose $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') @@ -84,11 +84,11 @@ Describe "Get-EntraUser" { } It "Should fail when ObjectId is empty string value" { - { Get-EntraUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraUser -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should fail when ObjectId is empty" { - { Get-EntraUser -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + { Get-EntraUser -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should return all contact" { @@ -161,7 +161,7 @@ Describe "Get-EntraUser" { try { # Act & Assert: Ensure the function doesn't throw an exception { - Get-EntraUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug + Get-EntraUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference From ff7a226f21c5025ba75022e274253bf88f2406fe Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 6 Sep 2024 10:27:22 +0530 Subject: [PATCH 04/64] updated Get-EntraUser --- .../Entra/customizations/Set-EntraDevice.ps1 | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/module/Entra/customizations/Set-EntraDevice.ps1 b/module/Entra/customizations/Set-EntraDevice.ps1 index 2247350d4..ba06573b3 100644 --- a/module/Entra/customizations/Set-EntraDevice.ps1 +++ b/module/Entra/customizations/Set-EntraDevice.ps1 @@ -3,9 +3,67 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = $null - Parameters = $null - Outputs = $null - CustomScript = @' + TargetName = "Update-MgDevice" + Parameters = @( + @{ + SourceName = "ApproximateLastLogonTimeStamp" + TargetName = "ApproximateLastSignInDateTime" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceId" + TargetName = "DeviceId1" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceObjectVersion" + TargetName = "DeviceVersion" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceOSType" + TargetName = "OperatingSystem" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceOSVersion" + TargetName = "OperatingSystemVersion" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DevicePhysicalIds" + TargetName = "PhysicalIds" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceTrustType" + TargetName = "TrustType" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "AlternativeSecurityIds" + TargetName = "BodyParameter" + ConversionType = "ScriptBlock" + SpecialMapping = @' + $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) + $Temp = @{ + alternativeSecurityIds = @( + @{ + type = $TmpValue.type + key = [System.Text.Encoding]::ASCII.GetBytes($key) + } + ) + } + $Value = $Temp '@ + } + ) + Outputs = $null } \ No newline at end of file From 605ef37a1859e113bc25bb1e7176b6f7916ed09b Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 6 Sep 2024 10:38:24 +0530 Subject: [PATCH 05/64] updated Remove-EntraUser --- .../Microsoft.Graph.Entra/Remove-EntraUser.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md index 6ada448cf..7a78367c8 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md @@ -27,7 +27,7 @@ Removes a user. ```powershell Remove-EntraUser - -ObjectId + -UserId [] ``` @@ -47,16 +47,16 @@ The calling user must be assigned at least one of the following Microsoft Entra ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -Remove-EntraUser -ObjectId 'SawyerM@Contoso.com' +Remove-EntraUser -UserId 'SawyerM@Contoso.com' ``` This command removes the specified user in Microsoft Entra ID. ## Parameters -### -ObjectId +### -UserId -Specifies the ID of a user (as a UPN or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a UPN or UserId) in Microsoft Entra ID. ```yaml Type: System.String From 9dd7d74816820acd71e863ff6b0709e855d5c747 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 6 Sep 2024 15:44:22 +0530 Subject: [PATCH 06/64] updated docs and UT --- .../customizations/Get-EntraApplication.ps1 | 22 +++++++-- .../customizations/Set-EntraApplication.ps1 | 48 ++++++++++++++++++- .../Get-EntraApplication.md | 8 ++-- .../Get-EntraApplicationExtensionProperty.md | 8 ++-- .../Get-EntraContactManager.md | 8 ++-- .../Get-EntraContract.md | 6 +-- .../Get-EntraDirectoryRole.md | 6 +-- .../Get-EntraGroupLifecyclePolicy.md | 8 ++-- .../Get-EntraGroupPermissionGrant.md | 6 +-- .../Remove-EntraApplication.md | 8 ++-- ...emove-EntraApplicationExtensionProperty.md | 6 +-- .../Remove-EntraContact.md | 6 +-- .../Remove-EntraDevice.md | 6 +-- .../Remove-EntraGroup.md | 8 ++-- .../Remove-EntraGroupLifecyclePolicy.md | 6 +-- .../Remove-EntraIdentityProvider.md | 6 +-- .../Remove-EntraServicePrincipal.md | 6 +-- .../Set-EntraApplication.md | 14 +++--- .../Microsoft.Graph.Entra/Set-EntraGroup.md | 16 +++---- .../Set-EntraGroupLifecyclePolicy.md | 8 ++-- .../Entra/Get-EntraApplication.Tests.ps1 | 18 +++---- .../Entra/Get-EntraDirectoryRole.Tests.ps1 | 18 +++---- .../Entra/Remove-EntraApplication.Tests.ps1 | 16 +++---- .../module/Entra/Remove-EntraDevice.Tests.ps1 | 16 +++---- test/module/Entra/Remove-EntraGroup.Tests.ps1 | 16 +++---- .../Entra/Set-EntraApplication.Tests.ps1 | 16 +++---- test/module/Entra/Set-EntraGroup.Tests.ps1 | 16 +++---- 27 files changed, 193 insertions(+), 133 deletions(-) diff --git a/module/Entra/customizations/Get-EntraApplication.ps1 b/module/Entra/customizations/Get-EntraApplication.ps1 index 10bbe2f17..6a1c4e9c7 100644 --- a/module/Entra/customizations/Get-EntraApplication.ps1 +++ b/module/Entra/customizations/Get-EntraApplication.ps1 @@ -7,19 +7,35 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $keysChanged = @{SearchString = "Filter"; ObjectId = "Id"} + $keysChanged = @{SearchString = "Filter"; ApplicationId = "Id"} if($null -ne $PSBoundParameters["SearchString"]) { $TmpValue = $PSBoundParameters["SearchString"] $Value = "displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')" $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["Property"]) { diff --git a/module/Entra/customizations/Set-EntraApplication.ps1 b/module/Entra/customizations/Set-EntraApplication.ps1 index 4ffc385dd..771b059e7 100644 --- a/module/Entra/customizations/Set-EntraApplication.ps1 +++ b/module/Entra/customizations/Set-EntraApplication.ps1 @@ -7,6 +7,50 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $TokenEncryptionKeyId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.ApiApplication] $Api, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AddIn]] $AddIns, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.ParentalControlSettings] $ParentalControlSettings, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DisplayName, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AppRole]] $AppRoles, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.PublicClientApplication] $PublicClient, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.RequiredResourceAccess]] $RequiredResourceAccess, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsDeviceOnlyAuthSupported, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsFallbackPublicClient, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $IdentifierUris, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.OptionalClaims] $OptionalClaims, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.PasswordCredential]] $PasswordCredentials, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $GroupMembershipClaims, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.WebApplication] $Web, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.InformationalUrl] $InformationalUrl, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $Tags, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.KeyCredential]] $KeyCredentials, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $SignInAudience + ) + PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -123,9 +167,9 @@ { $params["GroupMembershipClaims"] = $PSBoundParameters["GroupMembershipClaims"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["AddIns"]) { diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md index a84a3d8e4..3141dbfe5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md @@ -49,7 +49,7 @@ Get-EntraApplication ```powershell Get-EntraApplication - -ObjectId + -ApplicationId [-Property ] [-All] [] @@ -61,11 +61,11 @@ The `Get-EntraApplication` cmdlet gets a Microsoft Entra ID application. ## Examples -### Example 1: Get an application by ObjectId +### Example 1: Get an application by ApplicationId ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -193,7 +193,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md index 5af944c7c..8d77e5495 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md @@ -26,7 +26,7 @@ Gets application extension properties. ```powershell Get-EntraApplicationExtensionProperty - -ObjectId + -ApplicationId [-Property ] [] ``` @@ -42,7 +42,7 @@ The `Get-EntraApplicationExtensionProperty` cmdlet gets application extension pr ```powershell Connect-Entra -Scopes 'Application.Read.All' $Application = Get-EntraApplication -SearchString '' -Get-EntraApplicationExtensionProperty -ObjectId $Application.ObjectId +Get-EntraApplicationExtensionProperty -ApplicationId $Application.ObjectId ``` ```Output @@ -53,11 +53,11 @@ DeletedDateTime Id AppDisplayName DataType IsM This command gets the extension properties for the specified application in Microsoft Entra ID. You cane use the command `Get-EntraApplication` to get application Id. -- `-ObjectId` parameter specifies the the unique identifier of a application. +- `-ApplicationId` parameter specifies the the unique identifier of a application. ## Parameters -### -ObjectId +### -ApplicationId Specifies the unique ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md index 8e07f9393..93529d200 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md @@ -26,7 +26,7 @@ Gets the manager of a contact. ```powershell Get-EntraContactManager - -ObjectId + -OrgContactId [-Property ] [] ``` @@ -42,16 +42,16 @@ The `Get-EntraContactManager` cmdlet gets the manager of a contact in Microsoft ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraContact -Top 1 -Get-EntraContactManager -ObjectId $Contact.ObjectId +Get-EntraContactManager -OrgContactId $Contact.ObjectId ``` The example demonstrates how to retrieve the manager of a contact. You can use the command `Get-EntraContact` to get organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ## Parameters -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md index d308eb8c4..9ae83a4d2 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md @@ -39,7 +39,7 @@ Get-EntraContract ```powershell Get-EntraContract - -ObjectId + -ContractId [-All] [-Property ] [] @@ -77,7 +77,7 @@ It isn't automatically updated if the customer tenant's display name changes. - `objectType` - a string that identifies the object type. The value is always `Contract`. -- `ObjectId` - the unique identifier for the partnership. +- `ContractId` - the unique identifier for the partnership. ## Examples @@ -134,7 +134,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ContractId Specifies the ID of a contract. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md index ef185c317..2fec5f7de 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md @@ -37,7 +37,7 @@ Get-EntraDirectoryRole ```powershell Get-EntraDirectoryRole - -ObjectId + -DirectoryRoleId [-Property ] [] ``` @@ -52,7 +52,7 @@ The `Get-EntraDirectoryRole` cmdlet gets a directory role from Microsoft Entra I ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory' -Get-EntraDirectoryRole -ObjectId '019ea7a2-1613-47c9-81cb-20ba35b1ae48' +Get-EntraDirectoryRole -DirectoryRoleId '019ea7a2-1613-47c9-81cb-20ba35b1ae48' ``` ```Output @@ -135,7 +135,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md index 906e22b50..e28e74dab 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md @@ -37,7 +37,7 @@ Get-EntraGroupLifecyclePolicy ```powershell Get-EntraGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [-Property ] [] ``` @@ -70,7 +70,7 @@ This command retrieves the group expiration settings configured for the tenant. ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraGroupLifecyclePolicy -Id '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' +Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' ``` ```output @@ -79,11 +79,11 @@ Id AlternateNotificationEmails GroupLifetimeIn 1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5 admingroup@contoso.com 200 All ``` -This command is used to retrieve a specific Microsoft Group Lifecycle Policy. The `-Id` parameter specifies the ID of the Lifecycle Policy to be retrieved. +This command is used to retrieve a specific Microsoft Group Lifecycle Policy. The `-GroupLifecyclePolicyId` parameter specifies the ID of the Lifecycle Policy to be retrieved. ## Parameters -### -Id +### -GroupLifecyclePolicyId Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md index e25faecc3..b570dde4a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md @@ -26,7 +26,7 @@ Retrieves a list of permission grants that have been consented for this group. ```powershell Get-EntraGroupPermissionGrant - -Id + -GroupId [-Property ] [] ``` @@ -41,7 +41,7 @@ Retrieves a list of permission grants that have been consented for this group. ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupPermissionGrant -Id 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' +Get-EntraGroupPermissionGrant -GroupId 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' ``` ```output @@ -57,7 +57,7 @@ This cmdlet list existing permission grants for the specified group. ## Parameters -### -Id +### -GroupId The unique identifier of group. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md index 14b68704b..228100eeb 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md @@ -20,13 +20,13 @@ schema: 2.0.0 ## Synopsis -Delete an application by ObjectId. +Delete an application by ApplicationId. ## Syntax ```powershell Remove-EntraApplication - -ObjectId + -ApplicationId [] ``` @@ -40,14 +40,14 @@ The `Remove-EntraApplication` cmdlet removes the specified application from Micr ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Remove-EntraApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This command removes the specified application. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md index 3263cbf71..141f8d71e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md @@ -27,7 +27,7 @@ Removes an application extension property. ```powershell Remove-EntraApplicationExtensionProperty -ExtensionPropertyId - -ObjectId + -ApplicationId [] ``` @@ -42,7 +42,7 @@ The `Remove-EntraApplicationExtensionProperty` cmdlet removes an application ext ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $params = @{ - ObjectId = '22223333-cccc-4444-dddd-5555eeee6666' + ApplicationId = '22223333-cccc-4444-dddd-5555eeee6666' ExtensionPropertyId = 'cccc2222-dd33-4444-55ee-666666ffffff' } @@ -69,7 +69,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the unique ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md index 23c612b36..0f395ab06 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md @@ -26,7 +26,7 @@ Removes a contact. ```powershell Remove-EntraContact - -ObjectId + -OrgContactId [] ``` @@ -41,14 +41,14 @@ The Remove-EntraContact removes a contact from Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraContact -Top 1 -Remove-EntraContact -ObjectId $Contact.ObjectId +Remove-EntraContact -OrgContactId $Contact.ObjectId ``` The example shows how to remove a contact. ## Parameters -### -ObjectId +### -OrgContactId Specifies the object ID of a contact in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md index c3fb8746a..bafc190a5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md @@ -26,7 +26,7 @@ Deletes a device. ```powershell Remove-EntraDevice - -ObjectId + -DeviceId [] ``` @@ -42,14 +42,14 @@ The calling user must be in one of the following Microsoft Entra roles: Intune A ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Remove-EntraDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraDevice -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This command removes the specified device. ## Parameters -### -ObjectId +### -DeviceId Specifies the object ID of a device in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md index 171f5dfdd..fd354a4a6 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md @@ -25,7 +25,7 @@ Removes a group. ```powershell Remove-EntraGroup - -ObjectId + -GroupId [] ``` @@ -49,14 +49,14 @@ The following conditions apply for apps to delete role-assignable groups: ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -Remove-EntraGroup -ObjectId $group.Id +Remove-EntraGroup -GroupId $group.Id ``` -This command is used to remove a group. The `-ObjectId` parameter specifies the ID of the group to be removed. +This command is used to remove a group. The `-GroupId` parameter specifies the ID of the group to be removed. ## Parameters -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md index afd4bcd48..192a1248d 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md @@ -27,7 +27,7 @@ Deletes a groupLifecyclePolicies object ```powershell Remove-EntraGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [] ``` @@ -41,14 +41,14 @@ The Remove-EntraGroupLifecyclePolicy command deletes a groupLifecyclePolicies ob ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-EntraGroupLifecyclePolicy -Id '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' +Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' ``` This cmdlet deletes the groupLifecyclePolicies object that has the specified ID. ## Parameters -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the groupLifecyclePolicies object that this cmdlet removes. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md index ec3df8cad..0792c35e1 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md @@ -26,7 +26,7 @@ This cmdlet is used to delete an identity provider in the directory. ```powershell Remove-EntraIdentityProvider - -Id + -IdentityProviderBaseId [] ``` @@ -44,14 +44,14 @@ The work or school account needs to belong to at least the External Identity Pro ```Powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' -Remove-EntraIdentityProvider -Id LinkedIn-OAUTH +Remove-EntraIdentityProvider -IdentityProviderBaseId LinkedIn-OAUTH ``` This command demonstrates how to remove the specified identity provider. ## Parameters -### -Id +### -IdentityProviderBaseId The unique identifier for an identity provider. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md index 3eeb20008..a22e6014d 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md @@ -26,7 +26,7 @@ Removes a service principal. ```powershell Remove-EntraServicePrincipal - -ObjectId + -ServicePrincipalId [] ``` @@ -41,14 +41,14 @@ The Remove-EntraServicePrincipal cmdlet removes a service principal in Microsoft ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission -Remove-EntraServicePrincipal -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' +Remove-EntraServicePrincipal -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' ``` This example demonstrates how to remove a service principal in Microsoft Entra ID. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md index 67e7582d0..791ec2c49 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md @@ -27,7 +27,7 @@ Updates the properties of an application object. ```powershell Set-EntraApplication - -ObjectId + -ApplicationId [-PasswordCredentials ] [-TokenEncryptionKeyId ] [-SignInAudience ] @@ -61,7 +61,7 @@ Updates the properties of an application object. Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $params = @{ - ObjectId = '11112222-bbbb-3333-cccc-4444dddd5555' + ApplicationId = '11112222-bbbb-3333-cccc-4444dddd5555' DisplayName = 'My new application' } @@ -76,7 +76,7 @@ This command updates an application in Microsoft Entra ID. Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $params = @{ - ObjectId = '11112222-bbbb-3333-cccc-4444dddd5555' + ApplicationId = '11112222-bbbb-3333-cccc-4444dddd5555' IdentifierUris = 'https://mynewapp.contoso.com' } @@ -91,7 +91,7 @@ This command updates an application in Microsoft Entra ID. Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $params = @{ - ObjectId = '11112222-bbbb-3333-cccc-4444dddd5555' + ApplicationId = '11112222-bbbb-3333-cccc-4444dddd5555' GroupMembershipClaims = 'SecurityGroup' } @@ -106,7 +106,7 @@ This command updates an application in Microsoft Entra ID. Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $params = @{ - ObjectId = '11112222-bbbb-3333-cccc-4444dddd5555' + ApplicationId = '11112222-bbbb-3333-cccc-4444dddd5555' IsDeviceOnlyAuthSupported = $false } @@ -121,7 +121,7 @@ This command updates an application in Microsoft Entra ID. Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $params = @{ - ObjectId = '11112222-bbbb-3333-cccc-4444dddd5555' + ApplicationId = '11112222-bbbb-3333-cccc-4444dddd5555' Tags = 'mytag' } @@ -285,7 +285,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md index cad5b1168..7a127262f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md @@ -26,7 +26,7 @@ Sets the properties for an existing Microsoft Entra ID group. ```powershell Set-EntraGroup - -Id + -GroupId [-DisplayName ] [-GroupTypes ] [-SecurityEnabled ] @@ -48,7 +48,7 @@ The Set-EntraGroup cmdlet sets the properties for an existing Microsoft Entra ID ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -DisplayName 'UPDATE helpdesk' +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -DisplayName 'UPDATE helpdesk' ``` This command updates the display name of a specified group in Microsoft Entra ID. @@ -57,7 +57,7 @@ This command updates the display name of a specified group in Microsoft Entra ID ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -Description 'This is my new group' +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -Description 'This is my new group' ``` This example demonstrates how to update a group description. @@ -66,7 +66,7 @@ This example demonstrates how to update a group description. ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MailNickName 'newnickname' +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MailNickName 'newnickname' ``` This command updates the mail nickname of a specified group in Microsoft Entra ID. @@ -75,7 +75,7 @@ This command updates the mail nickname of a specified group in Microsoft Entra I ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -SecurityEnabled $true +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -SecurityEnabled $true ``` This command updates the security enabled of a specified group in Microsoft Entra ID. @@ -84,7 +84,7 @@ This command updates the security enabled of a specified group in Microsoft Entr ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MailEnabled $false +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MailEnabled $false ``` This example demonstrates how to update a group main enabled. @@ -92,7 +92,7 @@ This example demonstrates how to update a group main enabled. ### Example 6: Update a property for a group ```powershell -Set-EntraGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -Visibility 'Private' -GroupTypes 'DynamicMembership' -IsAssignableToRole $true +Set-EntraGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -Visibility 'Private' -GroupTypes 'DynamicMembership' -IsAssignableToRole $true ``` This example demonstrates how to update a property for an existing Microsoft Entra ID group. @@ -148,7 +148,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupId Specifies the object ID of a group. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md index 1c624d633..1063cfc58 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md @@ -26,7 +26,7 @@ Updates a specific group Lifecycle Policy in Microsoft Entra ID. ```powershell Set-EntraGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [-AlternateNotificationEmails ] [-GroupLifetimeInDays ] [-ManagedGroupTypes ] @@ -43,7 +43,7 @@ The Set-EntraGroupLifecyclePolicy command updates a specific group Lifecycle Pol ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Set-EntraGroupLifecyclePolicy -Id '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' -GroupLifetimeInDays 200 -AlternateNotificationEmails 'admingroup@contoso.com' -ManagedGroupTypes 'All' +Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' -GroupLifetimeInDays 200 -AlternateNotificationEmails 'admingroup@contoso.com' -ManagedGroupTypes 'All' ``` ```output @@ -54,7 +54,7 @@ Id AlternateNotificationEmails GroupLifetimeIn This command is used to set the properties of a specific Microsoft Group Lifecycle Policy. -- The `-Id` parameter specifies the ID of the Lifecycle Policy to be modified. +- The `-GroupLifecyclePolicyId` parameter specifies the ID of the Lifecycle Policy to be modified. - The `-GroupLifetimeInDays` parameter sets the lifetime of the groups in the policy to 200 days. The GroupLifetimeInDays represents the number of days before a group expires and needs to be renewed. Once renewed, the group expiration is extended by the number of days defined. - The `-AlternateNotificationEmails` parameter sets the email address that receives notifications about the policy. Multiple email address can be defined by separating email address with a semicolon. - The `-ManagedGroupTypes` parameter sets the types of groups that the policy manages. Possible values are `All`, `Selected`, or `None`. @@ -96,7 +96,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. diff --git a/test/module/Entra/Get-EntraApplication.Tests.ps1 b/test/module/Entra/Get-EntraApplication.Tests.ps1 index a8d3cd829..7f26417b9 100644 --- a/test/module/Entra/Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplication.Tests.ps1 @@ -37,17 +37,17 @@ BeforeAll { Describe "Get-EntraApplication" { Context "Test for Get-EntraApplication" { It "Should return specific application" { - $result = Get-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraApplication -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Get-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is invalid" { + { Get-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraApplication -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Get-EntraApplication -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should return all applications" { $result = Get-EntraApplication -All @@ -91,12 +91,12 @@ Describe "Get-EntraApplication" { Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Result should Contain ApplicationId" { + $result = Get-EntraApplication -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = Get-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = Get-EntraApplication -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } diff --git a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 index f4f814958..2ce23c08b 100644 --- a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 @@ -30,17 +30,17 @@ BeforeAll { Describe "Get-EntraDirectoryRole" { Context "Test for Get-EntraDirectoryRole" { It "Should return specific role" { - $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraDirectoryRole -DirectoryRoleId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Get-EntraDirectoryRole -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DirectoryRoleId is invalid" { + { Get-EntraDirectoryRole -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraDirectoryRole -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DirectoryRoleId is empty" { + { Get-EntraDirectoryRole -DirectoryRoleId } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'*" } It "Should return specific role by filter" { $result = Get-EntraDirectoryRole -Filter "DisplayName -eq 'Attribute Assignment Reader'" @@ -53,18 +53,18 @@ Describe "Get-EntraDirectoryRole" { { Get-EntraDirectoryRole -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" } It "Result should Contain ObjectId" { - $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraDirectoryRole -DirectoryRoleId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } - It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { - $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should contain DirectoryRoleId in parameters when passed DirectoryRoleId to it" { + $result = Get-EntraDirectoryRole -DirectoryRoleId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.DirectoryRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRole" - $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraDirectoryRole -DirectoryRoleId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Remove-EntraApplication.Tests.ps1 index e789f08a1..caa5a8227 100644 --- a/test/module/Entra/Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplication.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Remove-EntraApplication" { Context "Test for Remove-EntraApplication" { It "Should return empty object" { - $result = Remove-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Remove-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is invalid" { + { Remove-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Remove-EntraApplication -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Remove-EntraApplication -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Remove-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,7 +37,7 @@ Describe "Remove-EntraApplication" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplication" - $result = Remove-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Remove-EntraDevice.Tests.ps1 index cbb929e70..1cb6f65ed 100644 --- a/test/module/Entra/Remove-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDevice.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Remove-EntraDevice" { Context "Test for Remove-EntraDevice" { It "Should return empty object" { - $result = Remove-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Remove-EntraDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DeviceId is invalid" { + { Remove-EntraDevice -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Remove-EntraDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DeviceId is empty" { + { Remove-EntraDevice -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" } - It "Should contain DeviceId in parameters when passed ObjectId to it" { + It "Should contain DeviceId in parameters when passed DeviceId to it" { Mock -CommandName Remove-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.DeviceId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,7 +37,7 @@ Describe "Remove-EntraDevice" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDevice" - $result = Remove-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Remove-EntraGroup.Tests.ps1 index 49a24d323..4f3b80fdb 100644 --- a/test/module/Entra/Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroup.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Remove-EntraGroup" { Context "Test for Remove-EntraGroup" { It "Should return empty object" { - $result = Remove-EntraGroup -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Remove-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Remove-EntraGroup -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraGroup -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.GroupId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,7 +37,7 @@ Describe "Remove-EntraGroup" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroup" - $result = Remove-EntraGroup -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Remove-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Set-EntraApplication.Tests.ps1 b/test/module/Entra/Set-EntraApplication.Tests.ps1 index cc8dd48a1..485a30f17 100644 --- a/test/module/Entra/Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Set-EntraApplication.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Set-EntraApplication"{ Context "Test for Set-EntraApplication" { It "Should return empty object"{ - $result = Set-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" + $result = Set-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Set-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is invalid" { + { Set-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Set-EntraApplication -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Set-EntraApplication -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Update-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Set-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,7 +37,7 @@ Describe "Set-EntraApplication"{ $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplication" - $result = Set-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Set-EntraGroup.Tests.ps1 b/test/module/Entra/Set-EntraGroup.Tests.ps1 index 060707011..dc8de8387 100644 --- a/test/module/Entra/Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Set-EntraGroup.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Set-EntraGroup" { Context "Test for Set-EntraGroup" { It "Should return empty object" { - $result = Set-EntraGroup -Id bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" + $result = Set-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is invalid" { - { Set-EntraGroup -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Set-EntraGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - It "Should fail when Id is empty" { - { Set-EntraGroup -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupId is empty" { + { Set-EntraGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should contain GroupId in parameters when passed Id to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Update-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Set-EntraGroup -Id bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.GroupId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,7 +37,7 @@ Describe "Set-EntraGroup" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroup" - $result = Set-EntraGroup -Id bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } From ada13674aa0a918ec1d1351d31d4f9f549c3de86 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Mon, 9 Sep 2024 15:54:13 +0530 Subject: [PATCH 07/64] updated beta cmdlets --- .../customizations/Get-EntraBetaUser.ps1 | 22 ++++++- .../customizations/Set-EntraBetaDevice.ps1 | 66 ++----------------- .../Get-EntraBetaUser.md | 12 ++-- .../Remove-EntraBetaUser.md | 10 +-- .../EntraBeta/Get-EntraBetaUser.Tests.ps1 | 16 ++--- 5 files changed, 42 insertions(+), 84 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 index 2646581f4..343719a9b 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 @@ -7,6 +7,22 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params = @{} @@ -44,9 +60,9 @@ $query += "&$SearchString" $customHeaders['ConsistencyLevel'] = 'eventual' } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $UserId = $PSBoundParameters["ObjectId"] + $UserId = $PSBoundParameters["UserId"] if ($UserId -match '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'){ $f = '$' + 'Filter' $Filter = "UserPrincipalName eq '$UserId'" @@ -76,7 +92,7 @@ $response = Invoke-GraphRequest @params -Headers $customHeaders if ($upnPresent -and ($null -eq $response.value -or $response.value.Count -eq 0)){ - Write-Error "Resource '$ObjectId' does not exist or one of its queried reference-property objects are not present. + Write-Error "Resource '$UserId' does not exist or one of its queried reference-property objects are not present. Status: 404 (NotFound) ErrorCode: Request_ResourceNotFound" diff --git a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 index 6b8166863..2247350d4 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 @@ -3,67 +3,9 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = "Update-MgBetaDevice" - Parameters = @( - @{ - SourceName = "ApproximateLastLogonTimeStamp" - TargetName = "ApproximateLastSignInDateTime" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceId" - TargetName = "DeviceId1" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceObjectVersion" - TargetName = "DeviceVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSType" - TargetName = "OperatingSystem" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSVersion" - TargetName = "OperatingSystemVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DevicePhysicalIds" - TargetName = "PhysicalIds" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceTrustType" - TargetName = "TrustType" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "AlternativeSecurityIds" - TargetName = "BodyParameter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) - $Temp = @{ - alternativeSecurityIds = @( - @{ - type = $TmpValue.type - key = [System.Text.Encoding]::ASCII.GetBytes($key) - } - ) - } - $Value = $Temp -'@ - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' +'@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md index cec1f8ded..4d543e0ab 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md @@ -50,7 +50,7 @@ Get-EntraBetaUser ```powershell Get-EntraBetaUser - -ObjectId + -UserId [-All] [-Property ] [] @@ -83,7 +83,7 @@ This example demonstrates how to get top three users from Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUser -UserId 'SawyerM@contoso.com' ``` ```Output @@ -94,7 +94,7 @@ Sawyer Miller bbbbbbbb-1111-2222-3333-cccccccccccc sawyerm@tenant.com sawyerm@te This command gets the specified user. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. ### Example 3: Search among retrieved users @@ -146,7 +146,7 @@ In this example, we retrieve all users whose MailNickname starts with Ada. ```powershell Connect-Entra -Scopes 'User.Read.All','AuditLog.Read.All' -Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' -Property 'SignInActivity' | Select-Object -ExpandProperty 'SignInActivity' +Get-EntraBetaUser -UserId 'SawyerM@contoso.com' -Property 'SignInActivity' | Select-Object -ExpandProperty 'SignInActivity' ``` ```Output @@ -193,9 +193,9 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID (as a User Principal Name (UPN) or ObjectId) of a user in Microsoft Entra ID. +Specifies the ID (as a User Principal Name (UPN) or UserId) of a user in Microsoft Entra ID. ```yaml Type: System.String diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md index b44b19093..cb33fbd07 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md @@ -26,13 +26,13 @@ Removes a user. ```powershell Remove-EntraBetaUser - -ObjectId + -UserId [] ``` ## Description -The `Remove-EntraBetaUser` cmdlet removes a user in Microsoft Entra ID. Specify the `ObjectId` parameter to remove the specified user in Microsoft Entra ID. +The `Remove-EntraBetaUser` cmdlet removes a user in Microsoft Entra ID. Specify the `UserId` parameter to remove the specified user in Microsoft Entra ID. ## Examples @@ -40,16 +40,16 @@ The `Remove-EntraBetaUser` cmdlet removes a user in Microsoft Entra ID. Specify ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -Remove-EntraBetaUser -ObjectId 'TestUser@example.com' +Remove-EntraBetaUser -UserId 'TestUser@example.com' ``` This command removes the specified user in Microsoft Entra ID. ## Parameters -### -ObjectId +### -UserId -Specifies the ID of a user (as a UPN or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a UPN or UserId) in Microsoft Entra ID. ```yaml Type: System.String diff --git a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 index e0c874196..a452088e4 100644 --- a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 @@ -55,7 +55,7 @@ BeforeAll { Describe "Get-EntraBetaUser" { Context "Test for Get-EntraBetaUser" { It "Should return specific user" { - $result = Get-EntraBetaUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" Write-Verbose "Result : {$result}" -Verbose $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') @@ -77,12 +77,12 @@ Describe "Get-EntraBetaUser" { } } - It "Should fail when ObjectId is empty string value" { - { Get-EntraBetaUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Get-EntraBetaUser -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaUser -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraBetaUser -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should return all contact" { @@ -147,8 +147,8 @@ Describe "Get-EntraBetaUser" { { Get-EntraBetaUser -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraBetaUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -163,7 +163,7 @@ Describe "Get-EntraBetaUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraBetaUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 4ba4926bd326de970f575e22d79744dcf5d9a456 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Mon, 9 Sep 2024 18:07:15 +0530 Subject: [PATCH 08/64] updated beta cmdlets --- .../Get-EntraBetaApplication.ps1 | 20 +++++- .../New-EntraBetaAdministrativeUnitMember.ps1 | 34 +++++++++- .../Set-EntraBetaApplication.ps1 | 52 ++++++++++++++- .../customizations/Set-EntraBetaDevice.ps1 | 66 +++++++++++++++++-- .../Get-EntraBetaApplication.md | 8 +-- .../New-EntraBetaAdministrativeUnitMember.md | 10 +-- .../Remove-EntraBetaApplication.md | 8 +-- .../Remove-EntraBetaGroup.md | 10 +-- .../Set-EntraBetaApplication.md | 14 ++-- .../Set-EntraBetaGroup.md | 22 +++---- 10 files changed, 199 insertions(+), 45 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 index ba119c89a..aab76b4f8 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 @@ -7,6 +7,22 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -17,9 +33,9 @@ $Value = "displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')" $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 b/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 index b44ff1415..d7505a38e 100644 --- a/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 +++ b/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 @@ -7,6 +7,38 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)] + [System.Nullable`1[System.Boolean]] $MailEnabled, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $GroupTypes, + [Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)] + [System.String] $DisplayName, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Description, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $MembershipRule, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsAssignableToRole, + [Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)] + [System.Nullable`1[System.Boolean]] $SecurityEnabled, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $ProxyAddresses, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Visibility, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $MembershipRuleProcessingState, + [Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)] + [System.String] $MailNickname, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $OdataType, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AssignedLabel]] $AssignedLabels + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -107,7 +139,7 @@ Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") - $response = New-MGBetaAdministrativeUnitMember -Headers $customHeaders -AdministrativeUnitId $ID -BodyParameter $params + $response = New-MGBetaAdministrativeUnitMember -Headers $customHeaders -AdministrativeUnitId $AdministrativeUnitId -BodyParameter $params $response } '@ diff --git a/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 b/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 index 615497fc7..d702f5b04 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 @@ -7,6 +7,54 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.ApiApplication] $Api, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AddIn]] $AddIns, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.WebApplication] $Web, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DisplayName, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $IdentifierUris, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.ParentalControlSettings] $ParentalControlSettings, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.PreAuthorizedApplication]] $PreAuthorizedApplications, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsDeviceOnlyAuthSupported, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $Tags, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.KeyCredential]] $KeyCredentials, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $TokenEncryptionKeyId, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsFallbackPublicClient, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.OptionalClaims] $OptionalClaims, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $GroupMembershipClaims, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.PublicClientApplication] $PublicClient, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.PasswordCredential]] $PasswordCredentials, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $OrgRestrictions, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $SignInAudience, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.MSGraph.Model.InformationalUrl] $InformationalUrl, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.RequiredResourceAccess]] $RequiredResourceAccess, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AppRole]] $AppRoles + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -121,9 +169,9 @@ { $params["GroupMembershipClaims"] = $PSBoundParameters["GroupMembershipClaims"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["AppRoles"]) { diff --git a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 index 2247350d4..6b8166863 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 @@ -3,9 +3,67 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = $null - Parameters = $null - Outputs = $null - CustomScript = @' + TargetName = "Update-MgBetaDevice" + Parameters = @( + @{ + SourceName = "ApproximateLastLogonTimeStamp" + TargetName = "ApproximateLastSignInDateTime" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceId" + TargetName = "DeviceId1" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceObjectVersion" + TargetName = "DeviceVersion" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceOSType" + TargetName = "OperatingSystem" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceOSVersion" + TargetName = "OperatingSystemVersion" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DevicePhysicalIds" + TargetName = "PhysicalIds" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "DeviceTrustType" + TargetName = "TrustType" + ConversionType = "Name" + SpecialMapping = $null + } + @{ + SourceName = "AlternativeSecurityIds" + TargetName = "BodyParameter" + ConversionType = "ScriptBlock" + SpecialMapping = @' + $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) + $Temp = @{ + alternativeSecurityIds = @( + @{ + type = $TmpValue.type + key = [System.Text.Encoding]::ASCII.GetBytes($key) + } + ) + } + $Value = $Temp '@ + } + ) + Outputs = $null } \ No newline at end of file diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md index a1fa39344..404aa7d6d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md @@ -48,7 +48,7 @@ Get-EntraBetaApplication ```powershell Get-EntraBetaApplication - -ObjectId + -ApplicationId [-All] [-Property ] [] @@ -60,11 +60,11 @@ The `Get-EntraBetaApplication` cmdlet gets a Microsoft Entra ID application. ## Examples -### Example 1: Get an application by ObjectId +### Example 1: Get an application by ApplicationId ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -192,7 +192,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md index c10162851..276ac8cd6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md @@ -28,7 +28,7 @@ Currently only group objects are supported. ```powershell New-EntraBetaAdministrativeUnitMember - -Id + -AdministrativeUnitId [-GroupTypes ] [-AssignedLabels ] [-OdataType ] @@ -47,7 +47,7 @@ New-EntraBetaAdministrativeUnitMember ## Description -The `New-EntraBetaAdministrativeUnitMember` cmdlet creates a Microsoft Entra ID object as a member of an administrative unit. Specify `Id`, `DisplayName`, `MailNickname`, `SecurityEnabled` and `MailEnabled` parameters for create a new administrative unit member. +The `New-EntraBetaAdministrativeUnitMember` cmdlet creates a Microsoft Entra ID object as a member of an administrative unit. Specify `AdministrativeUnitId`, `DisplayName`, `MailNickname`, `SecurityEnabled` and `MailEnabled` parameters for create a new administrative unit member. Currently only Microsoft Entra ID groups are supported to create administrative unit members. @@ -60,7 +60,7 @@ For information about creating dynamic groups, see Using attributes to create ad ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $params = @{ - Id = 'bbbbbbbb-1111-2222-3333-cccccccccccc' + AdministrativeUnitId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' OdataType = 'Microsoft.Graph.Group' DisplayName = 'NewAUMember' Description = 'createdUnitMember' @@ -95,9 +95,9 @@ Any users that don't qualify are removed from the group. ## Parameters -### -Id +### -AdministrativeUnitId -Specifies the ID of a Microsoft Entra ID administrative unit. +Specifies the AdministrativeUnitId of a Microsoft Entra ID administrative unit. ```yaml Type: System.String diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md index 6e12c412a..9076292a9 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md @@ -25,13 +25,13 @@ Deletes an application object. ```powershell Remove-EntraBetaApplication - -ObjectId + -ApplicationId [] ``` ## Description -The `Remove-EntraBetaApplication` cmdlet deletes an application object identified by ObjectId. Specify the `ObjectId` parameter to delete an application object. +The `Remove-EntraBetaApplication` cmdlet deletes an application object identified by ApplicationId. Specify the `ApplicationId` parameter to delete an application object. ## Examples @@ -39,14 +39,14 @@ The `Remove-EntraBetaApplication` cmdlet deletes an application object identifie ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Remove-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This example demonstrates how to delete an application object. ## Parameters -### -ObjectId +### -ApplicationId The unique identifier of the object specific Microsoft Entra ID object. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md index d0034be60..7ac72ca80 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md @@ -26,13 +26,13 @@ Removes a group. ```powershell Remove-EntraBetaGroup - -ObjectId + -GroupId [] ``` ## Description -The `Remove-EntraBetaGroup` cmdlet removes a group from Microsoft Entra ID. Specify the `ObjectId` parameter removes a group. Unified Group can be restored withing 30 days after deletion using the `Restore-EntraBetaDeletedDirectoryObject` cmdlet. Security groups can't be restored after deletion. +The `Remove-EntraBetaGroup` cmdlet removes a group from Microsoft Entra ID. Specify the `GroupId` parameter removes a group. Unified Group can be restored withing 30 days after deletion using the `Restore-EntraBetaDeletedDirectoryObject` cmdlet. Security groups can't be restored after deletion. **Notes on permissions:** @@ -48,16 +48,16 @@ The following conditions apply for apps to delete role-assignable groups: ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -Remove-EntraBetaGroup -ObjectId $group.Id +Remove-EntraBetaGroup -GroupId $group.Id ``` This example demonstrates how to remove a group in Microsoft Entra ID. -- `ObjectId` parameter specifies the group ID . +- `GroupId` parameter specifies the group ID . ## Parameters -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md index 0b74bc706..68dea3f55 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md @@ -26,7 +26,7 @@ Updates the properties of an application object. ```powershell Set-EntraBetaApplication - -ObjectId + -ApplicationId [-Api ] [-OptionalClaims ] [-DisplayName ] @@ -61,7 +61,7 @@ Updates the properties of an application object. ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My new application' +Set-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My new application' ``` This command updates an application in Microsoft Entra ID. @@ -70,7 +70,7 @@ This command updates an application in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -IdentifierUris 'https://mynewapp.contoso.com' +Set-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -IdentifierUris 'https://mynewapp.contoso.com' ``` This command updates an application in Microsoft Entra ID. @@ -79,7 +79,7 @@ This command updates an application in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -GroupMembershipClaims 'SecurityGroup' +Set-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -GroupMembershipClaims 'SecurityGroup' ``` This command updates an application in Microsoft Entra ID. @@ -88,7 +88,7 @@ This command updates an application in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -IsDeviceOnlyAuthSupported $false +Set-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -IsDeviceOnlyAuthSupported $false ``` This command updates an application in Microsoft Entra ID. @@ -97,7 +97,7 @@ This command updates an application in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Tags 'mytag' +Set-EntraBetaApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Tags 'mytag' ``` This command updates an application in Microsoft Entra ID. @@ -277,7 +277,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md index 1bf8935b1..42c910e95 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md @@ -26,7 +26,7 @@ Sets the properties for an existing Microsoft Entra ID group. ```powershell Set-EntraBetaGroup - -Id + -GroupId [-GroupTypes ] [-DisplayName ] [-Description ] @@ -42,7 +42,7 @@ Set-EntraBetaGroup ## Description -The `Set-EntraBetaGroup` cmdlet sets the properties for an existing Microsoft Entra ID group. Specify the `Id` parameter to set the properties for an existing Microsoft Entra ID group. +The `Set-EntraBetaGroup` cmdlet sets the properties for an existing Microsoft Entra ID group. Specify the `GroupId` parameter to set the properties for an existing Microsoft Entra ID group. ## Examples @@ -51,7 +51,7 @@ The `Set-EntraBetaGroup` cmdlet sets the properties for an existing Microsoft En ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' DisplayName = 'UPDATE helpdesk' } @@ -65,7 +65,7 @@ This command updates the display name of a specified group in Microsoft Entra ID ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' Description = 'This is my new group' } @@ -79,7 +79,7 @@ This example demonstrates how to update a group description. ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' MailNickName = 'newnickname' } @@ -93,7 +93,7 @@ This command updates the mail nickname of a specified group in Microsoft Entra I ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' SecurityEnabled = $true } @@ -107,7 +107,7 @@ This command updates the security enabled of a specified group in Microsoft Entr ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' MailEnabled = $false } @@ -121,7 +121,7 @@ This example demonstrates how to update a group main enabled. ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' Visibility = 'Private' GroupTypes = 'DynamicMembership' IsAssignableToRole = $true @@ -137,7 +137,7 @@ This example demonstrates how to update a property for an existing Microsoft Ent ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $params = @{ - Id = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' + GroupId = 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' MembershipRule = '(user.UserType -contains "Member")' } @@ -150,7 +150,7 @@ This example demonstrates how to update the membership rule of a specified group ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Set-EntraBetaGroup -Id 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MembershipRuleProcessingState 'On' +Set-EntraBetaGroup -GroupId 'kkkkkkkk-3333-5555-1111-nnnnnnnnnnnn' -MembershipRuleProcessingState 'On' ``` This example demonstrates how to update the membership rule processing state of a specified group in Microsoft Entra ID. @@ -206,7 +206,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupId Specifies the object ID of a group. From 2ca897cc818157b31eec57aedf3d4a977363adba Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Tue, 10 Sep 2024 17:16:15 +0530 Subject: [PATCH 09/64] updated beta doc and parameters --- .../Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md | 8 ++++---- .../Get-EntraBetaContactManager.md | 8 ++++---- .../Get-EntraBetaContract.md | 6 +++--- .../Get-EntraBetaGroupLifecyclePolicy.md | 10 +++++----- .../Get-EntraBetaGroupPermissionGrant.md | 6 +++--- .../Remove-EntraBetaDevice.md | 6 +++--- .../Remove-EntraBetaGroupLifecyclePolicy.md | 8 ++++---- .../Remove-EntraBetaIdentityProvider.md | 8 ++++---- .../Set-EntraBetaGroupLifecyclePolicy.md | 8 ++++---- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md index c71fe9f3e..85a2330f2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md @@ -38,7 +38,7 @@ Get-EntraBetaContact ```powershell Get-EntraBetaContact - -ObjectId + -OrgContactId [-All] [-Property ] [] @@ -72,7 +72,7 @@ This example retrieves all contact objects in the directory. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' -Get-EntraBetaContact -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaContact -OrgContactId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -83,7 +83,7 @@ Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com This example retrieves specified contact in the directory. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 3: Retrieve all contacts objects in the directory @@ -172,7 +172,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md index f84876e03..2bd7df2af 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md @@ -25,7 +25,7 @@ Gets the manager of a contact. ```powershell Get-EntraBetaContactManager - -ObjectId + -OrgContactId [-Property ] [] ``` @@ -41,16 +41,16 @@ The `Get-EntraBetaContactManager` cmdlet gets the manager of a contact in Micros ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraBetaContactManager -ObjectId $Contact.ObjectId +Get-EntraBetaContactManager -OrgContactId $Contact.ObjectId ``` The example demonstrates how to retrieve the manager of a contact. You can use the command `Get-EntraBetaContact` to get organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ## Parameters -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md index b54880cc1..8723eae85 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md @@ -40,7 +40,7 @@ Get-EntraBetaContract ```powershell Get-EntraBetaContract - -ObjectId + -ContractId [-All] [-Property ] [] @@ -78,7 +78,7 @@ It isn't automatically updated if the customer tenant's display name changes. - `objectType` - a string that identifies the object type. The value is always `Contract`. -- `ObjectId` - the unique identifier for the partnership. +- `ContractId` - the unique identifier for the partnership. ## Examples @@ -135,7 +135,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ContractId Specifies the ID of a contract. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md index 83313f32b..734f75c48 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md @@ -37,14 +37,14 @@ Get-EntraBetaGroupLifecyclePolicy ```powershell Get-EntraBetaGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [-Property ] [] ``` ## Description -The `Get-EntraBetaGroupLifecyclePolicy` command retrieves the properties and relationships of a groupLifecyclePolicies object in Microsoft Entra ID. Specify the `-Id` parameter to get the group lifecycle policy. +The `Get-EntraBetaGroupLifecyclePolicy` command retrieves the properties and relationships of a groupLifecyclePolicies object in Microsoft Entra ID. Specify the `-GroupLifecyclePolicyId` parameter to get the group lifecycle policy. If you specify no parameters, this cmdlet gets all groupLifecyclePolicies. ## Examples @@ -68,7 +68,7 @@ This example demonstrates how to retrieve the properties and relationships of al ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaGroupLifecyclePolicy -Id 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' +Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' ``` ```Output @@ -79,11 +79,11 @@ ffffffff-5555-6666-7777-aaaaaaaaaaaa example@contoso.com 200 This command is used to retrieve a specific Microsoft Group Lifecycle Policy. -- `-Id` parameter specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. +- `-GroupLifecyclePolicyId` parameter specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. ## Parameters -### -Id +### -GroupLifecyclePolicyId Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md index 22c5e1a78..1d45f2c98 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md @@ -26,7 +26,7 @@ Retrieves a list of permission grants that have been consented for this group. ```powershell Get-EntraBetaGroupPermissionGrant - -Id + -GroupId [-Property ] [] ``` @@ -41,7 +41,7 @@ Retrieves a list of permission grants that have been consented for this group. ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupPermissionGrant -Id 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' +Get-EntraBetaGroupPermissionGrant -GroupId 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' ``` ```Output @@ -57,7 +57,7 @@ This cmdlet list existing permission grants for the specified group. ## Parameters -### -Id +### -GroupId The unique identifier of group. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md index 5af2e5a82..a1492dcaa 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md @@ -27,7 +27,7 @@ Deletes a device. ```powershell Remove-EntraBetaDevice - -ObjectId + -DeviceId [] ``` @@ -43,14 +43,14 @@ The calling user must be in one of the following Microsoft Entra roles: Intune A ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Remove-EntraBetaDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraBetaDevice -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This command removes the specified device. ## Parameters -### -ObjectId +### -DeviceId Specifies the object ID of a device in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md index 85d78d313..a855f1047 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md @@ -26,13 +26,13 @@ Deletes a groupLifecyclePolicies object ```powershell Remove-EntraBetaGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [] ``` ## Description -The `Remove-EntraBetaGroupLifecyclePolicy` command deletes a groupLifecyclePolicies object in Microsoft Entra ID. Specify `Id` parameter deletes the groupLifecyclePolicies object. +The `Remove-EntraBetaGroupLifecyclePolicy` command deletes a groupLifecyclePolicies object in Microsoft Entra ID. Specify `GroupLifecyclePolicyId` parameter deletes the groupLifecyclePolicies object. ## Examples @@ -40,14 +40,14 @@ The `Remove-EntraBetaGroupLifecyclePolicy` command deletes a groupLifecyclePolic ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-EntraBetaGroupLifecyclePolicy -Id '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' +Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId '1aaaaaa1-2bb2-3cc3-4dd4-5eeeeeeeeee5' ``` This example demonstrates how to delete the groupLifecyclePolicies object that has the specified ID. ## Parameters -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the groupLifecyclePolicies object that this cmdlet removes. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md index eb24ce44a..5d06748f8 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md @@ -27,7 +27,7 @@ This cmdlet is used to delete an identity provider in the directory. ```powershell Remove-EntraBetaIdentityProvider - -Id + -IdentityProviderBaseId [] ``` @@ -45,16 +45,16 @@ The work or school account needs to belong to at least the External Identity Pro ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' -Remove-EntraBetaIdentityProvider -Id 'LinkedIn-OAUTH' +Remove-EntraBetaIdentityProvider -IdentityProviderBaseId 'LinkedIn-OAUTH' ``` This command demonstrates how to remove the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. ## Parameters -### -Id +### -IdentityProviderBaseId The unique identifier for an identity provider. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md index d0014d65f..2e3421f30 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md @@ -26,7 +26,7 @@ Updates a specific group Lifecycle Policy in Microsoft Entra ID. ```powershell Set-EntraBetaGroupLifecyclePolicy - -Id + -GroupLifecyclePolicyId [-AlternateNotificationEmails ] [-ManagedGroupTypes ] [-GroupLifetimeInDays ] @@ -44,7 +44,7 @@ The `Set-EntraBetaGroupLifecyclePolicy` command updates a specific group Lifecyc ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - Id = 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' + GroupLifecyclePolicyId = 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' GroupLifetimeInDays = 200 AlternateNotificationEmails = 'example@contoso.com' ManagedGroupTypes = 'All' @@ -60,7 +60,7 @@ ffffffff-5555-6666-7777-aaaaaaaaaaaa example@contoso.com 200 This example updates the specified groupLifecyclePolicy in Microsoft Entra ID. -- `-Id` parameter specifies the ID of the Lifecycle Policy to be modified. +- `-GroupLifecyclePolicyId` parameter specifies the ID of the Lifecycle Policy to be modified. - `-GroupLifetimeInDays` parameter specifies the lifetime of the groups in the policy to 200 days. The GroupLifetimeInDays represents the number of days before a group expires and needs to be renewed. Once renewed, the group expiration is extended by the number of days defined. - `-AlternateNotificationEmails` parameter specifies the email address that receives notifications about the policy. Multiple email address can be defined by separating email address with a semicolon. - `-ManagedGroupTypes` parameter specifies which office 365 groups the policy applies to. Possible values are `All`, `Selected`, or `None`. @@ -101,7 +101,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. From ee3e96150d19312ddf461a6c008aab7646d63a09 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 11 Sep 2024 14:46:09 +0530 Subject: [PATCH 10/64] updated beta cmdlets --- .../Get-EntraBetaApplicationProxyApplication.ps1 | 12 ++++++++++-- ...move-EntraBetaApplicationProxyApplication.ps1 | 13 ++++++++++--- .../Get-EntraBetaApplicationExtensionProperty.md | 8 ++++---- .../Get-EntraBetaApplicationProxyApplication.md | 16 ++++++++-------- .../Get-EntraBetaDirectoryRole.md | 10 +++++----- ...move-EntraBetaApplicationExtensionProperty.md | 8 ++++---- ...emove-EntraBetaApplicationProxyApplication.md | 16 ++++++++-------- .../Remove-EntraBetaServicePrincipal.md | 8 ++++---- 8 files changed, 53 insertions(+), 38 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 index 3178938c6..9741bf7e9 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 @@ -7,14 +7,22 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand if ($PSBoundParameters.ContainsKey("Debug")) { $params["Debug"] = $PSBoundParameters["Debug"] } - if ($null -ne $PSBoundParameters["ObjectId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + if ($null -ne $PSBoundParameters["ApplicationId"]) { + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $params["Select"] = "onPremisesPublishing" } if ($PSBoundParameters.ContainsKey("Verbose")) { diff --git a/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 b/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 index 48e3ad727..f32e1aa93 100644 --- a/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 +++ b/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 @@ -7,14 +7,21 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Boolean]] $RemoveADApplication + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $ObjectId = $PSBoundParameters["ObjectId"] + $ObjectId = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["RemoveADApplication"] -and $true -eq $PSBoundParameters["RemoveADApplication"] ) { diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md index c57bcbfa4..d31e99685 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md @@ -26,7 +26,7 @@ Gets application extension properties. ```powershell Get-EntraBetaApplicationExtensionProperty - -ObjectId + -ApplicationId [-Property ] [] ``` @@ -42,7 +42,7 @@ The `Get-EntraBetaApplicationExtensionProperty` cmdlet gets application extensio ```powershell Connect-Entra -Scopes 'Application.Read.All' $Application = Get-EntraBetaApplication -SearchString '' -Get-EntraBetaApplicationExtensionProperty -ObjectId $Application.ObjectId +Get-EntraBetaApplicationExtensionProperty -ApplicationId $Application.ObjectId ``` ```Output @@ -53,11 +53,11 @@ DeletedDateTime Id AppDisplayName DataType IsM This command gets the extension properties for the specified application in Microsoft Entra ID. You cane use the command `Get-EntraBetaApplication` to get application Id. -- `-ObjectId` parameter specifies the the unique identifier of a application. +- `-ApplicationId` parameter specifies the the unique identifier of a application. ## Parameters -### -ObjectId +### -ApplicationId Specifies the unique ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md index 6bc3c58de..8f5d95d51 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md @@ -25,14 +25,14 @@ The `Get-EntraBetaApplicationProxyApplication` cmdlet retrieves an application c ```powershell Get-EntraBetaApplicationProxyApplication - -ObjectId + -ApplicationId [-Property ] [] ``` ## Description -The `Get-EntraBetaApplicationProxyApplication` cmdlet retrieves an application configured for Application Proxy in Microsoft Entra ID. Specify `ObjectId` parameter to retrieve application configured for application proxy. +The `Get-EntraBetaApplicationProxyApplication` cmdlet retrieves an application configured for Application Proxy in Microsoft Entra ID. Specify `ApplicationId` parameter to retrieve application configured for application proxy. ## Examples @@ -40,7 +40,7 @@ The `Get-EntraBetaApplicationProxyApplication` cmdlet retrieves an application c ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Get-EntraBetaApplicationProxyApplication -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraBetaApplicationProxyApplication -ApplicationId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -52,15 +52,15 @@ https://testp-m365x99297270.msapppr... This example retrieves an application configured for Application Proxy. -- `ObjectId` parameter specifies the application ID. +- `ApplicationId` parameter specifies the application ID. ## Parameters -### -ObjectId +### -ApplicationId -This ObjectId is the unique application ID of the application. -This ObjectId can be found using the `Get-EntraBetaApplication` command. -You can also find ObjectId in the Microsoft Portal by navigating to Microsoft Entra ID, Enterprise Applications, All Applications, Select your application, go to the properties tab, and use the ObjectId on that page. +This ApplicationId is the unique application ID of the application. +This ApplicationId can be found using the `Get-EntraBetaApplication` command. +You can also find ApplicationId in the Microsoft Portal by navigating to Microsoft Entra ID, Enterprise Applications, All Applications, Select your application, go to the properties tab, and use the ObjectId on that page. ```yaml Type: System.String diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md index 712c4ffe6..d1573a81a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md @@ -38,14 +38,14 @@ Get-EntraBetaDirectoryRole ```powershell Get-EntraBetaDirectoryRole - -ObjectId + -DirectoryRoleId [-Property ] [] ``` ## Description -The `Get-EntraBetaDirectoryRole` cmdlet gets a directory role from Microsoft Entra ID. Specify `ObjectId` parameter to get a directory role. +The `Get-EntraBetaDirectoryRole` cmdlet gets a directory role from Microsoft Entra ID. Specify `DirectoryRoleId` parameter to get a directory role. ## Examples @@ -53,7 +53,7 @@ The `Get-EntraBetaDirectoryRole` cmdlet gets a directory role from Microsoft Ent ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory' -Get-EntraBetaDirectoryRole -ObjectId '56644e28-bf8b-4dad-8595-24448ffa3cb8' +Get-EntraBetaDirectoryRole -DirectoryRoleId '56644e28-bf8b-4dad-8595-24448ffa3cb8' ``` ```Output @@ -64,7 +64,7 @@ DeletedDateTime Id Description This command gets the specified directory role. -- `-ObjectId` parameter specifies the ID of a directory role in Microsoft Entra ID. +- `-DirectoryRoleId` parameter specifies the ID of a directory role in Microsoft Entra ID. ### Example 2: Get all directory roles @@ -135,7 +135,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md index a3cf77d8a..82a225901 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md @@ -27,7 +27,7 @@ Removes an application extension property. ```powershell Remove-EntraBetaApplicationExtensionProperty - -ObjectId + -ApplicationId -ExtensionPropertyId [] ``` @@ -44,7 +44,7 @@ The `Remove-EntraBetaApplicationExtensionProperty` cmdlet removes an application Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId ExtensionPropertyId = 'cccc2222-dd33-4444-55ee-666666ffffff' } @@ -53,7 +53,7 @@ Remove-EntraBetaApplicationExtensionProperty @params This example removes the extension property that has the specified ID from an application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-ExtensionPropertyId` parameter specifies the unique identifier of the extension property to remove. ## Parameters @@ -74,7 +74,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the unique ID of an application in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md index 06eeb6c83..92ec99d55 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md @@ -26,7 +26,7 @@ Deletes an Application Proxy application. ```powershell Remove-EntraBetaApplicationProxyApplication - -ObjectId + -ApplicationId [-RemoveADApplication ] [] ``` @@ -41,32 +41,32 @@ The `Remove-EntraBetaApplicationProxyApplication` cmdlet removes Application Pro ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-EntraBetaApplicationProxyApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraBetaApplicationProxyApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This example removes a Proxy Application. -- `ObjectId` parameter specifies the application ID. +- `ApplicationId` parameter specifies the application ID. ### Example 2: Remove a Proxy Application, and remove it from Microsoft Entra ID completely ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-EntraBetaApplicationProxyApplication -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RemoveADApplication $true +Remove-EntraBetaApplicationProxyApplication -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RemoveADApplication $true ``` This example removes a Proxy Application, and removes it from Microsoft Entra ID completely. -- `ObjectId` parameter specifies the application ID. +- `ApplicationId` parameter specifies the application ID. - `RemoveADApplication` parameter specifies the user confirmation to delete application completely. ## Parameters -### -ObjectId +### -ApplicationId The unique application ID of the application. -This ObjectId can be found using the `Get-EntraBetaApplication` command. -You can also find this ObjectId in the Microsoft by navigating to Microsoft Entra ID > App registrations > All applications. Select your application. This will takes you to the application's overview page. Use the ObjectId on that page. +This ApplicationId can be found using the `Get-EntraBetaApplication` command. +You can also find this ApplicationId in the Microsoft by navigating to Microsoft Entra ID > App registrations > All applications. Select your application. This will takes you to the application's overview page. Use the ObjectId on that page. ```yaml Type: System.String diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md index 79edbd093..98e16534d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md @@ -27,7 +27,7 @@ Removes a service principal. ```powershell Remove-EntraBetaServicePrincipal - -ObjectId + -ServicePrincipalId [] ``` @@ -41,16 +41,16 @@ The `Remove-EntraBetaServicePrincipal` cmdlet removes a service principal in Mic ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' -Remove-EntraBetaServicePrincipal -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' +Remove-EntraBetaServicePrincipal -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' ``` This example demonstrates how to remove a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. From eb738b3eea80f25274591a4435bcdfc77b9f9d0f Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 13 Sep 2024 13:52:56 +0530 Subject: [PATCH 11/64] cmd to skip parameter name change --- src/CompatibilityAdapterBuilder.ps1 | 131 +++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 3 deletions(-) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index dd2fcec65..0fd2e2b5c 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -24,6 +24,131 @@ class CompatibilityAdapterBuilder { hidden [hashtable] $HelperCmdletsToExport = @{} hidden [string] $BasePath = $null hidden [string] $LoadMessage + hidden [string[]] $cmdtoSkipNameconverssion = @( + 'Revoke-EntraUserAllRefreshToken', + 'Select-EntraGroupIdsGroupIsMemberOf', + 'Get-EntraUserAppRoleAssignment', + 'Get-EntraPermissionGrantConditionSet', + 'Remove-EntraUserAppRoleAssignment', + 'Set-EntraUserLicense', + 'Restore-EntraDeletedApplication', + 'Set-EntraUserPassword', + 'Remove-EntraAdministrativeUnit', + 'Remove-EntraAdministrativeUnitMember', + 'Select-EntraGroupIdsServicePrincipalIsMemberOf', + 'Get-EntraServicePrincipalDelegatedPermissionClassification', + 'Set-EntraServicePrincipal', + 'New-EntraConditionalAccessPolicy', + 'Set-EntraUserThumbnailPhoto', + 'Reset-EntraLifeCycleGroup', + 'Get-EntraObjectByObjectId', + 'Get-EntraGroupPermissionGrant', + 'Remove-EntraPermissionGrantConditionSet', + 'Get-EntraPermissionGrantPolicy', + 'Remove-EntraOAuth2PermissionGrant', + 'New-EntraUserAppRoleAssignment', + 'Set-EntraPermissionGrantPolicy', + 'Remove-EntraScopedRoleMembership', + 'New-EntraPermissionGrantPolicy', + 'Remove-EntraApplicationPassword', + 'New-EntraNamedLocationPolicy', + 'New-EntraServiceAppRoleAssignment', + 'Select-EntraGroupIdsContactIsMemberOf', + 'Remove-EntraServicePrincipalDelegatedPermissionClassification', + 'Get-EntraServiceAppRoleAssignment', + 'Set-EntraConditionalAccessPolicy', + 'Remove-EntraPermissionGrantPolicy', + 'Set-EntraNamedLocationPolicy', + 'Set-EntraPermissionGrantConditionSet', + 'Remove-EntraDeletedApplication', + 'Select-EntraGroupIdsUserIsMemberOf', + 'Get-EntraUserOAuth2PermissionGrant', + 'Add-EntraBetaServicePrincipalPolicy', + 'Get-EntraBetaPrivilegedRoleDefinition', + 'Get-EntraBetaFeatureRolloutPolicy', + 'Set-EntraBetaPermissionGrantPolicy', + 'Remove-EntraBetaApplicationPassword', + 'Get-EntraBetaServicePrincipalPolicy', + 'Get-EntraBetaPrivilegedRoleAssignmentRequest', + 'New-EntraBetaApplicationPassword', + 'Set-EntraBetaPasswordSingleSignOnCredential', + 'Get-EntraBetaObjectSetting', + 'Add-EntraBetaApplicationPolicy', + 'Add-EntraBetaFeatureRolloutPolicyDirectoryObject', + 'Revoke-EntraBetaUserAllRefreshToken', + 'Get-EntraBetaPrivilegedRole', + 'Get-EntraBetaApplicationTemplate', + 'Select-EntraBetaGroupIdsContactIsMemberOf', + 'Set-EntraBetaCustomSecurityAttributeDefinitionAllowedValue', + 'Set-EntraBetaUserLicense', + 'Set-EntraBetaTrustFrameworkPolicy', + 'Remove-EntraBetaUserAppRoleAssignment', + 'Get-EntraBetaApplicationPolicy', + 'Get-EntraBetaPermissionGrantPolicy', + 'Select-EntraBetaGroupIdsGroupIsMemberOf', + 'New-EntraBetaUserAppRoleAssignment', + 'Remove-EntraBetaUser', + 'Get-EntraBetaTrustFrameworkPolicy', + 'Remove-EntraBetaObjectSetting', + 'Add-EntraBetacustomSecurityAttributeDefinitionAllowedValues', + 'Get-EntraBetaUserOAuth2PermissionGrant', + 'New-EntraBetaApplicationKey', + 'Get-EntraBetaPolicy', + 'Get-EntraBetaDirectorySetting', + 'New-EntraBetaServiceAppRoleAssignment', + 'Get-EntraBetaObjectByObjectId', + 'Remove-EntraBetaPasswordSingleSignOnCredential', + 'Set-EntraBetaPermissionGrantConditionSet', + 'Set-EntraBetaConditionalAccessPolicy', + 'Get-EntraBetaPolicyAppliedObject', + 'Remove-EntraBetaDeletedApplication', + 'Get-EntraBetaCustomSecurityAttributeDefinitionAllowedValue', + 'Get-EntraBetaUserAppRoleAssignment', + 'Get-EntraBetaDirectorySettingTemplate', + 'Remove-EntraBetaServicePrincipalPolicy', + 'Get-EntraBetaPermissionGrantConditionSet', + 'Set-EntraBetaObjectSetting', + 'Remove-EntraBetaFeatureRolloutPolicyDirectoryObject', + 'Get-EntraBetaAuthorizationPolicy', + 'Remove-EntraBetaPermissionGrantPolicy', + 'Set-EntraBetaDirectorySetting', + 'Set-EntraBetaAuthorizationPolicy', + 'Remove-EntraBetaDirectorySetting', + 'Remove-EntraBetaApplicationPolicy', + 'New-EntraBetaConditionalAccessPolicy', + 'Set-EntraBetaPrivilegedRoleAssignmentRequest', + 'Remove-EntraBetaTrustFrameworkPolicy', + 'New-EntraBetaPasswordSingleSignOnCredential', + 'Remove-EntraBetaPolicy', + 'Set-EntraBetaPolicy', + 'Set-EntraBetaCustomSecurityAttributeDefinition', + 'Get-EntraBetaPrivilegedResource', + 'Set-EntraBetaUserPassword', + 'New-EntraBetaApplicationFromApplicationTemplate', + 'Set-EntraBetaPrivilegedRoleSetting', + 'Remove-EntraBetaApplicationKey', + 'Get-EntraBetaPrivilegedRoleSetting', + 'Remove-EntraBetaOAuth2PermissionGrant', + 'Select-EntraBetaGroupIdsServicePrincipalIsMemberOf', + 'Get-EntraBetaServicePrincipalDelegatedPermissionClassification', + 'New-EntraBetaPrivilegedRoleAssignment', + 'Get-EntraBetaPasswordSingleSignOnCredential', + 'Set-EntraBetaFeatureRolloutPolicy', + 'New-EntraBetaPermissionGrantPolicy', + 'Remove-EntraBetaFeatureRolloutPolicy', + 'Get-EntraBetaCustomSecurityAttributeDefinition', + 'Remove-EntraBetaServicePrincipalDelegatedPermissionClassification', + 'Select-EntraBetaGroupIdsUserIsMemberOf', + 'Set-EntraBetaNamedLocationPolicy', + 'Get-EntraBetaGroupMember', + 'New-EntraBetaNamedLocationPolicy', + 'Remove-EntraBetaApplication', + 'Restore-EntraBetaDeletedApplication', + 'Add-EntraBetaGroupMember', + 'Remove-EntraBetaGroupMember', + 'Remove-EntraBetaPermissionGrantConditionSet' + + ) # Constructor that changes the output folder, load all the Required Modules and creates the output folder. CompatibilityAdapterBuilder() { @@ -575,7 +700,7 @@ Set-Variable -name MISSING_CMDS -value @('$($this.ModuleMap.MissingCommandsList $parameterDefinitions = $this.GetParametersDefinitions($Command) $ParamterTransformations = $this.GetParametersTransformations($Command) $OutputTransformations = $this.GetOutputTransformations($Command) - if ($parameterDefinitions.Contains('$ObjectId') -or $parameterDefinitions.Contains('$Id')) { + if (($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and $parameterDefinitions.Contains('$ObjectId') -or $parameterDefinitions.Contains('$Id')) { $function = @" function $($Command.Generate) { $($Command.CustomScript) @@ -667,7 +792,7 @@ $OutputTransformations return [CommandTranslation]::New($Command.Generate,$Command.Old,$codeBlock) } - hidden [string] GetParametersDefinitions([PSCustomObject] $Command) { + hidden [string] GetParametersDefinitions([PSCustomObject] $Command) { $commonParameterNames = @("ProgressAction","Verbose", "Debug","ErrorAction", "ErrorVariable", "WarningAction", "WarningVariable", "OutBuffer", "PipelineVariable", "OutVariable", "InformationAction", "InformationVariable","WhatIf","Confirm") $ignorePropertyParameter = @("Get-EntraBetaApplicationPolicy", "Get-EntraBetaApplicationSignInSummary","Get-EntraBetaPrivilegedRoleAssignment","Get-EntraBetaTrustFrameworkPolicy","Get-EntraBetaPolicy","Get-EntraBetaPolicyAppliedObject","Get-EntraBetaServicePrincipalPolicy","Get-EntraApplicationLogo","Get-EntraBetaApplicationLogo","Get-EntraApplicationKeyCredential","Get-EntraBetaApplicationKeyCredential","Get-EntraBetaServicePrincipalKeyCredential","Get-EntraBetaServicePrincipalPasswordCredential","Get-EntraServicePrincipalKeyCredential","Get-EntraServicePrincipalPasswordCredential") $params = $(Get-Command -Name $Command.Old).Parameters @@ -683,7 +808,7 @@ $OutputTransformations if($param.Name -eq 'All'){ $paramType = "switch" } - if(($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $targetParam.TargetName){ + if(($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and (($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $targetParam.TargetName)){ if ($targetParam.TargetName) { $param.Name = $targetParam.TargetName } From 54f2a62eb48f932a2e1520de877ebfc2a25f52a5 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 18 Sep 2024 16:26:18 +0530 Subject: [PATCH 12/64] removed wrong cmd from skip list --- src/CompatibilityAdapterBuilder.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 0fd2e2b5c..c745d4dc5 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -139,13 +139,10 @@ class CompatibilityAdapterBuilder { 'Get-EntraBetaCustomSecurityAttributeDefinition', 'Remove-EntraBetaServicePrincipalDelegatedPermissionClassification', 'Select-EntraBetaGroupIdsUserIsMemberOf', - 'Set-EntraBetaNamedLocationPolicy', - 'Get-EntraBetaGroupMember', + 'Set-EntraBetaNamedLocationPolicy', 'New-EntraBetaNamedLocationPolicy', 'Remove-EntraBetaApplication', - 'Restore-EntraBetaDeletedApplication', - 'Add-EntraBetaGroupMember', - 'Remove-EntraBetaGroupMember', + 'Restore-EntraBetaDeletedApplication', 'Remove-EntraBetaPermissionGrantConditionSet' ) From bab7f2753911443b5e4c78fb3525b33c28a539b7 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 19 Sep 2024 14:28:24 +0530 Subject: [PATCH 13/64] added Alias --- src/CompatibilityAdapterBuilder.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index c745d4dc5..2d84f6120 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -86,8 +86,7 @@ class CompatibilityAdapterBuilder { 'Get-EntraBetaApplicationPolicy', 'Get-EntraBetaPermissionGrantPolicy', 'Select-EntraBetaGroupIdsGroupIsMemberOf', - 'New-EntraBetaUserAppRoleAssignment', - 'Remove-EntraBetaUser', + 'New-EntraBetaUserAppRoleAssignment', 'Get-EntraBetaTrustFrameworkPolicy', 'Remove-EntraBetaObjectSetting', 'Add-EntraBetacustomSecurityAttributeDefinitionAllowedValues', @@ -794,6 +793,7 @@ $OutputTransformations $ignorePropertyParameter = @("Get-EntraBetaApplicationPolicy", "Get-EntraBetaApplicationSignInSummary","Get-EntraBetaPrivilegedRoleAssignment","Get-EntraBetaTrustFrameworkPolicy","Get-EntraBetaPolicy","Get-EntraBetaPolicyAppliedObject","Get-EntraBetaServicePrincipalPolicy","Get-EntraApplicationLogo","Get-EntraBetaApplicationLogo","Get-EntraApplicationKeyCredential","Get-EntraBetaApplicationKeyCredential","Get-EntraBetaServicePrincipalKeyCredential","Get-EntraBetaServicePrincipalPasswordCredential","Get-EntraServicePrincipalKeyCredential","Get-EntraServicePrincipalPasswordCredential") $params = $(Get-Command -Name $Command.Old).Parameters $paramsList = @() + $ParamAlias=$null foreach ($paramKey in $Command.Parameters.Keys) { if($commonParameterNames.Contains($paramKey)) { continue @@ -805,8 +805,10 @@ $OutputTransformations if($param.Name -eq 'All'){ $paramType = "switch" } - if(($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and (($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $targetParam.TargetName)){ + + if( ($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and (($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $targetParam.TargetName)){ if ($targetParam.TargetName) { + $ParamAlias = $this.GetParameterAlias($param.Name) $param.Name = $targetParam.TargetName } } @@ -824,9 +826,11 @@ $OutputTransformations } } $paramBlock = @" + $ParamAlias $($this.GetParameterAttributes($Param))[$($paramType)] `$$($param.Name) "@ $paramsList += $paramBlock + $ParamAlias=$null } $addProperty = $true @@ -864,6 +868,10 @@ $OutputTransformations return $propertyParamBlock } + hidden [string] GetParameterAlias($param){ + return "[Alias('$param')]" + } + hidden [string] GetParameterAttributes($param){ $attributesString = "" From bdee4a66325790a9273c4fbda13a82af803b20cc Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 19 Sep 2024 17:01:52 +0530 Subject: [PATCH 14/64] test case for alice --- module/Entra/customizations/Get-EntraUser.ps1 | 1 + test/module/Entra/Get-EntraUser.Tests.ps1 | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/module/Entra/customizations/Get-EntraUser.ps1 b/module/Entra/customizations/Get-EntraUser.ps1 index 8aff55a82..d12e75ecf 100644 --- a/module/Entra/customizations/Get-EntraUser.ps1 +++ b/module/Entra/customizations/Get-EntraUser.ps1 @@ -11,6 +11,7 @@ param ( [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Nullable`1[System.Int32]] $Top, + [Alias("ObjectId")] [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $UserId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/test/module/Entra/Get-EntraUser.Tests.ps1 b/test/module/Entra/Get-EntraUser.Tests.ps1 index 9f6761da5..06d9a23ed 100644 --- a/test/module/Entra/Get-EntraUser.Tests.ps1 +++ b/test/module/Entra/Get-EntraUser.Tests.ps1 @@ -69,6 +69,15 @@ Describe "Get-EntraUser" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Get-EntraUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Write-Verbose "Result : {$result}" -Verbose + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUser" From db6f3d42540f260fda385d6c392d464c7705a23c Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 20 Sep 2024 13:17:27 +0530 Subject: [PATCH 15/64] Usability-Parameters --- .../customizations/Get-EntraApplication.ps1 | 1 + .../customizations/Set-EntraApplication.ps1 | 1 + .../Entra/customizations/Set-EntraDevice.ps1 | 242 +++++++++++++----- .../customizations/Set-EntraBetaDevice.ps1 | 242 +++++++++++++----- .../Set-EntraBetaDevice.md | 16 +- .../Get-EntraApplication.md | 2 +- .../Microsoft.Graph.Entra/Get-EntraUser.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraUser.md | 2 +- .../Set-EntraApplication.md | 2 +- .../Microsoft.Graph.Entra/Set-EntraDevice.md | 16 +- .../Entra/Get-EntraApplication.Tests.ps1 | 8 + .../Entra/Set-EntraApplication.Tests.ps1 | 6 + test/module/Entra/Set-EntraDevice.Tests.ps1 | 22 +- 13 files changed, 412 insertions(+), 150 deletions(-) diff --git a/module/Entra/customizations/Get-EntraApplication.ps1 b/module/Entra/customizations/Get-EntraApplication.ps1 index 6a1c4e9c7..c41b934cd 100644 --- a/module/Entra/customizations/Get-EntraApplication.ps1 +++ b/module/Entra/customizations/Get-EntraApplication.ps1 @@ -11,6 +11,7 @@ param ( [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/module/Entra/customizations/Set-EntraApplication.ps1 b/module/Entra/customizations/Set-EntraApplication.ps1 index 771b059e7..a6f5db81e 100644 --- a/module/Entra/customizations/Set-EntraApplication.ps1 +++ b/module/Entra/customizations/Set-EntraApplication.ps1 @@ -21,6 +21,7 @@ [System.String] $DisplayName, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.AppRole]] $AppRoles, + [Alias('ObjectId')] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] diff --git a/module/Entra/customizations/Set-EntraDevice.ps1 b/module/Entra/customizations/Set-EntraDevice.ps1 index ba06573b3..d6b90eb58 100644 --- a/module/Entra/customizations/Set-EntraDevice.ps1 +++ b/module/Entra/customizations/Set-EntraDevice.ps1 @@ -3,67 +3,187 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = "Update-MgDevice" - Parameters = @( - @{ - SourceName = "ApproximateLastLogonTimeStamp" - TargetName = "ApproximateLastSignInDateTime" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceId" - TargetName = "DeviceId1" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceObjectVersion" - TargetName = "DeviceVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSType" - TargetName = "OperatingSystem" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSVersion" - TargetName = "OperatingSystemVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DevicePhysicalIds" - TargetName = "PhysicalIds" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceTrustType" - TargetName = "TrustType" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "AlternativeSecurityIds" - TargetName = "BodyParameter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) - $Temp = @{ - alternativeSecurityIds = @( - @{ - type = $TmpValue.type - key = [System.Text.Encoding]::ASCII.GetBytes($key) - } - ) + TargetName = $null + Parameters = $null + Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Int32]] $DeviceObjectVersion, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceOSVersion, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.AlternativeSecurityId]] $AlternativeSecurityIds, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.DateTime]] $ApproximateLastLogonTimeStamp, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $DevicePhysicalIds, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsCompliant, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceTrustType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsManaged, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ProfileType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceOSType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DisplayName, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $AccountEnabled, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceMetadata, + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceObjectId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $SystemLabels + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + + if($null -ne $PSBoundParameters["DeviceObjectVersion"]) + { + $params["DeviceVersion"] = $PSBoundParameters["DeviceObjectVersion"] + } + if($null -ne $PSBoundParameters["DeviceOSVersion"]) + { + $params["OperatingSystemVersion"] = $PSBoundParameters["DeviceOSVersion"] + } + if($null -ne $PSBoundParameters["AlternativeSecurityIds"]) + { + $TmpValue = $PSBoundParameters["AlternativeSecurityIds"] + $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) + $Temp = @{ + alternativeSecurityIds = @( + @{ + type = $TmpValue.type + key = [System.Text.Encoding]::ASCII.GetBytes($key) + } + ) + } + $Value = $Temp + $params["BodyParameter"] = $Value + } + if($null -ne $PSBoundParameters["OutBuffer"]) + { + $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] + } + if($null -ne $PSBoundParameters["WarningAction"]) + { + $params["WarningAction"] = $PSBoundParameters["WarningAction"] + } + if($null -ne $PSBoundParameters["DeviceId"]) + { + $params["DeviceId1"] = $PSBoundParameters["DeviceId"] + } + if($null -ne $PSBoundParameters["PipelineVariable"]) + { + $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] + } + if($null -ne $PSBoundParameters["ApproximateLastLogonTimeStamp"]) + { + $params["ApproximateLastSignInDateTime"] = $PSBoundParameters["ApproximateLastLogonTimeStamp"] + } + if($null -ne $PSBoundParameters["InformationVariable"]) + { + $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] + } + if($null -ne $PSBoundParameters["DevicePhysicalIds"]) + { + $params["PhysicalIds"] = $PSBoundParameters["DevicePhysicalIds"] + } + if($null -ne $PSBoundParameters["OutVariable"]) + { + $params["OutVariable"] = $PSBoundParameters["OutVariable"] + } + if($null -ne $PSBoundParameters["IsCompliant"]) + { + $params["IsCompliant"] = $PSBoundParameters["IsCompliant"] + } + if($null -ne $PSBoundParameters["DeviceTrustType"]) + { + $params["TrustType"] = $PSBoundParameters["DeviceTrustType"] + } + if($null -ne $PSBoundParameters["IsManaged"]) + { + $params["IsManaged"] = $PSBoundParameters["IsManaged"] + } + if($null -ne $PSBoundParameters["ErrorAction"]) + { + $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] + } + if($PSBoundParameters.ContainsKey("Verbose")) + { + $params["Verbose"] = $PSBoundParameters["Verbose"] + } + if($PSBoundParameters.ContainsKey("Debug")) + { + $params["Debug"] = $PSBoundParameters["Debug"] + } + if($null -ne $PSBoundParameters["ProfileType"]) + { + $params["ProfileType"] = $PSBoundParameters["ProfileType"] + } + if($null -ne $PSBoundParameters["DeviceOSType"]) + { + $params["OperatingSystem"] = $PSBoundParameters["DeviceOSType"] + } + if($null -ne $PSBoundParameters["WarningVariable"]) + { + $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] + } + if($null -ne $PSBoundParameters["DisplayName"]) + { + $params["DisplayName"] = $PSBoundParameters["DisplayName"] + } + if($null -ne $PSBoundParameters["AccountEnabled"]) + { + $params["AccountEnabled"] = $PSBoundParameters["AccountEnabled"] + } + if($null -ne $PSBoundParameters["DeviceMetadata"]) + { + $params["DeviceMetadata"] = $PSBoundParameters["DeviceMetadata"] + } + if($null -ne $PSBoundParameters["InformationAction"]) + { + $params["InformationAction"] = $PSBoundParameters["InformationAction"] + } + if($null -ne $PSBoundParameters["DeviceObjectId"]) + { + $params["DeviceId"] = $PSBoundParameters["DeviceObjectId"] + } + if($null -ne $PSBoundParameters["SystemLabels"]) + { + $params["SystemLabels"] = $PSBoundParameters["SystemLabels"] + } + if($null -ne $PSBoundParameters["ProgressAction"]) + { + $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + } + if($null -ne $PSBoundParameters["ErrorVariable"]) + { + $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = Update-MgDevice @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + } - $Value = $Temp -'@ } - ) - Outputs = $null + $response + } +'@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 index 6b8166863..fd14729bb 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaDevice.ps1 @@ -3,67 +3,187 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Set-AzureADDevice" - TargetName = "Update-MgBetaDevice" - Parameters = @( - @{ - SourceName = "ApproximateLastLogonTimeStamp" - TargetName = "ApproximateLastSignInDateTime" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceId" - TargetName = "DeviceId1" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceObjectVersion" - TargetName = "DeviceVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSType" - TargetName = "OperatingSystem" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceOSVersion" - TargetName = "OperatingSystemVersion" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DevicePhysicalIds" - TargetName = "PhysicalIds" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "DeviceTrustType" - TargetName = "TrustType" - ConversionType = "Name" - SpecialMapping = $null - } - @{ - SourceName = "AlternativeSecurityIds" - TargetName = "BodyParameter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) - $Temp = @{ - alternativeSecurityIds = @( - @{ - type = $TmpValue.type - key = [System.Text.Encoding]::ASCII.GetBytes($key) - } - ) + TargetName = $null + Parameters = $null + Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $DevicePhysicalIds, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.AlternativeSecurityId]] $AlternativeSecurityIds, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsManaged, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $AccountEnabled, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceOSVersion, + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceObjectId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceOSType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ProfileType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DisplayName, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.DateTime]] $ApproximateLastLogonTimeStamp, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Boolean]] $IsCompliant, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceTrustType, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Int32]] $DeviceObjectVersion, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $DeviceMetadata, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Collections.Generic.List`1[System.String]] $SystemLabels + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand + + if($null -ne $PSBoundParameters["DevicePhysicalIds"]) + { + $params["PhysicalIds"] = $PSBoundParameters["DevicePhysicalIds"] + } + if($null -ne $PSBoundParameters["AlternativeSecurityIds"]) + { + $TmpValue = $PSBoundParameters["AlternativeSecurityIds"] + $key = [System.Text.Encoding]::UTF8.GetString($TmpValue.key) + $Temp = @{ + alternativeSecurityIds = @( + @{ + type = $TmpValue.type + key = [System.Text.Encoding]::ASCII.GetBytes($key) + } + ) + } + $Value = $Temp + $params["BodyParameter"] = $Value + } + if($PSBoundParameters.ContainsKey("Debug")) + { + $params["Debug"] = $PSBoundParameters["Debug"] + } + if($null -ne $PSBoundParameters["InformationVariable"]) + { + $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] + } + if($null -ne $PSBoundParameters["OutBuffer"]) + { + $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] + } + if($null -ne $PSBoundParameters["IsManaged"]) + { + $params["IsManaged"] = $PSBoundParameters["IsManaged"] + } + if($null -ne $PSBoundParameters["ErrorAction"]) + { + $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] + } + if($null -ne $PSBoundParameters["AccountEnabled"]) + { + $params["AccountEnabled"] = $PSBoundParameters["AccountEnabled"] + } + if($null -ne $PSBoundParameters["PipelineVariable"]) + { + $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] + } + if($null -ne $PSBoundParameters["DeviceOSVersion"]) + { + $params["OperatingSystemVersion"] = $PSBoundParameters["DeviceOSVersion"] + } + if($null -ne $PSBoundParameters["DeviceObjectId"]) + { + $params["DeviceId"] = $PSBoundParameters["DeviceObjectId"] + } + if($null -ne $PSBoundParameters["DeviceOSType"]) + { + $params["OperatingSystem"] = $PSBoundParameters["DeviceOSType"] + } + if($null -ne $PSBoundParameters["ProfileType"]) + { + $params["ProfileType"] = $PSBoundParameters["ProfileType"] + } + if($null -ne $PSBoundParameters["DisplayName"]) + { + $params["DisplayName"] = $PSBoundParameters["DisplayName"] + } + if($null -ne $PSBoundParameters["DeviceId"]) + { + $params["DeviceId1"] = $PSBoundParameters["DeviceId"] + } + if($null -ne $PSBoundParameters["ApproximateLastLogonTimeStamp"]) + { + $params["ApproximateLastSignInDateTime"] = $PSBoundParameters["ApproximateLastLogonTimeStamp"] + } + if($null -ne $PSBoundParameters["ErrorVariable"]) + { + $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] + } + if($null -ne $PSBoundParameters["InformationAction"]) + { + $params["InformationAction"] = $PSBoundParameters["InformationAction"] + } + if($null -ne $PSBoundParameters["WarningAction"]) + { + $params["WarningAction"] = $PSBoundParameters["WarningAction"] + } + if($null -ne $PSBoundParameters["IsCompliant"]) + { + $params["IsCompliant"] = $PSBoundParameters["IsCompliant"] + } + if($null -ne $PSBoundParameters["OutVariable"]) + { + $params["OutVariable"] = $PSBoundParameters["OutVariable"] + } + if($null -ne $PSBoundParameters["DeviceTrustType"]) + { + $params["TrustType"] = $PSBoundParameters["DeviceTrustType"] + } + if($null -ne $PSBoundParameters["DeviceObjectVersion"]) + { + $params["DeviceVersion"] = $PSBoundParameters["DeviceObjectVersion"] + } + if($null -ne $PSBoundParameters["WarningVariable"]) + { + $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] + } + if($null -ne $PSBoundParameters["ProgressAction"]) + { + $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + } + if($PSBoundParameters.ContainsKey("Verbose")) + { + $params["Verbose"] = $PSBoundParameters["Verbose"] + } + if($null -ne $PSBoundParameters["DeviceMetadata"]) + { + $params["DeviceMetadata"] = $PSBoundParameters["DeviceMetadata"] + } + if($null -ne $PSBoundParameters["SystemLabels"]) + { + $params["SystemLabels"] = $PSBoundParameters["SystemLabels"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = Update-MgBetaDevice @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + } - $Value = $Temp -'@ } - ) - Outputs = $null + $response + } +'@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDevice.md index 395480ca4..48fa83abe 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDevice.md @@ -26,7 +26,7 @@ Updates a device. ```powershell Set-EntraBetaDevice - -ObjectId + -DeviceObjectId [-DevicePhysicalIds ] [-DeviceOSType ] [-DeviceTrustType ] @@ -57,7 +57,7 @@ The calling user must have at least the Intune Administrator role in Microsoft E ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraBetaDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My OS/2 computer' +Set-EntraBetaDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My OS/2 computer' ``` This example shows how to update a display name of a specified. @@ -69,7 +69,7 @@ Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' $NewId= New-Object Microsoft.Open.AzureAD.Model.AlternativeSecurityId $NewId.Key =[System.Text.Encoding]::UTF8.GetBytes('test') $NewId.type = 2 -Set-EntraBetaDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AlternativeSecurityIds $NewId +Set-EntraBetaDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AlternativeSecurityIds $NewId ``` This example shows how to update an alternative security ID of a specified device. @@ -78,7 +78,7 @@ This example shows how to update an alternative security ID of a specified devic ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraBetaDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AccountEnabled $true +Set-EntraBetaDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AccountEnabled $true ``` This example shows how to update an account enabled of a specified device. @@ -87,7 +87,7 @@ This example shows how to update an account enabled of a specified device. ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraBetaDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DeviceOSType Windows +Set-EntraBetaDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DeviceOSType Windows ``` This example shows how to update an OS type of a specified device. @@ -98,7 +98,7 @@ This example shows how to update an OS type of a specified device. Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + DeviceObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' DeviceMetadata = 'Testdevice' DeviceObjectVersion = 4 DevicePhysicalIds = '[GID]:g:1234567890123456' @@ -320,14 +320,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceObjectId Specifies the object ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md index 3141dbfe5..3c7cb40f7 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplication.md @@ -200,7 +200,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md index a35c61890..829aec8c3 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUser.md @@ -217,7 +217,7 @@ Specifies the ID (as a User Principal Name (UPN) or UserId) of a user in Microso ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md index ea9cf26d2..705a8a1ed 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md @@ -60,7 +60,7 @@ Specifies the ID of a user (as a UPN or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md index 76832bc8d..90e396791 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplication.md @@ -288,7 +288,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDevice.md index 4e1298991..bb7f28d89 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDevice.md @@ -26,7 +26,7 @@ Updates a device. ```powershell Set-EntraDevice - -ObjectId + -DeviceObjectId [-DevicePhysicalIds ] [-DeviceOSType ] [-DeviceTrustType ] @@ -57,7 +57,7 @@ The calling user must have at least the Intune Administrator role in Microsoft E ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My OS/2 computer' +Set-EntraDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName 'My OS/2 computer' ``` This example shows how to update a display name of a specified. @@ -69,7 +69,7 @@ Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' $NewId= New-Object Microsoft.Open.AzureAD.Model.AlternativeSecurityId $NewId.Key =[System.Text.Encoding]::UTF8.GetBytes('test') $NewId.type = 2 -Set-EntraDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AlternativeSecurityIds $NewId +Set-EntraDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AlternativeSecurityIds $NewId ``` This example shows how to update an alternative security ID of a specified device. @@ -78,7 +78,7 @@ This example shows how to update an alternative security ID of a specified devic ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AccountEnabled $true +Set-EntraDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -AccountEnabled $true ``` This example shows how to update an account enabled of a specified device. @@ -87,7 +87,7 @@ This example shows how to update an account enabled of a specified device. ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' -Set-EntraDevice -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DeviceOSType Windows +Set-EntraDevice -DeviceObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DeviceOSType Windows ``` This example shows how to update an OS type of a specified device. @@ -98,7 +98,7 @@ This example shows how to update an OS type of a specified device. Connect-Entra -Scopes 'Directory.AccessAsUser.All','Device.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + DeviceObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' DeviceMetadata = 'Testdevice' DeviceObjectVersion = 4 DevicePhysicalIds = '[GID]:g:1234567890123456' @@ -320,14 +320,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceObjectId Specifies the object ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Get-EntraApplication.Tests.ps1 b/test/module/Entra/Get-EntraApplication.Tests.ps1 index 7f26417b9..c82845c84 100644 --- a/test/module/Entra/Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplication.Tests.ps1 @@ -112,5 +112,13 @@ Describe "Get-EntraApplication" { $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } + It "Should return specific user with Alias" { + $result = Get-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Write-Verbose "Result : {$result}" -Verbose + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } } } \ No newline at end of file diff --git a/test/module/Entra/Set-EntraApplication.Tests.ps1 b/test/module/Entra/Set-EntraApplication.Tests.ps1 index 485a30f17..85cf1b4a2 100644 --- a/test/module/Entra/Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Set-EntraApplication.Tests.ps1 @@ -41,5 +41,11 @@ Describe "Set-EntraApplication"{ $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } + It "Should return specific user with Alias" { + $result = Set-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } } } \ No newline at end of file diff --git a/test/module/Entra/Set-EntraDevice.Tests.ps1 b/test/module/Entra/Set-EntraDevice.Tests.ps1 index b803465fe..f179f5ef3 100644 --- a/test/module/Entra/Set-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Set-EntraDevice.Tests.ps1 @@ -14,21 +14,21 @@ BeforeAll { Describe "Set-EntraDevice"{ Context "Test for Set-EntraDevice" { It "Should return empty object"{ - $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + $result = Set-EntraDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Set-EntraDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DeviceObjectId is invalid" { + { Set-EntraDevice -DeviceObjectId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceObjectId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Set-EntraDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DeviceObjectId is empty" { + { Set-EntraDevice -DeviceObjectId } | Should -Throw "Missing an argument for parameter 'DeviceObjectId'*" } - It "Should contain DeviceId in parameters when passed ObjectId to it" { + It "Should contain DeviceId in parameters when passed DeviceObjectId to it" { Mock -CommandName Update-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.DeviceId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -37,9 +37,15 @@ Describe "Set-EntraDevice"{ $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraDevice" - $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result = Set-EntraDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } + It "Should return specific user with Alias" { + $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } } } \ No newline at end of file From 07c2e25068fa59f4595e19e4b2ca7b88d2b51e93 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 20 Sep 2024 17:21:55 +0530 Subject: [PATCH 16/64] added alias --- .../EntraBeta/customizations/Get-EntraBetaApplication.ps1 | 1 + .../Get-EntraBetaApplicationProxyApplication.ps1 | 1 + module/EntraBeta/customizations/Get-EntraBetaUser.ps1 | 1 + .../New-EntraBetaAdministrativeUnitMember.ps1 | 1 + .../Remove-EntraBetaApplicationProxyApplication.ps1 | 1 + .../EntraBeta/customizations/Set-EntraBetaApplication.ps1 | 1 + .../Get-EntraBetaApplication.md | 2 +- .../Get-EntraBetaApplicationExtensionProperty.md | 2 +- .../Get-EntraBetaApplicationProxyApplication.md | 2 +- .../Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md | 2 +- .../Get-EntraBetaContactManager.md | 2 +- .../Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md | 2 +- .../Get-EntraBetaDirectoryRole.md | 2 +- .../Get-EntraBetaGroupLifecyclePolicy.md | 2 +- .../Get-EntraBetaGroupPermissionGrant.md | 2 +- .../Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md | 2 +- .../New-EntraBetaAdministrativeUnitMember.md | 2 +- .../Remove-EntraBetaApplication.md | 2 +- .../Remove-EntraBetaApplicationExtensionProperty.md | 2 +- .../Remove-EntraBetaApplicationProxyApplication.md | 2 +- .../Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md | 2 +- .../Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md | 2 +- .../Remove-EntraBetaGroupLifecyclePolicy.md | 2 +- .../Remove-EntraBetaIdentityProvider.md | 2 +- .../Remove-EntraBetaServicePrincipal.md | 2 +- .../Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md | 2 +- .../Set-EntraBetaApplication.md | 2 +- .../Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md | 2 +- .../Set-EntraBetaGroupLifecyclePolicy.md | 2 +- .../Get-EntraApplicationExtensionProperty.md | 2 +- .../Microsoft.Graph.Entra/Get-EntraContactManager.md | 2 +- .../Microsoft.Graph.Entra/Get-EntraContract.md | 2 +- .../Microsoft.Graph.Entra/Get-EntraDirectoryRole.md | 2 +- .../Get-EntraGroupLifecyclePolicy.md | 2 +- .../Get-EntraGroupPermissionGrant.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraApplication.md | 2 +- .../Remove-EntraApplicationExtensionProperty.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraContact.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraDevice.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraGroup.md | 2 +- .../Remove-EntraGroupLifecyclePolicy.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md | 2 +- .../Microsoft.Graph.Entra/Set-EntraGroup.md | 2 +- .../Set-EntraGroupLifecyclePolicy.md | 2 +- test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 | 7 +++++++ test/module/Entra/Remove-EntraApplication.Tests.ps1 | 6 ++++++ test/module/Entra/Remove-EntraDevice.Tests.ps1 | 6 ++++++ test/module/Entra/Remove-EntraGroup.Tests.ps1 | 6 ++++++ test/module/Entra/Set-EntraDevice.Tests.ps1 | 6 ++++++ test/module/Entra/Set-EntraGroup.Tests.ps1 | 6 ++++++ test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 | 8 ++++++++ 52 files changed, 90 insertions(+), 39 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 index aab76b4f8..af9cce5c7 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 @@ -13,6 +13,7 @@ [System.String] $Filter, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Nullable`1[System.Int32]] $Top, + [Alias("ObjectId")] [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 index 9741bf7e9..e3391de83 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationProxyApplication.ps1 @@ -9,6 +9,7 @@ CustomScript = @' [CmdletBinding(DefaultParameterSetName = '')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] diff --git a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 index 343719a9b..a70cb9b3b 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 @@ -11,6 +11,7 @@ param ( [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Nullable`1[System.Int32]] $Top, + [Alias("ObjectId")] [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $UserId, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 b/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 index d7505a38e..fcb59009d 100644 --- a/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 +++ b/module/EntraBeta/customizations/New-EntraBetaAdministrativeUnitMember.ps1 @@ -33,6 +33,7 @@ [System.String] $MailNickname, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $OdataType, + [Alias("Id")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $AdministrativeUnitId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] diff --git a/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 b/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 index f32e1aa93..3c98af220 100644 --- a/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 +++ b/module/EntraBeta/customizations/Remove-EntraBetaApplicationProxyApplication.ps1 @@ -9,6 +9,7 @@ CustomScript = @' [CmdletBinding(DefaultParameterSetName = '')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 b/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 index d702f5b04..ddf186048 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaApplication.ps1 @@ -31,6 +31,7 @@ [System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.KeyCredential]] $KeyCredentials, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $TokenEncryptionKeyId, + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ApplicationId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md index 404aa7d6d..0ec0f310e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplication.md @@ -199,7 +199,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md index d31e99685..93eac437f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md @@ -64,7 +64,7 @@ Specifies the unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md index 93c8ab499..b7e918d85 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyApplication.md @@ -66,7 +66,7 @@ You can also find ApplicationId in the Microsoft Portal by navigating to Microso ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md index 85a2330f2..c7c97873f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContact.md @@ -179,7 +179,7 @@ Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md index 2bd7df2af..e9a8ad5c5 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactManager.md @@ -57,7 +57,7 @@ Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md index 8723eae85..075f0c3cb 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContract.md @@ -142,7 +142,7 @@ Specifies the ID of a contract. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md index d1573a81a..5af437ed0 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRole.md @@ -142,7 +142,7 @@ Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md index 734f75c48..41cf72645 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupLifecyclePolicy.md @@ -90,7 +90,7 @@ Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md index 1d45f2c98..59174b3d2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupPermissionGrant.md @@ -64,7 +64,7 @@ The unique identifier of group. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md index cac4cbf4d..842e31ef3 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUser.md @@ -218,7 +218,7 @@ Specifies the ID (as a User Principal Name (UPN) or UserId) of a user in Microso ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md index 276ac8cd6..c850c4f19 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAdministrativeUnitMember.md @@ -102,7 +102,7 @@ Specifies the AdministrativeUnitId of a Microsoft Entra ID administrative unit. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md index 2dbfa8228..a8eefb017 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplication.md @@ -54,7 +54,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md index 3761500cc..ceb3691ab 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationExtensionProperty.md @@ -80,7 +80,7 @@ Specifies the unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md index 92ec99d55..453e51b08 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplication.md @@ -71,7 +71,7 @@ You can also find this ApplicationId in the Microsoft by navigating to Microsoft ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md index 3807bb49b..edde24ed2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDevice.md @@ -58,7 +58,7 @@ Specifies the object ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md index 15708449b..596dfb90b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroup.md @@ -66,7 +66,7 @@ Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md index 4a22b6116..4c50619a6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupLifecyclePolicy.md @@ -54,7 +54,7 @@ Specifies the ID of the groupLifecyclePolicies object that this cmdlet removes. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md index 5d06748f8..a26a3fd9b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaIdentityProvider.md @@ -61,7 +61,7 @@ The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md index 6b6d4d21b..f08fcb4a7 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipal.md @@ -58,7 +58,7 @@ Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md index e24247a77..b84d22cf7 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUser.md @@ -58,7 +58,7 @@ Specifies the ID of a user (as a UPN or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md index a494febac..3bbe6af55 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplication.md @@ -311,7 +311,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md index a3c5fe289..907790d7d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroup.md @@ -214,7 +214,7 @@ Specifies the object ID of a group. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md index 5dfc959d3..e89017571 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaGroupLifecyclePolicy.md @@ -108,7 +108,7 @@ Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md index 8d77e5495..0ea6cc82b 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md @@ -64,7 +64,7 @@ Specifies the unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md index 93529d200..9aba15604 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactManager.md @@ -58,7 +58,7 @@ Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: OrgContactId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md index 9ae83a4d2..c65dae7c2 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContract.md @@ -141,7 +141,7 @@ Specifies the ID of a contract. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md index 7697b6e59..aac3e91b9 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRole.md @@ -141,7 +141,7 @@ Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md index f01768ede..9df4ac2bb 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupLifecyclePolicy.md @@ -90,7 +90,7 @@ Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md index b1e6f3416..61a2d722e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupPermissionGrant.md @@ -64,7 +64,7 @@ The unique identifier of group. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md index b6e74b331..974b7a659 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplication.md @@ -54,7 +54,7 @@ Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md index 25a244628..109fe85fc 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationExtensionProperty.md @@ -80,7 +80,7 @@ Specifies the unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md index ea249f48b..44d5764c5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraContact.md @@ -55,7 +55,7 @@ Specifies the object ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md index 311e33e83..ea66e8884 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDevice.md @@ -57,7 +57,7 @@ Specifies the object ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md index de4aff488..e1d0aef90 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroup.md @@ -65,7 +65,7 @@ Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md index 3e4d07373..b4fc2d8ce 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupLifecyclePolicy.md @@ -55,7 +55,7 @@ Specifies the ID of the groupLifecyclePolicies object that this cmdlet removes. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md index 7e9585f04..4581d7d88 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraIdentityProvider.md @@ -60,7 +60,7 @@ The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md index d627ae364..be2e2d827 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipal.md @@ -58,7 +58,7 @@ Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md index 4252ddded..1536da3ee 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroup.md @@ -188,7 +188,7 @@ Specifies the object ID of a group. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md index 5f08bcb59..ba9413e5e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraGroupLifecyclePolicy.md @@ -108,7 +108,7 @@ Specifies the ID of a groupLifecyclePolicies object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 index 2ce23c08b..323310ac9 100644 --- a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 @@ -36,6 +36,13 @@ Describe "Get-EntraDirectoryRole" { Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when DirectoryRoleId is invalid" { { Get-EntraDirectoryRole -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } diff --git a/test/module/Entra/Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Remove-EntraApplication.Tests.ps1 index caa5a8227..d788dd665 100644 --- a/test/module/Entra/Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplication.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Remove-EntraApplication" { Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Remove-EntraApplication -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when ApplicationId is invalid" { { Remove-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } diff --git a/test/module/Entra/Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Remove-EntraDevice.Tests.ps1 index 1cb6f65ed..1eb0be125 100644 --- a/test/module/Entra/Remove-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDevice.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Remove-EntraDevice" { Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Remove-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when DeviceId is invalid" { { Remove-EntraDevice -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." } diff --git a/test/module/Entra/Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Remove-EntraGroup.Tests.ps1 index 4f3b80fdb..75b890867 100644 --- a/test/module/Entra/Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroup.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Remove-EntraGroup" { Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Remove-EntraGroup -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when GroupId is invalid" { { Remove-EntraGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } diff --git a/test/module/Entra/Set-EntraDevice.Tests.ps1 b/test/module/Entra/Set-EntraDevice.Tests.ps1 index f179f5ef3..95d49c13d 100644 --- a/test/module/Entra/Set-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Set-EntraDevice.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Set-EntraDevice"{ Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when DeviceObjectId is invalid" { { Set-EntraDevice -DeviceObjectId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceObjectId' because it is an empty string." } diff --git a/test/module/Entra/Set-EntraGroup.Tests.ps1 b/test/module/Entra/Set-EntraGroup.Tests.ps1 index dc8de8387..f03b6c536 100644 --- a/test/module/Entra/Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Set-EntraGroup.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Set-EntraGroup" { Should -Invoke -CommandName Update-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Set-EntraGroup -Id bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when GroupId is invalid" { { Set-EntraGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } diff --git a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 index a452088e4..5bc994a4e 100644 --- a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 @@ -169,5 +169,13 @@ Describe "Get-EntraBetaUser" { $DebugPreference = $originalDebugPreference } } + It "Should return specific user with Alias" { + $result = Get-EntraBetaUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Write-Verbose "Result : {$result}" -Verbose + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('bbbbbbbb-1111-2222-3333-cccccccccccc') + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } } } \ No newline at end of file From 4429775be3d0f6ec27aeb084a141a2043dcc9667 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 20 Sep 2024 23:22:10 +0530 Subject: [PATCH 17/64] added alias --- .../Get-EntraDirectoryObjectOnPremisesProvisioningError.ps1 | 2 ++ .../AdditionalFunctions/Update-EntraUserFromFederated.ps1 | 2 ++ ...et-EntraBetaDirectoryObjectOnPremisesProvisioningError.ps1 | 4 +++- .../AdditionalFunctions/Update-EntraBetaUserFromFederated.ps1 | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/module/Entra/AdditionalFunctions/Get-EntraDirectoryObjectOnPremisesProvisioningError.ps1 b/module/Entra/AdditionalFunctions/Get-EntraDirectoryObjectOnPremisesProvisioningError.ps1 index dea107f48..5d1d03af9 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraDirectoryObjectOnPremisesProvisioningError.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraDirectoryObjectOnPremisesProvisioningError.ps1 @@ -36,3 +36,5 @@ function Get-EntraDirectoryObjectOnPremisesProvisioningError { } } +Set-Alias -Name Get-EntraHasObjectsWithDirSyncProvisioningError -Value Get-EntraDirectoryObjectOnPremisesProvisioningError -Scope Global -Force + diff --git a/module/Entra/AdditionalFunctions/Update-EntraUserFromFederated.ps1 b/module/Entra/AdditionalFunctions/Update-EntraUserFromFederated.ps1 index 349d874e1..2fc79e92a 100644 --- a/module/Entra/AdditionalFunctions/Update-EntraUserFromFederated.ps1 +++ b/module/Entra/AdditionalFunctions/Update-EntraUserFromFederated.ps1 @@ -79,3 +79,5 @@ function Update-EntraUserFromFederated { $response } } +Set-Alias -Name Convert-EntraFederatedUser -Value Update-EntraUserFromFederated -Scope Global -Force + diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaDirectoryObjectOnPremisesProvisioningError.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaDirectoryObjectOnPremisesProvisioningError.ps1 index 2e1a698ae..9866fe1d0 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaDirectoryObjectOnPremisesProvisioningError.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaDirectoryObjectOnPremisesProvisioningError.ps1 @@ -35,4 +35,6 @@ function Get-EntraBetaDirectoryObjectOnPremisesProvisioningError { $response } } -} \ No newline at end of file +} +Set-Alias -Name Get-EntraBetaHasObjectsWithDirSyncProvisioningError -Value Get-EntraBetaDirectoryObjectOnPremisesProvisioningError -Scope Global -Force + diff --git a/module/EntraBeta/AdditionalFunctions/Update-EntraBetaUserFromFederated.ps1 b/module/EntraBeta/AdditionalFunctions/Update-EntraBetaUserFromFederated.ps1 index 67803c6eb..09b03f7d9 100644 --- a/module/EntraBeta/AdditionalFunctions/Update-EntraBetaUserFromFederated.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Update-EntraBetaUserFromFederated.ps1 @@ -79,4 +79,6 @@ function Update-EntraBetaUserFromFederated { } $response } -} \ No newline at end of file +} +Set-Alias -Name Convert-EntraBetaFederatedUser -Value Update-EntraBetaUserFromFederated -Scope Global -Force + From 9e192fab74f885575fa7dd20ea31fca090f8cf5f Mon Sep 17 00:00:00 2001 From: v-akarke <142799789+v-akarke@users.noreply.github.com> Date: Tue, 24 Sep 2024 03:52:49 -0700 Subject: [PATCH 18/64] Usability parameters custom script/not null (#1088) * updated Entra cmdlets * added alias --- .../Set-EntraServicePrincipal.ps1 | 7 +- ...Get-EntraServicePrincipalKeyCredential.ps1 | 9 +- .../Get-EntraServicePrincipalOwner.ps1 | 17 ++- ...ntraServicePrincipalPasswordCredential.ps1 | 9 +- ...ntraServicePrincipalPasswordCredential.ps1 | 17 ++- .../Remove-EntraServicePrincipalOwner.ps1 | 102 +++++++++++++++--- ...ntraServicePrincipalPasswordCredential.ps1 | 11 +- .../Add-EntraServicePrincipalOwner.md | 10 +- .../Get-EntraServicePrincipal.md | 12 +-- .../Get-EntraServicePrincipalCreatedObject.md | 18 ++-- .../Get-EntraServicePrincipalKeyCredential.md | 10 +- .../Get-EntraServicePrincipalMembership.md | 18 ++-- ...raServicePrincipalOAuth2PermissionGrant.md | 12 +-- .../Get-EntraServicePrincipalOwner.md | 22 ++-- ...EntraServicePrincipalPasswordCredential.md | 10 +- ...EntraServicePrincipalPasswordCredential.md | 14 +-- ...move-EntraServicePrincipalKeyCredential.md | 10 +- .../Remove-EntraServicePrincipalOwner.md | 12 +-- ...EntraServicePrincipalPasswordCredential.md | 12 +-- .../Set-EntraServicePrincipal.md | 32 +++--- ...EntraServicePrincipalOwnedObject.Tests.ps1 | 30 +++--- .../Entra/Set-EntraServicePrincipal.Tests.ps1 | 28 +++-- 22 files changed, 279 insertions(+), 143 deletions(-) diff --git a/module/Entra/AdditionalFunctions/Set-EntraServicePrincipal.ps1 b/module/Entra/AdditionalFunctions/Set-EntraServicePrincipal.ps1 index 0f12fe77b..b7a13abd7 100644 --- a/module/Entra/AdditionalFunctions/Set-EntraServicePrincipal.ps1 +++ b/module/Entra/AdditionalFunctions/Set-EntraServicePrincipal.ps1 @@ -31,8 +31,9 @@ function Set-EntraServicePrincipal { [System.String] $ServicePrincipalType, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.Collections.Generic.List`1[System.String]] $Tags, + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $ServicePrincipalId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.PasswordCredential]] $PasswordCredentials, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -99,9 +100,9 @@ function Set-EntraServicePrincipal { { $body["replyUrls"] = $PSBoundParameters["ReplyUrls"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ServicePrincipalId"]) { - $params["Uri"] += "/$ObjectId" + $params["Uri"] += "/$ServicePrincipalId" } if($null -ne $PSBoundParameters["LogoutUrl"]) { diff --git a/module/Entra/customizations/Get-EntraServicePrincipalKeyCredential.ps1 b/module/Entra/customizations/Get-EntraServicePrincipalKeyCredential.ps1 index 2058892c0..a08f25ed6 100644 --- a/module/Entra/customizations/Get-EntraServicePrincipalKeyCredential.ps1 +++ b/module/Entra/customizations/Get-EntraServicePrincipalKeyCredential.ps1 @@ -7,8 +7,15 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId + ) + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $response = (Get-MgServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"]).KeyCredentials + $response = (Get-MgServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"]).KeyCredentials $response | ForEach-Object { if($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name StartDate -Value StartDateTime diff --git a/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 b/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 index efbeba360..a9b9e7257 100644 --- a/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 +++ b/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 @@ -7,6 +7,19 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +27,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ServicePrincipalId"]) { - $params["ServicePrincipalId"] = $PSBoundParameters["ObjectId"] + $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/Entra/customizations/Get-EntraServicePrincipalPasswordCredential.ps1 b/module/Entra/customizations/Get-EntraServicePrincipalPasswordCredential.ps1 index b441ec9c1..f78df77a9 100644 --- a/module/Entra/customizations/Get-EntraServicePrincipalPasswordCredential.ps1 +++ b/module/Entra/customizations/Get-EntraServicePrincipalPasswordCredential.ps1 @@ -7,8 +7,15 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId + ) + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $response = (Get-MgServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"]).PasswordCredentials + $response = (Get-MgServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"]).PasswordCredentials $response | ForEach-Object { if($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name StartDate -Value StartDateTime diff --git a/module/Entra/customizations/New-EntraServicePrincipalPasswordCredential.ps1 b/module/Entra/customizations/New-EntraServicePrincipalPasswordCredential.ps1 index c3b5e1b54..8c4afe22a 100644 --- a/module/Entra/customizations/New-EntraServicePrincipalPasswordCredential.ps1 +++ b/module/Entra/customizations/New-EntraServicePrincipalPasswordCredential.ps1 @@ -7,6 +7,21 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Value, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $StartDate, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $CustomKeyIdentifier, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $EndDate + ) + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $body = @{ passwordCredential = @{ @@ -14,7 +29,7 @@ endDateTime = $PSBoundParameters["EndDate"]; } } - $response = Add-MgServicePrincipalPassword -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"] -BodyParameter $body + $response = Add-MgServicePrincipalPassword -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"] -BodyParameter $body $response | ForEach-Object { if($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name StartDate -Value StartDateTime diff --git a/module/Entra/customizations/Remove-EntraServicePrincipalOwner.ps1 b/module/Entra/customizations/Remove-EntraServicePrincipalOwner.ps1 index d2af043bf..9104f4547 100644 --- a/module/Entra/customizations/Remove-EntraServicePrincipalOwner.ps1 +++ b/module/Entra/customizations/Remove-EntraServicePrincipalOwner.ps1 @@ -1,19 +1,91 @@ @{ SourceName = "Remove-AzureADServicePrincipalOwner" - TargetName = "Remove-MgServicePrincipalOwnerByRef" - Parameters = @( - @{ - SourceName = "ObjectId" - TargetName = "ServicePrincipalId" - ConversionType = "Name" - SpecialMapping = $null - }, - @{ - SourceName = "OwnerId" - TargetName = "DirectoryObjectId" - ConversionType = "Name" - SpecialMapping = $null - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $OwnerId + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + + if($null -ne $PSBoundParameters["ErrorVariable"]) + { + $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] + } + if($null -ne $PSBoundParameters["OutVariable"]) + { + $params["OutVariable"] = $PSBoundParameters["OutVariable"] + } + if($null -ne $PSBoundParameters["WarningVariable"]) + { + $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] + } + if($null -ne $PSBoundParameters["PipelineVariable"]) + { + $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] + } + if($null -ne $PSBoundParameters["WarningAction"]) + { + $params["WarningAction"] = $PSBoundParameters["WarningAction"] + } + if($null -ne $PSBoundParameters["ServicePrincipalId"]) + { + $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] + } + if($null -ne $PSBoundParameters["InformationAction"]) + { + $params["InformationAction"] = $PSBoundParameters["InformationAction"] + } + if($null -ne $PSBoundParameters["ErrorAction"]) + { + $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] + } + if($PSBoundParameters.ContainsKey("Verbose")) + { + $params["Verbose"] = $PSBoundParameters["Verbose"] + } + if($null -ne $PSBoundParameters["InformationVariable"]) + { + $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] + } + if($null -ne $PSBoundParameters["OwnerId"]) + { + $params["DirectoryObjectId"] = $PSBoundParameters["OwnerId"] + } + if($PSBoundParameters.ContainsKey("Debug")) + { + $params["Debug"] = $PSBoundParameters["Debug"] + } + if($null -ne $PSBoundParameters["ProgressAction"]) + { + $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + } + if($null -ne $PSBoundParameters["OutBuffer"]) + { + $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = Remove-MgServicePrincipalOwnerByRef @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + + } + } + $response + } +'@ } \ No newline at end of file diff --git a/module/Entra/customizations/Remove-EntraServicePrincipalPasswordCredential.ps1 b/module/Entra/customizations/Remove-EntraServicePrincipalPasswordCredential.ps1 index 7f68d0c17..9cf798ee2 100644 --- a/module/Entra/customizations/Remove-EntraServicePrincipalPasswordCredential.ps1 +++ b/module/Entra/customizations/Remove-EntraServicePrincipalPasswordCredential.ps1 @@ -7,9 +7,18 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $KeyId, + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ServicePrincipalId + ) + PROCESS{ $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - Remove-MgServicePrincipalPassword -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"] -KeyId $PSBoundParameters["KeyId"] + Remove-MgServicePrincipalPassword -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"] -KeyId $PSBoundParameters["KeyId"] } '@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraServicePrincipalOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraServicePrincipalOwner.md index 0abedb066..a39843301 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraServicePrincipalOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraServicePrincipalOwner.md @@ -25,7 +25,7 @@ Adds an owner to a service principal. ```powershell Add-EntraServicePrincipalOwner - -ObjectId + -ServicePrincipalId -RefObjectId [] ``` @@ -43,7 +43,7 @@ Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy $ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId $OwnerId = (Get-EntraUser -Top 1).ObjectId $Params = @{ - ObjectId = $ServicePrincipalId + ServicePrincipalId = $ServicePrincipalId RefObjectId = $OwnerId } Add-EntraServicePrincipalOwner @Params @@ -51,19 +51,19 @@ Add-EntraServicePrincipalOwner @Params This example demonstrates how to add an owner to a service principal. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. - `-RefObjectId` parameter specifies the user object ID. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipal.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipal.md index 40465f020..ad63780a2 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipal.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipal.md @@ -49,7 +49,7 @@ Get-EntraServicePrincipal ```powershell Get-EntraServicePrincipal - -ObjectId + -ServicePrincipalId [-All] [-Property ] [] @@ -78,11 +78,11 @@ dddddddd-3333-4444-5555-eeeeeeeeeeee 33334444-dddd-5555-eeee-6666ffff7777 Projec This example retrieves all service principals from the directory. -### Example 2: Retrieve a service principal by ObjectId +### Example 2: Retrieve a service principal by ServicePrincipalId ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraServicePrincipal -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraServicePrincipal -ServicePrincipalId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -93,7 +93,7 @@ M365 License Manager aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb 0000111 This command retrieves specific service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 3: Retrieve all service principals from the directory @@ -255,14 +255,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalCreatedObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalCreatedObject.md index 4c9788f27..8a607194b 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalCreatedObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalCreatedObject.md @@ -25,7 +25,7 @@ Get objects created by a service principal. ```powershell Get-EntraServicePrincipalCreatedObject - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -43,36 +43,36 @@ The `Get-EntraServicePrincipalCreatedObject` cmdlet gets an object created by a ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId +Get-EntraServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId ``` This example gets objects created by the service principal identified by $ServicePrincipalId. You can use the command `Get-EntraServicePrincipal` to get service principal ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 2: Retrieve the all objects created by a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` This example demonstrates how to get the all object created by a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 3: Retrieve the top two objects created by a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId -Top 2 +Get-EntraServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId -Top 2 ``` This example demonstrates how to get the top two object created by a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ## Parameters @@ -92,14 +92,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalKeyCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalKeyCredential.md index 85ee76686..4e4a3529c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalKeyCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalKeyCredential.md @@ -26,7 +26,7 @@ Get key credentials for a service principal. ```powershell Get-EntraServicePrincipalKeyCredential - -ObjectId + -ServicePrincipalId [] ``` @@ -41,7 +41,7 @@ The `Get-EntraServicePrincipalKeyCredential` cmdlet gets the key credentials for ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalKeyCredential -ObjectId $ServicePrincipal.ObjectId +Get-EntraServicePrincipalKeyCredential -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -52,18 +52,18 @@ CustomKeyIdentifier DisplayName EndDateTime Key KeyId This example retrieves the key credentials for specified service principal in Microsoft Entra ID. You can use the command `Get-EntraServicePrincipal` to get a service principal object Id. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of the application for which to get the password credential. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalMembership.md index 4eafe52e4..4fcb1f99c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalMembership.md @@ -26,7 +26,7 @@ Get a service principal membership. ```powershell Get-EntraServicePrincipalMembership - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraServicePrincipalMembership` cmdlet gets the memberships of a servi ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId +Get-EntraServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -55,14 +55,14 @@ Id DeletedDateTime This cmdlet retrieves a specified service principal memberships in Microsoft Entra ID. You can use the command `Get-EntraServicePrincipal` to get service principal ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 2: Retrieve all memberships of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -75,14 +75,14 @@ Id DeletedDateTime This command gets all memberships of a specified service principal. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 3: Retrieve top two memberships of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId -Top 2 +Get-EntraServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId -Top 2 ``` ```Output @@ -95,7 +95,7 @@ Id DeletedDateTime This command gets top two memberships of a specified service principal. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ## Parameters @@ -115,14 +115,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.md index 0c1c1d42c..aaa8e79db 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.md @@ -26,7 +26,7 @@ Gets an oAuth2PermissionGrant object. ```powershell Get-EntraServicePrincipalOAuth2PermissionGrant --ObjectId +-ServicePrincipalId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraServicePrincipalOAuth2PermissionGrant` cmdlet gets an oAuth2Permis ```powershell Connect-Entra -Scopes 'Directory.Read.All' ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId -Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId $ServicePrincipalId +Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId $ServicePrincipalId ``` ```output @@ -59,7 +59,7 @@ This example demonstrates how to get all oAuth2PermissionGrant object for a serv ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' -All +Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' -All ``` ```Output @@ -76,7 +76,7 @@ This example demonstrates how to get all oAuth2PermissionGrant object for a serv ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' -Top 2 +Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' -Top 2 ``` ```Output @@ -106,14 +106,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwner.md index 63b5a49dd..10562863a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwner.md @@ -26,7 +26,7 @@ Get the owner of a service principal. ```powershell Get-EntraServicePrincipalOwner - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraServicePrincipalOwner` cmdlet gets the owners of a service princip ```powershell Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId +Get-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId ``` ```Output @@ -57,14 +57,14 @@ cccccccc-2222-3333-4444-dddddddddddd This example gets the owners of a specified service principal. You can use the comand `Get-EntraServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 2: Retrieve all the owners of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId -All +Get-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId -All ``` ```Output @@ -77,14 +77,14 @@ cccccccc-2222-3333-4444-dddddddddddd This command gets all the owners of a service principal. You can use the comand `Get-EntraServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 3: Retrieve top two owners of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId -Top 2 +Get-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId -Top 2 ``` ```Output @@ -96,7 +96,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This command gets top two owners of a service principal. You can use the comand `Get-EntraServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 4: Retrieve service principal owner details @@ -104,13 +104,13 @@ This command gets top two owners of a service principal. You can use the comand Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" # Get the owners of the service principal -$owners = Get-EntraServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId -All +$owners = Get-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId -All $result = @() # Loop through each owner and get their UserPrincipalName and DisplayName foreach ($owner in $owners) { $userId = $owner.Id - $user = Get-EntraUser -ObjectId $userId + $user = Get-EntraUser -UserId $userId $userDetails = [PSCustomObject]@{ Id = $owner.Id UserPrincipalName = $user.UserPrincipalName @@ -150,14 +150,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalPasswordCredential.md index 68447c93b..a841d551c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalPasswordCredential.md @@ -26,7 +26,7 @@ Get credentials for a service principal. ```powershell Get-EntraServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId [] ``` @@ -41,7 +41,7 @@ The `Get-EntraServicePrincipalPasswordCredential` cmdlet gets the password crede ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalPasswordCredential -ObjectId $ServicePrincipal.ObjectId +Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -54,18 +54,18 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This example retrieves the password credentials for specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the object ID of a service principal. You can use the command `Get-EntraServicePrincipal` to get a service principal Id. +- `-ServicePrincipalId` parameter specifies the object ID of a service principal. You can use the command `Get-EntraServicePrincipal` to get a service principal Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of the service principal for which to get password credentials. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraServicePrincipalPasswordCredential.md index 6bd727064..4b36dca9c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraServicePrincipalPasswordCredential.md @@ -27,7 +27,7 @@ Creates a password credential for a service principal. ```powershell New-EntraServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId [-EndDate ] [-StartDate ] [] @@ -45,7 +45,7 @@ The `New-EntraServicePrincipalPasswordCredential` cmdlet creates a password cred Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId StartDate = '2024-04-21T14:14:14Z' } New-EntraServicePrincipalPasswordCredential @Params @@ -67,7 +67,7 @@ EndDate : 08-08-2026 10:30:00 This example demonstrates how to create a password credential with StartDate for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-StarteDate` parameter specifies the date and time at which the password becomes valid. ### Example 2: Create a password credential with EndtDate @@ -76,7 +76,7 @@ This example demonstrates how to create a password credential with StartDate for Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId EndDate = '2030-03-21T14:14:14Z' } New-EntraServicePrincipalPasswordCredential @Params @@ -98,7 +98,7 @@ EndDate : 08-08-2026 10:30:00 This example demonstrates how to create a password credential with EndDate for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-EndDate` parameter specifies the date and time at which the password expires represented using ISO 8601 format and is always in UTC time. ## Parameters @@ -119,14 +119,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of the service principal. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalKeyCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalKeyCredential.md index 9e0e60ad0..4aeee9df7 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalKeyCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalKeyCredential.md @@ -26,7 +26,7 @@ Removes a key credential from a service principal. ```powershell Remove-EntraServicePrincipalKeyCredential - -ObjectId + -ServicePrincipalId -KeyId [] ``` @@ -43,8 +43,8 @@ The Remove-EntraServicePrincipalKeyCredential cmdlet removes a key credential fr Connect-Entra -Scopes 'Application.ReadWrite.All' #Delegated Permission Connect-Entra -Scopes 'Application.ReadWrite.OwnedBy' #Application Permission $SPObjectID = (Get-EntraServicePrincipal -SearchString 'Entra Multi-Factor Auth Client').ObjectID -Get-EntraServicePrincipalKeyCredential -ObjectId $SPObjectID -Remove-EntraServicePrincipalKeyCredential -ObjectID $SPObjectID -KeyId +Get-EntraServicePrincipalKeyCredential -ServicePrincipalId $SPObjectID +Remove-EntraServicePrincipalKeyCredential -ServicePrincipalId $SPObjectID -KeyId ``` This example demonstrates how to remove a key credential from a service principal in Microsoft Entra ID. @@ -71,14 +71,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalOwner.md index 9a6ece57b..6bc57c180 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalOwner.md @@ -27,7 +27,7 @@ Removes an owner from a service principal. ```powershell Remove-EntraServicePrincipalOwner -OwnerId - -ObjectId + -ServicePrincipalId [] ``` @@ -42,10 +42,10 @@ The `Remove-EntraServicePrincipalOwner` cmdlet removes an owner from a service p ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -$owner = Get-EntraUser -ObjectId 'SawyerM@contoso.com' +$owner = Get-EntraUser -UserId 'SawyerM@contoso.com' $params= @{ - ObjectId = $servicePrincipal.Id + ServicePrincipalId = $servicePrincipal.Id OwnerId = $owner.Id } Remove-EntraServicePrincipalOwner @params @@ -53,19 +53,19 @@ Remove-EntraServicePrincipalOwner @params This example demonstrates how to remove an owner from a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. - `-OwnerId` parameter specifies the service principal owner Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalPasswordCredential.md index 02defd606..6706517f4 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalPasswordCredential.md @@ -25,7 +25,7 @@ Removes a password credential from a service principal. ```powershell Remove-EntraServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId -KeyId [] ``` @@ -42,15 +42,15 @@ The `Remove-EntraServicePrincipalPasswordCredential` cmdlet removes a password c Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId - KeyId = 'bbbbbbbb-1c1c-2d2d-3e3e-444444444444' + ServicePrincipalId = $ServicePrincipal.ObjectId + KeyId = 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' } Remove-EntraServicePrincipalPasswordCredential @Params ``` This example demonstrates how to remove a password credential from a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ObjectId of a specified Service Principal Password Credential. +- `-ServicePrincipalId` parameter specifies the ServicePrincipalId of a specified Service Principal Password Credential. - `-KeyId` parameter specifies the unique identifier of a Password Credential. ## Parameters @@ -71,14 +71,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraServicePrincipal.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraServicePrincipal.md index ebc34703c..3a6529577 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraServicePrincipal.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraServicePrincipal.md @@ -25,7 +25,7 @@ Updates a service principal. ```powershell Set-EntraServicePrincipal - -ObjectId + -ServicePrincipalId [-KeyCredentials ] [-Homepage ] [-AppId ] @@ -55,7 +55,7 @@ The `Set-EntraServicePrincipal` cmdlet updates a service principal in Microsoft Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AccountEnabled = $False } Set-EntraServicePrincipal @params @@ -63,7 +63,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update `AccountEnabled` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-AccountEnabled` parameter specifies indicates whether the account is enabled. ### Example 2: Update AppId and Homepage of a service principal @@ -72,7 +72,7 @@ This example demonstrates how to update `AccountEnabled` of a service principal Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AppId = '22223333-cccc-4444-dddd-5555eeee6666' Homepage = 'https://*.e-days.com/SSO/SAML2/SP/AssertionConsumer.aspx?metadata=e-days|ISV9.2|primary|z' } @@ -81,7 +81,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update `AppId` and Homepage of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-AppId` parameter specifies the application ID. - `-Homepage` parameter specifies the home page or landing page of the application. @@ -91,7 +91,7 @@ This example demonstrates how to update `AppId` and Homepage of a service princi Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AlternativeNames = 'Service Principal Demo' DisplayName = 'NewName' } @@ -100,7 +100,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update AlternativeNames and DisplayName of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 4: Update LogoutUrl and ReplyUrls of a service principal @@ -108,7 +108,7 @@ This example demonstrates how to update AlternativeNames and DisplayName of a se Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId LogoutUrl = 'https://securescore.office.com/SignOut' ReplyUrls = 'https://admin.contoso.com' } @@ -117,7 +117,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update LogoutUrl and ReplyUrls of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-LogoutUrl` parameter specifies the sign out URL. - `-ReplyUrls` parameter specifies the URLs that user tokens are sent to for sign in with the associated application. @@ -127,7 +127,7 @@ This example demonstrates how to update LogoutUrl and ReplyUrls of a service pri Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId ServicePrincipalType = 'Application' AppRoleAssignmentRequired = $True } @@ -136,7 +136,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update `ServicePrincipalType` and `AppRoleAssignmentRequired` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-ServicePrincipalType` parameter specifies the service principal type. - `-AppRoleAssignmentRequired` parameter specifies indicates whether an application role assignment is required. @@ -153,7 +153,7 @@ $creds.Type = 'Symmetric' $creds.Usage = 'Sign' $creds.Value = [System.Text.Encoding]::UTF8.GetBytes('A') $creds.EndDate = Get-Date -Year 2025 -Month 12 -Day 20 -Set-EntraServicePrincipal -ObjectId $servicePrincipal.ObjectId -KeyCredentials $creds +Set-EntraServicePrincipal -ServicePrincipalId $servicePrincipal.ObjectId -KeyCredentials $creds ``` This example demonstrates how to update KeyCredentials of a service principal in Microsoft Entra ID. @@ -166,7 +166,7 @@ Use the `New-EntraServicePrincipalPasswordCredential` and `Remove-EntraServicePr Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId PreferredSingleSignOnMode = 'saml' } Set-EntraServicePrincipal @params @@ -174,7 +174,7 @@ Set-EntraServicePrincipal @params This example demonstrates how to update `PreferredSingleSignOnMode` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-PreferredSingleSignOnMode` parameter specifies the single sign-on mode configured for this application. ## Parameters @@ -307,14 +307,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Species the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 index f2d04dd3c..7721d119a 100644 --- a/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 @@ -29,42 +29,48 @@ BeforeAll { Describe "Get-EntraServicePrincipalOwnedObject" { Context "Test for Get-EntraServicePrincipalOwnedObject" { It "Should return specific Owned Object" { + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific ServicePrincipalOwnedObject with Alias" { $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalOwnedObject -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraServicePrincipalOwnedObject -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ServicePrincipalId is null" { + { Get-EntraServicePrincipalOwnedObject -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } It "Should return all Owned Objects" { - $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" -All + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } It "Should return top Owned Object" { - $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" -Top 1 + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "2d028fff-7e65-4340-80ca-89be16dae0b3" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwnedObject" - $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" + $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } diff --git a/test/module/Entra/Set-EntraServicePrincipal.Tests.ps1 b/test/module/Entra/Set-EntraServicePrincipal.Tests.ps1 index 4ca5fed18..45c0b59c5 100644 --- a/test/module/Entra/Set-EntraServicePrincipal.Tests.ps1 +++ b/test/module/Entra/Set-EntraServicePrincipal.Tests.ps1 @@ -14,19 +14,25 @@ Describe "Set-EntraServicePrincipal"{ Context "Test for Set-EntraServicePrincipal" { It "Should update the parameter" { $tags = @("Environment=Production", "Department=Finance", "Project=MNO") - $result= Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AccountEnabled $false -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -AppRoleAssignmentRequired $true -DisplayName "test11" -ServicePrincipalNames "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Tags $tags + $result= Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AccountEnabled $false -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -AppRoleAssignmentRequired $true -DisplayName "test11" -ServicePrincipalNames "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Tags $tags $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should update the parameter with Alias" { + $result= Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AccountEnabled $false -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -AppRoleAssignmentRequired $true -DisplayName "test11" -ServicePrincipalNames "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should update the LogoutUrl and ServicePrincipalType parameter" { - $result= Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -LogoutUrl 'https://securescore.office.com/SignOut' -ServicePrincipalType "Application" + $result= Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -LogoutUrl 'https://securescore.office.com/SignOut' -ServicePrincipalType "Application" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should update the Homepage, ReplyUrls and AlternativeNames parameter" { - $result= Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Homepage 'https://HomePageurlss.com' -ReplyUrls 'https://admin.microsoft1.com' -AlternativeNames "updatetest" + $result= Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Homepage 'https://HomePageurlss.com' -ReplyUrls 'https://admin.microsoft1.com' -AlternativeNames "updatetest" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 @@ -40,24 +46,24 @@ Describe "Set-EntraServicePrincipal"{ $creds.Usage = 'Sign' $creds.Value = [System.Text.Encoding]::UTF8.GetBytes("A") $creds.EndDate = Get-Date -Year 2025 -Month 12 -Day 20 - $result= Set-EntraServicePrincipal -ObjectId 6aa187e3-bbbb-4748-a708-fc380aa9eb17 -KeyCredentials $creds + $result= Set-EntraServicePrincipal -ServicePrincipalId 6aa187e3-bbbb-4748-a708-fc380aa9eb17 -KeyCredentials $creds $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraServicePrincipal -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Set-EntraServicePrincipal -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is Invalid" { - { Set-EntraServicePrincipal -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is Invalid" { + { Set-EntraServicePrincipal -ServicePrincipalId ""} | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should fail when non-mandatory is empty" { - { Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AppId -Tags -ReplyUrls -AccountEnabled -AlternativeNames -KeyCredentials -Homepage} | Should -Throw "Missing an argument for parameter*" + { Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AppId -Tags -ReplyUrls -AccountEnabled -AlternativeNames -KeyCredentials -Homepage} | Should -Throw "Missing an argument for parameter*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraServicePrincipal" - Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -LogoutUrl 'https://securescore.office.com/SignOut' -ServicePrincipalType "Application" + Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -LogoutUrl 'https://securescore.office.com/SignOut' -ServicePrincipalType "Application" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraServicePrincipal" @@ -73,7 +79,7 @@ Describe "Set-EntraServicePrincipal"{ $tags = @("Environment=Production", "Department=Finance", "Project=MNO") try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraServicePrincipal -ObjectId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AccountEnabled $false -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -AppRoleAssignmentRequired $true -DisplayName "test11" -ServicePrincipalNames "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Tags $tags -Debug } | Should -Not -Throw + { Set-EntraServicePrincipal -ServicePrincipalId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -AccountEnabled $false -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -AppRoleAssignmentRequired $true -DisplayName "test11" -ServicePrincipalNames "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Tags $tags -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 56ad9bde72516e1d3719d1226969b522b6596256 Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Tue, 24 Sep 2024 22:41:25 +0530 Subject: [PATCH 19/64] objectId alias change (#1048) * updates * updates * Updated alias name * updates --------- Co-authored-by: v-varshamane <142500640+v-varshamane@users.noreply.github.com> --- .../Get-EntraAttributeSet.ps1 | 7 +++-- .../Get-EntraAuditSignInLog.ps1 | 7 +++-- .../New-EntraAttributeSet.ps1 | 7 +++-- .../Set-EntraAttributeSet.ps1 | 7 +++-- .../Get-EntraAttributeSet.md | 10 +++---- .../Get-EntraAuditSignInLog.md | 17 +++++++++++ .../New-EntraAttributeSet.md | 8 ++--- .../Set-EntraAttributeSet.md | 28 ++++++++++-------- .../Entra/Get-EntraAttributeSet.Tests.ps1 | 21 +++++++++----- .../Entra/Get-EntraAuditSignInLog.Tests.ps1 | 16 ++++++---- .../Entra/New-EntraAttributeSet.Tests.ps1 | 17 ++++++++--- .../Entra/Set-EntraAttributeSet.Tests.ps1 | 29 ++++++++++++++++--- 12 files changed, 121 insertions(+), 53 deletions(-) diff --git a/module/Entra/AdditionalFunctions/Get-EntraAttributeSet.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAttributeSet.ps1 index 15ab2fe0a..cdccf1849 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAttributeSet.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAttributeSet.ps1 @@ -6,7 +6,8 @@ function Get-EntraAttributeSet { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id + [Alias("Id")] + [System.String] $AttributeSetId ) PROCESS { @@ -14,8 +15,8 @@ function Get-EntraAttributeSet { $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $params["Uri"] = "https://graph.microsoft.com/v1.0/directory/attributeSets/" $params["Method"] = "GET" - if ($null -ne $PSBoundParameters["Id"]) { - $params["Uri"] += $Id + if ($null -ne $PSBoundParameters["AttributeSetId"]) { + $params["Uri"] += $AttributeSetId } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug diff --git a/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 index 95ff8dfe8..5686e768d 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 @@ -6,7 +6,8 @@ function Get-EntraAuditSignInLog { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(ParameterSetName = "GetById", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id, + [Alias("Id")] + [System.String] $SignInId, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Int32] $Top, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -35,9 +36,9 @@ function Get-EntraAuditSignInLog { } } - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["SignInId"]) { - $logId = $PSBoundParameters["Id"] + $logId = $PSBoundParameters["SignInId"] $params["Uri"] = "$baseUri/$($logId)" } if($null -ne $PSBoundParameters["Filter"]) diff --git a/module/Entra/AdditionalFunctions/New-EntraAttributeSet.ps1 b/module/Entra/AdditionalFunctions/New-EntraAttributeSet.ps1 index 6e18e5af6..97e1a671c 100644 --- a/module/Entra/AdditionalFunctions/New-EntraAttributeSet.ps1 +++ b/module/Entra/AdditionalFunctions/New-EntraAttributeSet.ps1 @@ -6,7 +6,8 @@ function New-EntraAttributeSet { [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] param ( [Parameter(ParameterSetName = "InvokeByDynamicParameters")] - [System.String] $Id, + [Alias("Id")] + [System.String] $AttributeSetId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $Description, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -20,8 +21,8 @@ function New-EntraAttributeSet { $params["Uri"] = "https://graph.microsoft.com/v1.0/directory/attributeSets" $params["Method"] = "POST" - if ($null -ne $PSBoundParameters["Id"]) { - $body["id"] = $PSBoundParameters["Id"] + if ($null -ne $PSBoundParameters["AttributeSetId"]) { + $body["id"] = $PSBoundParameters["AttributeSetId"] } if ($null -ne $PSBoundParameters["Description"]) { $body["description"] = $PSBoundParameters["Description"] diff --git a/module/Entra/AdditionalFunctions/Set-EntraAttributeSet.ps1 b/module/Entra/AdditionalFunctions/Set-EntraAttributeSet.ps1 index a1a763d8f..ffa208ddf 100644 --- a/module/Entra/AdditionalFunctions/Set-EntraAttributeSet.ps1 +++ b/module/Entra/AdditionalFunctions/Set-EntraAttributeSet.ps1 @@ -6,7 +6,8 @@ function Set-EntraAttributeSet { [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] param ( [Parameter(ParameterSetName = "InvokeByDynamicParameters")] - [System.String] $Id, + [Alias("Id")] + [System.String] $AttributeSetId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $Description, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -19,9 +20,9 @@ function Set-EntraAttributeSet { $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $params["Uri"] = "https://graph.microsoft.com/v1.0/directory/attributeSets/" $params["Method"] = "PATCH" - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["AttributeSetId"]) { - $params["Uri"] += $Id + $params["Uri"] += $AttributeSetId } if($null -ne $PSBoundParameters["Description"]) { diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAttributeSet.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAttributeSet.md index 77b9fa05d..268a74a1c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAttributeSet.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAttributeSet.md @@ -34,7 +34,7 @@ Get-EntraAttributeSet ```powershell Get-EntraAttributeSet - -Id + -AttributeSetId [] ``` @@ -73,7 +73,7 @@ This example returns all attribute sets. ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' -Get-EntraAttributeSet -Id 'Testing' +Get-EntraAttributeSet -AttributeSetId 'Testing' ``` ```Output @@ -84,11 +84,11 @@ Testing Attributes for engineering team 10 This example demonstrates how to retrieve an attribute set by Id. -- `Id` parameter specifies the unique identifier for the attribute set within a tenant. +- `AttributeSetId` parameter specifies the unique identifier for the attribute set within a tenant. ## Parameters -### -Id +### -AttributeSetId Unique identifier for the attribute set within a tenant. @@ -97,7 +97,7 @@ This identifier can be up to 32 characters long and may include Unicode characte ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAuditSignInLog.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAuditSignInLog.md index d56ec818a..d8b69d850 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAuditSignInLog.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAuditSignInLog.md @@ -26,6 +26,7 @@ Get audit logs of sign-ins. ```powershell Get-EntraAuditSignInLog + [-SignInId] [-All] [-Top ] [-Filter ] @@ -106,6 +107,22 @@ This example shows how to retrieve sign-in logs between dates. ## Parameters +### -SignInId + +Specifies unique ID of the Audit Log. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: Id + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -All List all pages. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraAttributeSet.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraAttributeSet.md index 49b2d2435..34d42b229 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraAttributeSet.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraAttributeSet.md @@ -26,7 +26,7 @@ Adds a new attribute set. ```powershell New-EntraAttributeSet - [-Id ] + [-AttributeSetId ] [-Description ] [-MaxAttributesPerSet ] [] @@ -45,7 +45,7 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Testing' + AttributeSetId = 'NewCustomAttributeSet' Description = 'Attributes for engineering team' MaxAttributesPerSet = 10 } @@ -83,14 +83,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -AttributeSetId Name of the attribute set. Unique identifier for the attribute set within a tenant, up to 32 Unicode characters. It can't contain spaces or special characters, is case sensitive, and can't be changed later. Required. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: False Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md index 15c557b7e..1ccf1dfd3 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md @@ -26,15 +26,19 @@ Updates an existing attribute set. ```powershell Set-EntraAttributeSet - -Id + -AttributeSetId [-Description ] [-MaxAttributesPerSet ] [] ``` -## Description +## DESCRIPTION -Updates a Microsoft Entra ID attribute set object identified by ID. Specify `Id` parameter to update an attribute set. +The `Set-EntraAttributeSet` cmdlet updates a Microsoft Entra ID attribute set object specified by its ID. Specify `AttributeSetId` parameter to Update a Microsoft Entra ID attribute set object. + +In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. + +Note: Only the Attribute Definition Administrator role is supported for this operation. Ensure the signed-in user is assigned this role. You can only update the `description` and `maxAttributesPerSet` properties. @@ -47,31 +51,31 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Engineering' - Description = 'Attributes for engineering team' + AttributeSetId = 'Engineering' + Description = 'Attributes for cloud engineering team' } Set-EntraAttributeSet @params ``` This example update an attribute set. -- `Id` parameter specifies the name of the attribute set. You can `Get-EntraAttributeSet` to get more details. -- `Description` parameter specifies the description for the attribute set. +- `-AttributeSetId` parameter specifies the name of the attribute set. You can `Get-EntraAttributeSet` to get more details. +- `-Description` parameter specifies the description for the attribute set. ### Example 2: Update an attribute set using MaxAttributesPerSet ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Engineering' - MaxAttributesPerSet = 10 + AttributeSetId = 'Engineering' + MaxAttributesPerSet = 10 } Set-EntraAttributeSet @params ``` This example update an attribute set using MaxAttributesPerSet. -- `-Id` parameter specifies the name of the attribute set. You can `Get-EntraAttributeSet` to get more details. +- `-AttributeSetId` parameter specifies the name of the attribute set. You can `Get-EntraAttributeSet` to get more details. - `-MaxAttributesPerSet` parameter specifies the maximum number of custom security attributes. ## Parameters @@ -92,14 +96,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -AttributeSetId Name of the attribute set. Unique identifier for the attribute set within a tenant. This identifier can be up to 32 characters long and may include Unicode characters. It cannot contain spaces or special characters, and it cannot be changed later. The identifier is case insensitive. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/Entra/Get-EntraAttributeSet.Tests.ps1 b/test/module/Entra/Get-EntraAttributeSet.Tests.ps1 index 7e076eb4e..69bf952e6 100644 --- a/test/module/Entra/Get-EntraAttributeSet.Tests.ps1 +++ b/test/module/Entra/Get-EntraAttributeSet.Tests.ps1 @@ -24,29 +24,36 @@ BeforeAll { Describe "Get-EntraAttributeSet" { Context "Test for Get-EntraAttributeSet" { It "Should return AttributeSets with any parameter" { - $result = Get-EntraAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return specific AttributeSet" { + $result = Get-EntraAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific AttributeSet with alias" { $result = Get-EntraAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is invalid" { - { Get-EntraAttributeSet -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when AttributeSetId is invalid" { + { Get-EntraAttributeSet -AttributeSetId "" } | Should -Throw "Cannot bind argument to parameter 'AttributeSetId' because it is an empty string." } - It "Should fail when Id is empty" { - { Get-EntraAttributeSet -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when AttributeSetId is empty" { + { Get-EntraAttributeSet -AttributeSetId } | Should -Throw "Missing an argument for parameter 'AttributeSetId'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAttributeSet" - Get-EntraAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" | Out-Null + Get-EntraAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Out-Null Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue $true @@ -60,7 +67,7 @@ Describe "Get-EntraAttributeSet" { try { # Act & Assert: Ensure the function doesn't throw an exception { - Get-EntraAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug + Get-EntraAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference diff --git a/test/module/Entra/Get-EntraAuditSignInLog.Tests.ps1 b/test/module/Entra/Get-EntraAuditSignInLog.Tests.ps1 index bd5e819e7..57a0dab03 100644 --- a/test/module/Entra/Get-EntraAuditSignInLog.Tests.ps1 +++ b/test/module/Entra/Get-EntraAuditSignInLog.Tests.ps1 @@ -48,13 +48,19 @@ BeforeAll { Describe "Get-EntraAuditSignInLog" { Context "Test for Get-EntraAuditSignInLog" { It "Should return specific Audit SignIn Logs" { + $result = Get-EntraAuditSignInLog -SignInId "bbbbbbbb-1111-2222-3333-cccccccccc22" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccc22' + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific Audit SignIn Logs with alias" { $result = Get-EntraAuditSignInLog -Id "bbbbbbbb-1111-2222-3333-cccccccccc22" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccc22' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraAuditSignInLog -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when SignInId is empty" { + { Get-EntraAuditSignInLog -SignInId } | Should -Throw "Missing an argument for parameter 'SignInId'*" } It "Should fail when filter is empty" { { Get-EntraAuditSignInLog -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" @@ -86,13 +92,13 @@ Describe "Get-EntraAuditSignInLog" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should contain ID in parameters when passed Id to it" { - $result = Get-EntraAuditSignInLog -Id "bbbbbbbb-1111-2222-3333-cccccccccc22" + $result = Get-EntraAuditSignInLog -SignInId "bbbbbbbb-1111-2222-3333-cccccccccc22" $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc22" } It "Should contain 'User-Agent' header" { Mock -CommandName Invoke-GraphRequest -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAuditSignInLog" - $result = Get-EntraAuditSignInLog -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraAuditSignInLog -SignInId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -106,7 +112,7 @@ Describe "Get-EntraAuditSignInLog" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraAuditSignInLog -Id "bbbbbbbb-1111-2222-3333-cccccccccc22" -Debug } | Should -Not -Throw + { Get-EntraAuditSignInLog -SignInId "bbbbbbbb-1111-2222-3333-cccccccccc22" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/New-EntraAttributeSet.Tests.ps1 b/test/module/Entra/New-EntraAttributeSet.Tests.ps1 index 8688a6b2f..766a84f56 100644 --- a/test/module/Entra/New-EntraAttributeSet.Tests.ps1 +++ b/test/module/Entra/New-EntraAttributeSet.Tests.ps1 @@ -25,6 +25,15 @@ BeforeAll { Describe "New-EntraAttributeSet" { Context "Test for New-EntraAttributeSet" { It "Should return created AttributeSet" { + $result = New-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "NewCustomAttributeSet" + $result.MaxAttributesPerSet | should -Be 125 + $result.Description | should -Be "CustomAttributeSet" + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return created AttributeSet with alias" { $result = New-EntraAttributeSet -Id "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "NewCustomAttributeSet" @@ -33,8 +42,8 @@ Describe "New-EntraAttributeSet" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id parameter is invalid" { - { New-EntraAttributeSet -Id } | Should -Throw "Missing an argument for parameter 'Id*" + It "Should fail when AttributeSetId parameter is invalid" { + { New-EntraAttributeSet -AttributeSetId } | Should -Throw "Missing an argument for parameter 'AttributeSetId*" } It "Should fail when Description parameter is empty" { { New-EntraAttributeSet -Description } | Should -Throw "Missing an argument for parameter 'Description*" @@ -48,7 +57,7 @@ Describe "New-EntraAttributeSet" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraAttributeSet" - New-EntraAttributeSet -Id "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 | Out-Null + New-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 | Out-Null Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue $true @@ -62,7 +71,7 @@ Describe "New-EntraAttributeSet" { try { # Act & Assert: Ensure the function doesn't throw an exception { - New-EntraAttributeSet -Id "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 -Debug + New-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference diff --git a/test/module/Entra/Set-EntraAttributeSet.Tests.ps1 b/test/module/Entra/Set-EntraAttributeSet.Tests.ps1 index 49eb858d7..5d6aaf317 100644 --- a/test/module/Entra/Set-EntraAttributeSet.Tests.ps1 +++ b/test/module/Entra/Set-EntraAttributeSet.Tests.ps1 @@ -14,13 +14,19 @@ BeforeAll { Describe "Set-EntraAttributeSet" { Context "Test for Set-EntraAttributeSet" { It "Should return created AttributeSet" { + $result = Set-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return created AttributeSet with alias" { $result = Set-EntraAttributeSet -Id "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id parameter is empty" { - { Set-EntraAttributeSet -Id } | Should -Throw "Missing an argument for parameter 'Id*" + It "Should fail when AttributeSetId parameter is empty" { + { Set-EntraAttributeSet -AttributeSetId } | Should -Throw "Missing an argument for parameter 'AttributeSetId*" } It "Should fail when Description parameter is empty" { { Set-EntraAttributeSet -Description } | Should -Throw "Missing an argument for parameter 'Description*" @@ -34,11 +40,26 @@ Describe "Set-EntraAttributeSet" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraAttributeSet" - Set-EntraAttributeSet -Id "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 | Out-Null + Set-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 | Out-Null Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue $true } - } + } + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { + Set-EntraAttributeSet -AttributeSetId "NewCustomAttributeSet" -Description "CustomAttributeSet" -MaxAttributesPerSet 125 -Debug + } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } } } \ No newline at end of file From 6569c0b2bcbe9d6670f0faf2cf615c8f3be61628 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 16:06:44 +0530 Subject: [PATCH 20/64] Usability-Parameters --- test/module/Entra/Get-EntraUser.Tests.ps1 | 7 ------- .../Entra/Remove-EntraApplication.Tests.ps1 | 6 ++++++ test/module/Entra/Remove-EntraUser.Tests.ps1 | 21 ++++++++++++------- .../Entra/Set-EntraApplication.Tests.ps1 | 7 ++++++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/test/module/Entra/Get-EntraUser.Tests.ps1 b/test/module/Entra/Get-EntraUser.Tests.ps1 index 06d9a23ed..0adfba7ce 100644 --- a/test/module/Entra/Get-EntraUser.Tests.ps1 +++ b/test/module/Entra/Get-EntraUser.Tests.ps1 @@ -38,13 +38,6 @@ BeforeAll { "MobilePhone" = $null } - # Response from an Invoke-GraphRequest is a hashtable with @odata.context and Value objects - - # Name Value - # ---- ----- - # @odata.context https://graph.microsoft.com/v1.0/$metadata#users - # value {System.Collections.Hashtable, System.Collections.Hashtable, System.Collections.Hasht... - $response = @{ '@odata.context' = 'Users()' Value = $valueObject diff --git a/test/module/Entra/Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Remove-EntraApplication.Tests.ps1 index e8e900625..d671c82f0 100644 --- a/test/module/Entra/Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplication.Tests.ps1 @@ -19,6 +19,12 @@ Describe "Remove-EntraApplication" { Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Remove-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when ApplicationId is invalid" { { Remove-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } diff --git a/test/module/Entra/Remove-EntraUser.Tests.ps1 b/test/module/Entra/Remove-EntraUser.Tests.ps1 index dcf0024e3..0e32a3f9c 100644 --- a/test/module/Entra/Remove-EntraUser.Tests.ps1 +++ b/test/module/Entra/Remove-EntraUser.Tests.ps1 @@ -15,27 +15,32 @@ BeforeAll { Describe "Remove-EntraUser" { Context "Test for Remove-EntraUser" { It "Should return empty object" { + $result = Remove-EntraUser -UserId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgUser -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific user with Alias" { $result = Remove-EntraUser -ObjectId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgUser -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string" { - { Remove-EntraUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string" { + { Remove-EntraUser -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Remove-EntraUser -ObjectId } | Should -Throw "Missing an argument for parameter*" + It "Should fail when UserId is empty" { + { Remove-EntraUser -UserId } | Should -Throw "Missing an argument for parameter*" } - It "Should contain Id in parameters when passed ObjectId to it" { + It "Should contain Id in parameters when passed UserId to it" { Mock -CommandName Remove-MgUser -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraUser -ObjectId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" + $result = Remove-EntraUser -UserId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.userId | Should -Be "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraUser" - Remove-EntraUser -ObjectId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" + Remove-EntraUser -UserId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraUser" @@ -51,7 +56,7 @@ Describe "Remove-EntraUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraUser -ObjectId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Remove-EntraUser -UserId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraApplication.Tests.ps1 b/test/module/Entra/Set-EntraApplication.Tests.ps1 index e8be20df4..123bcb480 100644 --- a/test/module/Entra/Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Set-EntraApplication.Tests.ps1 @@ -14,12 +14,17 @@ BeforeAll { Describe "Set-EntraApplication"{ Context "Test for Set-EntraApplication" { It "Should return empty object"{ - $result = Set-EntraApplication -ApplicationId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" $result = Set-EntraApplication -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" -DisplayName "Mock-App" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific user with Alias" { + $result = Set-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when ApplicationId is invalid" { { Set-EntraApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } From 519fe1a56436097e6a9807df9ac40146c9355e46 Mon Sep 17 00:00:00 2001 From: v-uansari <143997438+v-uansari@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:26:55 +0530 Subject: [PATCH 21/64] Parameter Name change Additional function (#1075) * Alice changes * alice updates * doc changes * Alice Added * ut change * doc changes * doc chagnes * doc cahgnes --- entra-powershell | 1 + .../Add-EntraAdministrativeUnitMember.ps1 | 7 ++- .../Add-EntraScopedRoleMembership.ps1 | 9 +-- .../Get-EntraAdministrativeUnit.ps1 | 61 ++++++++++--------- .../Get-EntraAdministrativeUnitMember.ps1 | 22 ++++--- .../Get-EntraScopedRoleMembership.ps1 | 7 ++- .../Remove-EntraAdministrativeUnit.ps1 | 7 ++- .../Remove-EntraAdministrativeUnitMember.ps1 | 9 +-- .../Remove-EntraScopedRoleMembership.ps1 | 7 ++- .../Set-EntraAdministrativeUnit.ps1 | 7 ++- .../Get-EntraDeletedApplication.ps1 | 2 +- .../Add-EntraAdministrativeUnitMember.md | 12 ++-- .../Add-EntraScopedRoleMembership.md | 12 ++-- .../Get-EntraAdministrativeUnit.md | 12 ++-- .../Get-EntraAdministrativeUnitMember.md | 32 +++++----- .../Get-EntraScopedRoleMembership.md | 12 ++-- .../Remove-EntraAdministrativeUnit.md | 10 +-- .../Remove-EntraAdministrativeUnitMember.md | 12 ++-- .../Remove-EntraScopedRoleMembership.md | 10 +-- .../Set-EntraAdministrativeUnit.md | 16 ++--- ...dd-EntraAdministrativeUnitMember.Tests.ps1 | 20 +++--- .../Add-EntraScopedRoleMembership.Tests.ps1 | 26 ++++---- .../Get-EntraAdministrativeUnit.Tests.ps1 | 18 ++++-- ...et-EntraAdministrativeUnitMember.Tests.ps1 | 19 +++--- .../Get-EntraScopedRoleMembership.Tests.ps1 | 22 ++++--- .../Remove-EntraAdministrativeUnit.Tests.ps1 | 14 ++--- ...ve-EntraAdministrativeUnitMember.Tests.ps1 | 17 ++++-- ...Remove-EntraScopedRoleMembership.Tests.ps1 | 19 +++--- .../Set-EntraAdministrativeUnit.Tests.ps1 | 19 +++--- 29 files changed, 248 insertions(+), 193 deletions(-) create mode 160000 entra-powershell diff --git a/entra-powershell b/entra-powershell new file mode 160000 index 000000000..9d4e2e265 --- /dev/null +++ b/entra-powershell @@ -0,0 +1 @@ +Subproject commit 9d4e2e2656cbe75b6558e2034153f95bda85ec11 diff --git a/module/Entra/AdditionalFunctions/Add-EntraAdministrativeUnitMember.ps1 b/module/Entra/AdditionalFunctions/Add-EntraAdministrativeUnitMember.ps1 index 60ff8523c..f4522dfbf 100644 --- a/module/Entra/AdditionalFunctions/Add-EntraAdministrativeUnitMember.ps1 +++ b/module/Entra/AdditionalFunctions/Add-EntraAdministrativeUnitMember.ps1 @@ -6,16 +6,17 @@ function Add-EntraAdministrativeUnitMember { param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $RefObjectId, + [Alias('ObjectId')] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId + [System.String] $AdministrativeUnitId ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] $Uri = "/v1.0/directory/administrativeUnits/$($params.AdministrativeUnitId)/members/" + '$ref' } if($null -ne $PSBoundParameters["RefObjectId"]) diff --git a/module/Entra/AdditionalFunctions/Add-EntraScopedRoleMembership.ps1 b/module/Entra/AdditionalFunctions/Add-EntraScopedRoleMembership.ps1 index c98b25f99..1b0b769be 100644 --- a/module/Entra/AdditionalFunctions/Add-EntraScopedRoleMembership.ps1 +++ b/module/Entra/AdditionalFunctions/Add-EntraScopedRoleMembership.ps1 @@ -3,9 +3,10 @@ # ------------------------------------------------------------------------------ function Add-EntraScopedRoleMembership { [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] - param ( + param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $AdministrativeUnitId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $RoleObjectId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -17,9 +18,9 @@ function Add-EntraScopedRoleMembership { $body = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] $Uri = "/v1.0/directory/administrativeUnits/$($params.AdministrativeUnitId)/scopedRoleMembers" } if($null -ne $PSBoundParameters["RoleObjectId"]) diff --git a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 index ad9673a5a..849b52436 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 @@ -4,41 +4,42 @@ function Get-EntraAdministrativeUnit { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( - [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, - [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Int32] $Top, - [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [switch] $All, - [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Filter + [Alias("ObjectId")] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter ) PROCESS { - $params = @{} - $topCount = $null - $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $baseUri = "/v1.0/directory/administrativeUnits" - $properties = '$select=*' - $params["Uri"] = "$baseUri/?$properties" - if ($null -ne $PSBoundParameters["ObjectId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] - $params["Uri"] = "$baseUri/$($params.AdministrativeUnitId)?$properties" + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + $baseUri = "/v1.0/directory/administrativeUnits" + $properties = '$select=*' + $params["Uri"] = "$baseUri/?$properties" + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) + { + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] + $params["Uri"] = "$baseUri/$($params.AdministrativeUnitId)?$properties" + } + if ($PSBoundParameters.ContainsKey("Top")) { + $topCount = $PSBoundParameters["Top"] + if ($topCount -gt 999) { + $params["Uri"] += "&`$top=999" } - if ($PSBoundParameters.ContainsKey("Top")) { - $topCount = $PSBoundParameters["Top"] - if ($topCount -gt 999) { - $params["Uri"] += "&`$top=999" - } - else { - $params["Uri"] += "&`$top=$topCount" - } - } - if ($null -ne $PSBoundParameters["Filter"]) { - $Filter = $PSBoundParameters["Filter"] - $f = '$' + 'Filter' - $params["Uri"] += "&$f=$Filter" + else { + $params["Uri"] += "&`$top=$topCount" } + } + if ($null -ne $PSBoundParameters["Filter"]) { + $Filter = $PSBoundParameters["Filter"] + $f = '$' + 'Filter' + $params["Uri"] += "&$f=$Filter" + } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug diff --git a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 index 0007a082d..7bb91f323 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 @@ -3,23 +3,25 @@ # ------------------------------------------------------------------------------ function Get-EntraAdministrativeUnitMember { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] - param ( - [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Int32] $Top, - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, - [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [switch] $All + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias("ObjectId")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All ) PROCESS { $params = @{} $topCount = $null $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $baseUri = "/v1.0/directory/administrativeUnits/$ObjectId/members?`$select=*" + $baseUri = "/v1.0/directory/administrativeUnits/$AdministrativeUnitId/members?`$select=*" $params["Uri"] = "$baseUri" - if ($null -ne $PSBoundParameters["ObjectId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) + { + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if ($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] diff --git a/module/Entra/AdditionalFunctions/Get-EntraScopedRoleMembership.ps1 b/module/Entra/AdditionalFunctions/Get-EntraScopedRoleMembership.ps1 index bb1be8800..3324e6a0b 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraScopedRoleMembership.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraScopedRoleMembership.ps1 @@ -4,8 +4,9 @@ function Get-EntraScopedRoleMembership { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $AdministrativeUnitId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ScopedRoleMembershipId ) @@ -15,9 +16,9 @@ function Get-EntraScopedRoleMembership { $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $isList = $false $baseUri = "https://graph.microsoft.com/v1.0/directory/administrativeUnits" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] $uri = $baseUri + "/$($params.AdministrativeUnitId)/scopedRoleMembers" $params["Uri"] = $uri $isList = $true diff --git a/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnit.ps1 b/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnit.ps1 index 6ac11fe9f..2812f2fe1 100644 --- a/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnit.ps1 +++ b/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnit.ps1 @@ -4,16 +4,17 @@ function Remove-EntraAdministrativeUnit { [CmdletBinding(DefaultParameterSetName = '')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId + [System.String] $AdministrativeUnitId ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } Write-Debug("============================ TRANSFORMATIONS ============================") diff --git a/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnitMember.ps1 b/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnitMember.ps1 index fdfcd21d0..f8daf219e 100644 --- a/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnitMember.ps1 +++ b/module/Entra/AdditionalFunctions/Remove-EntraAdministrativeUnitMember.ps1 @@ -4,8 +4,9 @@ function Remove-EntraAdministrativeUnitMember { [CmdletBinding(DefaultParameterSetName = '')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $AdministrativeUnitId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $MemberId ) @@ -13,9 +14,9 @@ function Remove-EntraAdministrativeUnitMember { PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($null -ne $PSBoundParameters["MemberId"]) { @@ -26,7 +27,7 @@ function Remove-EntraAdministrativeUnitMember { $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") - $uri = "/v1.0/directory/administrativeUnits/$ObjectId/members/$MemberId/`$ref" + $uri = "/v1.0/directory/administrativeUnits/$AdministrativeUnitId/members/$MemberId/`$ref" $params["Uri"] = $uri $response = Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method DELETE diff --git a/module/Entra/AdditionalFunctions/Remove-EntraScopedRoleMembership.ps1 b/module/Entra/AdditionalFunctions/Remove-EntraScopedRoleMembership.ps1 index 30640e1a7..9aca2cd2b 100644 --- a/module/Entra/AdditionalFunctions/Remove-EntraScopedRoleMembership.ps1 +++ b/module/Entra/AdditionalFunctions/Remove-EntraScopedRoleMembership.ps1 @@ -4,8 +4,9 @@ function Remove-EntraScopedRoleMembership { [CmdletBinding(DefaultParameterSetName = '')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $AdministrativeUnitId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ScopedRoleMembershipId ) @@ -13,9 +14,9 @@ function Remove-EntraScopedRoleMembership { PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($null -ne $PSBoundParameters["ScopedRoleMembershipId"]) { diff --git a/module/Entra/AdditionalFunctions/Set-EntraAdministrativeUnit.ps1 b/module/Entra/AdditionalFunctions/Set-EntraAdministrativeUnit.ps1 index 1eb234695..dc9b7c703 100644 --- a/module/Entra/AdditionalFunctions/Set-EntraAdministrativeUnit.ps1 +++ b/module/Entra/AdditionalFunctions/Set-EntraAdministrativeUnit.ps1 @@ -4,8 +4,9 @@ function Set-EntraAdministrativeUnit { [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] param ( + [Alias("ObjectId")] [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [System.String] $AdministrativeUnitId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.String] $Description, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -17,9 +18,9 @@ function Set-EntraAdministrativeUnit { $body = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($null -ne $PSBoundParameters["DisplayName"]) { diff --git a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 index 2b354a2da..8172f09ef 100644 --- a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 +++ b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 @@ -109,7 +109,7 @@ 'PublisherDomain','Web','RequiredResourceAccess') foreach ($prop in $propsToConvert) { - $value = $_.$prop | ConvertTo-Json -Depth 5 | ConvertFrom-Json + $value = $_.$prop | ConvertTo-Json -Depth 10 | ConvertFrom-Json $_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force } diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraAdministrativeUnitMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraAdministrativeUnitMember.md index 49221e320..4fd404ec5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraAdministrativeUnitMember.md @@ -28,7 +28,7 @@ Adds an administrative unit member. ```powershell Add-EntraAdministrativeUnitMember -RefObjectId - -ObjectId + -AdministrativeUnitId [] ``` @@ -47,9 +47,9 @@ To add a user, group, or device to an administrative unit, the calling principal ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -$User = Get-EntraUser -ObjectId 'SawyerM@contoso.com' +$User = Get-EntraUser -UserId 'SawyerM@contoso.com' $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId RefObjectId = $User.ObjectId } Add-EntraAdministrativeUnitMember @params @@ -57,19 +57,19 @@ Add-EntraAdministrativeUnitMember @params This example shows how to add an administrative unit member. You can use the command `Get-EntraAdministrativeUnit` to get administrative unit ID. You can use the command `Get-EntraUser` to get user ID. -- `ObjectId` parameter specifies the ID of an administrative unit. +- `AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `RefObjectId` parameter specifies the ID of the user or group you want to add as a member of the administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of a Microsoft Entra ID administrative unit. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraScopedRoleMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraScopedRoleMembership.md index bfb05607c..6366a197c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraScopedRoleMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraScopedRoleMembership.md @@ -25,7 +25,7 @@ Assign a Microsoft Entra role with an administrative unit scope. ```powershell Add-EntraScopedRoleMembership - -ObjectId + -AdministrativeUnitId [-RoleObjectId ] [-RoleMemberInfo ] [] @@ -33,7 +33,7 @@ Add-EntraScopedRoleMembership ## Description -The `Add-EntraScopedRoleMembership` cmdlet adds a scoped role membership to an administrative unit. Specify `ObjectId` parameter to add a scoped role membership. +The `Add-EntraScopedRoleMembership` cmdlet adds a scoped role membership to an administrative unit. Specify `AdministrativeUnitId` parameter to add a scoped role membership. For delegated scenarios, the calling user needs at least the Privileged Role Administrator Microsoft Entra role. @@ -49,7 +49,7 @@ $Unit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ' + -AdministrativeUnitId [-All] [-Property ] [] @@ -46,7 +46,7 @@ Get-EntraAdministrativeUnit ## Description -The `Get-EntraAdministrativeUnit` cmdlet gets a Microsoft Entra ID administrative unit. Specify `ObjectID` parameter to get a specific administrative unit. +The `Get-EntraAdministrativeUnit` cmdlet gets a Microsoft Entra ID administrative unit. Specify `AdministrativeUnitId` parameter to get a specific administrative unit. ## Examples @@ -92,7 +92,7 @@ This command gets all the administrative units. ```powershell Connect-Entra -Scopes 'AdministrativeUnit.Read.All' -Get-EntraAdministrativeUnit -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraAdministrativeUnit -AdministrativeUnitId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -103,7 +103,7 @@ DeletedDateTime Id Description Disp This example returns the details of the specified administrative unit. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ### Example 4: Get administrative units filter by display name @@ -170,14 +170,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md index 2ebecd5c9..89c854462 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md @@ -27,7 +27,7 @@ Gets a member of an administrative unit. ```powershell Get-EntraAdministrativeUnitMember - -ObjectId + -AdministrativeUnitId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraAdministrativeUnitMember ## Description -The `Get-EntraAdministrativeUnitMember` cmdlet gets a member of a Microsoft Entra ID administrative unit. Specify `ObjectId` parameters to retrieve an administrative unit member. +The `Get-EntraAdministrativeUnitMember` cmdlet gets a member of a Microsoft Entra ID administrative unit. Specify `AdministrativeUnitId` parameters to retrieve an administrative unit member. In delegated scenarios with work or school accounts, the signed-in user must either be a member user or be assigned a supported Microsoft Entra role, or a custom role with the necessary permissions. The following least privileged roles are supported for this operation: @@ -46,12 +46,12 @@ In delegated scenarios with work or school accounts, the signed-in user must eit ## Examples -### Example 1: Get an administrative unit member by ObjectId +### Example 1: Get an administrative unit member by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId ``` ```Output @@ -64,16 +64,16 @@ eeeeeeee-4444-5555-6666-ffffffffffff ffffffff-5555-6666-7777-aaaaaaaaaaaa ``` -This example returns the list of administrative unit members from specified administrative unit ObjectId. +This example returns the list of administrative unit members from specified administrative unit AdministrativeUnitId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. -### Example 2: Get all administrative unit members by ObjectId +### Example 2: Get all administrative unit members by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId -All +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -All ``` ```Output @@ -86,16 +86,16 @@ eeeeeeee-4444-5555-6666-ffffffffffff ffffffff-5555-6666-7777-aaaaaaaaaaaa ``` -This example returns the list of all administrative unit members from specified administrative unit ObjectId. +This example returns the list of all administrative unit members from specified administrative unit AdministrativeUnitId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. -### Example 3: Get top three administrative unit members by ObjectId +### Example 3: Get top three administrative unit members by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId -Top 3 +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -Top 3 ``` ```Output @@ -106,20 +106,20 @@ cccccccc-2222-3333-4444-dddddddddddd dddddddd-3333-4444-5555-eeeeeeeeeeee ``` -This example returns top three administrative unit members from specified administrative unit ObjectId. +This example returns top three administrative unit members from specified administrative unit AdministrativeUnitId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraScopedRoleMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraScopedRoleMembership.md index 00911b68d..57698577c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraScopedRoleMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraScopedRoleMembership.md @@ -25,7 +25,7 @@ List Microsoft Entra role assignments with administrative unit scope. ```powershell Get-EntraScopedRoleMembership - -ObjectId + -AdministrativeUnitId [-ScopedRoleMembershipId ] [-Property ] [] @@ -43,7 +43,7 @@ The `Get-EntraScopedRoleMembership` cmdlet lists Microsoft Entra role assignment Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId ScopedRoleMembershipId = 'dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc' } Get-EntraScopedRoleMembership @params @@ -57,7 +57,7 @@ dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc aaaaaaaa-bbbb-aaaa-bbbb-cccccccccccc bb This example gets scoped role administrator. You cane use the command `Get-EntraAdministrativeUnit` to get administrative unit Id. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `-ScopedRoleMembershipId` parameter specifies the scoped role membership Id. ### Example 2: List scoped administrators for administrative unit by ObjectId @@ -76,18 +76,18 @@ dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc aaaaaaaa-bbbb-aaaa-bbbb-cccccccccccc bb This example list scoped administrators with objectId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnit.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnit.md index 6659339b0..667a07b71 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnit.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnit.md @@ -26,13 +26,13 @@ Removes an administrative unit. ```powershell Remove-EntraAdministrativeUnit - -ObjectId + -AdministrativeUnitId [] ``` ## Description -The `Remove-EntraAdministrativeUnit` cmdlet removes an administrative unit from Microsoft Entra ID. Specify `ObjectId` parameter to delete an administrative unit. +The `Remove-EntraAdministrativeUnit` cmdlet removes an administrative unit from Microsoft Entra ID. Specify `AdministrativeUnitId` parameter to delete an administrative unit. To delete an administrative unit, the calling principal must have at least the Privileged Role Administrator role in Microsoft Entra. @@ -48,18 +48,18 @@ Remove-EntraAdministrativeUnit -ObjectId $AdministrativeUnit.ObjectId This command removes the specified administrative unit from Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnitMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnitMember.md index b925dc3a6..f0c10bc69 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraAdministrativeUnitMember.md @@ -25,14 +25,14 @@ Removes an administrative unit member. ```powershell Remove-EntraAdministrativeUnitMember - -ObjectId + -AdministrativeUnitId -MemberId [] ``` ## Description -The `Remove-EntraAdministrativeUnitMember` cmdlet removes an administrative unit member in Microsoft Entra ID. Specify `ObjectId` and `MemberId` to remove an administrative unit member. +The `Remove-EntraAdministrativeUnitMember` cmdlet removes an administrative unit member in Microsoft Entra ID. Specify `AdministrativeUnitId` and `MemberId` to remove an administrative unit member. To remove a member from an administrative unit, the calling principal must have at least the Privileged Role Administrator role in Microsoft Entra. @@ -44,7 +44,7 @@ To remove a member from an administrative unit, the calling principal must have Connect-Entra -Scopes 'AdministrativeUnit.Read.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId MemberId = 'eeeeeeee-4444-5555-6666-ffffffffffff' } Remove-EntraAdministrativeUnitMember @params @@ -52,7 +52,7 @@ Remove-EntraAdministrativeUnitMember @params This command removes a specified member (user or group) from a specified administrative unit. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `-MemberId` parameter specifies the ID of the administrative unit member. ## Parameters @@ -73,14 +73,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md index f33bff875..49e2fd174 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md @@ -27,7 +27,7 @@ Removes a scoped role membership. ```powershell Remove-EntraScopedRoleMembership - -ObjectId + -AdministrativeUnitId -ScopedRoleMembershipId [] ``` @@ -44,7 +44,7 @@ The `Remove-EntraScopedRoleMembership` cmdlet removes a scoped role membership f Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId ScopedRoleMembershipId = 'dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc' } Remove-EntraScopedRoleMembership @params @@ -52,19 +52,19 @@ Remove-EntraScopedRoleMembership @params This cmdlet removes a specific scoped role membership from Microsoft Entra ID. You can use the command `Get-EntraAdministrativeUnit` to get administrative unit Id. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `-ScopedRoleMembershipId` parameter specifies the ID of the scoped role membership to remove. To obtain the details of a scoped role membership, you can use the `Get-EntraScopedRoleMembership` command. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAdministrativeUnit.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAdministrativeUnit.md index 834fb8e15..08ce3f467 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAdministrativeUnit.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAdministrativeUnit.md @@ -26,7 +26,7 @@ Updates an administrative unit. ```powershell Set-EntraAdministrativeUnit - -ObjectId + -AdministrativeUnitId [-Description ] [-DisplayName ] [] @@ -34,7 +34,7 @@ Set-EntraAdministrativeUnit ## Description -The `Set-EntraAdministrativeUnit` cmdlet updates an administrative unit in Microsoft Entra ID. Specify `Id` parameter to update a specific administrative unit. +The `Set-EntraAdministrativeUnit` cmdlet updates an administrative unit in Microsoft Entra ID. Specify `AdministrativeUnitId` parameter to update a specific administrative unit. In delegated scenarios, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with the `microsoft.directory/administrativeUnits/allProperties/allTasks` permission. @@ -48,7 +48,7 @@ The Privileged Role Administrator is the least privileged role required for this Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId DisplayName = 'UpdatedAU' } Set-EntraAdministrativeUnit @params @@ -56,7 +56,7 @@ Set-EntraAdministrativeUnit @params This Command update DisplayName of specific administrative unit. -- `-ObjectId` parameter specifies the Id of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the Id of an administrative unit. - `-DisplayName` parameter specifies the display name for the administrative unit. ### Example 2: Update Description @@ -65,7 +65,7 @@ This Command update DisplayName of specific administrative unit. Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId Description = 'Updated AU Description' } Set-EntraAdministrativeUnit @params @@ -73,7 +73,7 @@ Set-EntraAdministrativeUnit @params This example shows how to update the description of a specific administrative unit. -- `-ObjectId` parameter specifies the Id of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the Id of an administrative unit. - `-Description` parameter specifies the description for the administrative unit. ## Parameters @@ -110,14 +110,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -AdministrativeUnitId Specifies the Id of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 index aef06b5ed..724b1dc81 100644 --- a/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 @@ -12,15 +12,20 @@ BeforeAll { } Describe "Add-EntraAdministrativeUnitMember tests"{ It "Should return empty object"{ - $result = Add-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraAdministrativeUnitMember -AdministrativeUnitId "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with ObjectId"{ + $result = Add-EntraAdministrativeUnitMember -ObjectId "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ObjectId is empty"{ - { Add-EntraAdministrativeUnitMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + { Add-EntraAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" } It "Should fail when ObjectId is null"{ - { Add-EntraAdministrativeUnitMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Add-EntraAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" } It "Should fail when RefObjectId is empty"{ { Add-EntraAdministrativeUnitMember -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId'*" @@ -35,10 +40,9 @@ Describe "Add-EntraAdministrativeUnitMember tests"{ $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraAdministrativeUnitMember" Add-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraAdministrativeUnitMember" - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } + $result = Add-EntraAdministrativeUnitMember -AdministrativeUnitId "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } It "Should execute successfully without throwing an error " { # Disable confirmation prompts @@ -47,7 +51,7 @@ Describe "Add-EntraAdministrativeUnitMember tests"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraAdministrativeUnitMember -AdministrativeUnitId "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Add-EntraScopedRoleMembership.Tests.ps1 b/test/module/Entra/Add-EntraScopedRoleMembership.Tests.ps1 index 06de04aef..0a57839a9 100644 --- a/test/module/Entra/Add-EntraScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Add-EntraScopedRoleMembership.Tests.ps1 @@ -33,16 +33,22 @@ BeforeAll{ } Describe "Tests for Add-EntraScopedRoleMembership"{ It "Result should not be empty"{ + $result = Add-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('NewDummyId') + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty with ObjectId"{ $result = Add-EntraScopedRoleMembership -ObjectId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('NewDummyId') Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Add-EntraScopedRoleMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is invalid" { + { Add-EntraScopedRoleMembership -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is empty" { - { Add-EntraScopedRoleMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Add-EntraScopedRoleMembership -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when RoleMemberInfo is invalid" { { Add-EntraScopedRoleMembership -RoleMemberInfo "" } | Should -Throw "Cannot process argument transformation on parameter 'RoleMemberInfo'*" @@ -55,12 +61,10 @@ Describe "Tests for Add-EntraScopedRoleMembership"{ } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraScopedRoleMembership" - Add-EntraScopedRoleMembership -ObjectId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraScopedRoleMembership" - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } + $result = Add-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember + $params = Get-Parameters -data $result.Parameters + $a= $params | ConvertTo-json | ConvertFrom-Json + $a.headers.'User-Agent' | Should -Be $userAgentHeaderValue } It "Should execute successfully without throwing an error " { # Disable confirmation prompts @@ -69,7 +73,7 @@ Describe "Tests for Add-EntraScopedRoleMembership"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraScopedRoleMembership -ObjectId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember -Debug } | Should -Not -Throw + { Add-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -RoleObjectId $roleObjId -RoleMemberInfo $RoleMember -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 b/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 index a792f54af..aed997974 100644 --- a/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 @@ -25,15 +25,25 @@ BeforeAll{ } Describe "Tests for Get-EntraAdministrativeUnit"{ It "Result should not be empty"{ + $result = Get-EntraAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty objectid"{ + $result = Get-EntraAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty objectid"{ $result = Get-EntraAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraAdministrativeUnit -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraAdministrativeUnit -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Get-EntraAdministrativeUnit -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when All has an argument" { { Get-EntraAdministrativeUnit -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" diff --git a/test/module/Entra/Get-EntraAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Get-EntraAdministrativeUnitMember.Tests.ps1 index d8e467484..d947363ac 100644 --- a/test/module/Entra/Get-EntraAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Get-EntraAdministrativeUnitMember.Tests.ps1 @@ -25,15 +25,20 @@ BeforeAll{ } Describe "Tests for Get-EntraAdministrativeUnitMember"{ It "Result should not be empty"{ + $result = Get-EntraAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty objectId"{ $result = Get-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraAdministrativeUnitMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraAdministrativeUnitMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Get-EntraAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when All has an argument" { { Get-EntraAdministrativeUnitMember -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" @@ -48,14 +53,14 @@ Describe "Tests for Get-EntraAdministrativeUnitMember"{ { Get-EntraAdministrativeUnitMember -xyz } | Should -Throw "A parameter cannot be found that matches parameter name 'xyz'*" } It "Should return top AdministrativeUnit" { - $result = @(Get-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1) + $result = @(Get-EntraAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1) $result | Should -Not -BeNullOrEmpty $result | Should -HaveCount 1 Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAdministrativeUnitMember" - $result = Get-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Get-EntraAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAdministrativeUnitMember" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -70,7 +75,7 @@ Describe "Tests for Get-EntraAdministrativeUnitMember"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1 -Debug } | Should -Not -Throw + { Get-EntraAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1 -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraScopedRoleMembership.Tests.ps1 b/test/module/Entra/Get-EntraScopedRoleMembership.Tests.ps1 index 532a72c5f..3785667f1 100644 --- a/test/module/Entra/Get-EntraScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Get-EntraScopedRoleMembership.Tests.ps1 @@ -32,6 +32,14 @@ BeforeAll{ } Describe "Tests for Get-EntraScopedRoleMembership"{ It "Result should not be empty"{ + $result = Get-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId + $result | Should -Not -BeNullOrEmpty + $result.ObjectId | should -Be $scopedRoleMembershipId + $result.AdministrativeUnitObjectId | should -Be $unitObjId + $result.RoleObjectId | should -Be $roleObjId + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty with ObjectId"{ $result = Get-EntraScopedRoleMembership -ObjectId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId $result | Should -Not -BeNullOrEmpty $result.ObjectId | should -Be $scopedRoleMembershipId @@ -39,21 +47,21 @@ Describe "Tests for Get-EntraScopedRoleMembership"{ $result.RoleObjectId | should -Be $roleObjId Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Get-EntraScopedRoleMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is invalid" { + { Get-EntraScopedRoleMembership -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is empty" { - { Get-EntraScopedRoleMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraScopedRoleMembership -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when ScopedRoleMembershipId is empty" { - { Get-EntraScopedRoleMembership -ObjectId $unitObjId -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" + { Get-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" } It "Should fail when invalid parameter is passed" { { Get-EntraScopedRoleMembership -xyz } | Should -Throw "A parameter cannot be found that matches parameter name 'xyz'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraScopedRoleMembership" - $result = Get-EntraScopedRoleMembership -ObjectId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId + $result = Get-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraScopedRoleMembership" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -68,7 +76,7 @@ Describe "Tests for Get-EntraScopedRoleMembership"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraScopedRoleMembership -ObjectId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId -Debug } | Should -Not -Throw + { Get-EntraScopedRoleMembership -AdministrativeUnitId $unitObjId -ScopedRoleMembershipId $scopedRoleMembershipId -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraAdministrativeUnit.Tests.ps1 b/test/module/Entra/Remove-EntraAdministrativeUnit.Tests.ps1 index f7fafd23f..45b889cd9 100644 --- a/test/module/Entra/Remove-EntraAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Remove-EntraAdministrativeUnit.Tests.ps1 @@ -12,15 +12,15 @@ BeforeAll { Describe "Test for Remove-EntraAdministrativeUnit" { It "Should return empty object" { - $result = Remove-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" + $result = Remove-EntraAdministrativeUnit -AdministrativeUnitId bbbbbbbb-1111-1111-1111-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraAdministrativeUnit -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Remove-EntraAdministrativeUnit -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Remove-EntraAdministrativeUnit -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when invalid parameter is passed" { { Remove-EntraAdministrativeUnit -xyz } | Should -Throw "A parameter cannot be found that matches parameter name 'xyz'*" @@ -28,7 +28,7 @@ Describe "Test for Remove-EntraAdministrativeUnit" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraAdministrativeUnit" - Remove-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" + Remove-EntraAdministrativeUnit -AdministrativeUnitId "bbbbbbbb-1111-1111-1111-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraAdministrativeUnit" @@ -44,7 +44,7 @@ Describe "Test for Remove-EntraAdministrativeUnit" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraAdministrativeUnit -AdministrativeUnitId "bbbbbbbb-1111-1111-1111-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Remove-EntraAdministrativeUnitMember.Tests.ps1 index 34c42621d..7a05bd315 100644 --- a/test/module/Entra/Remove-EntraAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Remove-EntraAdministrativeUnitMember.Tests.ps1 @@ -15,15 +15,20 @@ BeforeAll { Describe "Test for Remove-EntraAdministrativeUnitMember" { It "Should return empty object" { + $result = Remove-EntraAdministrativeUnitMember -AdministrativeUnitId $auId -MemberId $memId + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with ObjectId" { $result = Remove-EntraAdministrativeUnitMember -ObjectId $auId -MemberId $memId $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraAdministrativeUnitMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Remove-EntraAdministrativeUnitMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Remove-EntraAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when MemberId is empty" { { Remove-EntraAdministrativeUnitMember -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId'*" @@ -37,7 +42,7 @@ Describe "Test for Remove-EntraAdministrativeUnitMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraAdministrativeUnitMember" - Remove-EntraAdministrativeUnitMember -ObjectId $auId -MemberId $memId + Remove-EntraAdministrativeUnitMember -AdministrativeUnitId $auId -MemberId $memId $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraAdministrativeUnitMember" @@ -53,7 +58,7 @@ Describe "Test for Remove-EntraAdministrativeUnitMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraAdministrativeUnitMember -ObjectId $auId -MemberId $memId -Debug } | Should -Not -Throw + { Remove-EntraAdministrativeUnitMember -AdministrativeUnitId $auId -MemberId $memId -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraScopedRoleMembership.Tests.ps1 b/test/module/Entra/Remove-EntraScopedRoleMembership.Tests.ps1 index 2a1e63972..52a70a536 100644 --- a/test/module/Entra/Remove-EntraScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Remove-EntraScopedRoleMembership.Tests.ps1 @@ -12,15 +12,20 @@ BeforeAll { Describe "Test for Remove-EntraScopedRoleMembership" { It "Should return empty object" { - $result = Remove-EntraScopedRoleMembership -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -ScopedRoleMembershipId "bbbbbbbb-2222-2222-2222-cccccccccccc" + $result = Remove-EntraScopedRoleMembership -AdministrativeUnitId bbbbbbbb-1111-1111-1111-cccccccccccc -ScopedRoleMembershipId bbbbbbbb-2222-2222-2222-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraScopedRoleMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should return empty object with ObjectId" { + $result = Remove-EntraScopedRoleMembership -ObjectId bbbbbbbb-1111-1111-1111-cccccccccccc -ScopedRoleMembershipId bbbbbbbb-2222-2222-2222-cccccccccccc + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraScopedRoleMembership -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Remove-EntraScopedRoleMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Remove-EntraScopedRoleMembership -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when ScopedRoleMembershipId is empty" { { Remove-EntraScopedRoleMembership -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter 'ScopedRoleMembershipId'*" @@ -34,7 +39,7 @@ Describe "Test for Remove-EntraScopedRoleMembership" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraScopedRoleMembership" - Remove-EntraScopedRoleMembership -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -ScopedRoleMembershipId "bbbbbbbb-2222-2222-2222-cccccccccccc" + Remove-EntraScopedRoleMembership -AdministrativeUnitId "bbbbbbbb-1111-1111-1111-cccccccccccc" -ScopedRoleMembershipId "bbbbbbbb-2222-2222-2222-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraScopedRoleMembership" @@ -50,7 +55,7 @@ Describe "Test for Remove-EntraScopedRoleMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraScopedRoleMembership -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -ScopedRoleMembershipId "bbbbbbbb-2222-2222-2222-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraScopedRoleMembership -AdministrativeUnitId "bbbbbbbb-1111-1111-1111-cccccccccccc" -ScopedRoleMembershipId "bbbbbbbb-2222-2222-2222-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 b/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 index dc624a57e..0542f54fd 100644 --- a/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 @@ -12,24 +12,27 @@ BeforeAll { Describe "Test for Set-EntraAdministrativeUnit" { It "Should return empty object" { - $result = Set-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -DisplayName "test" -Description "test" + $result = Set-EntraAdministrativeUnit -AdministrativeUnitId bbbbbbbb-1111-1111-1111-cccccccccccc -DisplayName "test" -Description "test" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraAdministrativeUnit -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should return empty object withObjectID" { + $result = Set-EntraAdministrativeUnit -ObjectId bbbbbbbb-1111-1111-1111-cccccccccccc -DisplayName "test" -Description "test" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when AdministrativeUnitId is empty" { + { Set-EntraAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null" { - { Set-EntraAdministrativeUnit -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null" { + { Set-EntraAdministrativeUnit -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when invalid parameter is passed" { { Set-EntraAdministrativeUnit -xyz } | Should -Throw "A parameter cannot be found that matches parameter name 'xyz'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraAdministrativeUnit" - Set-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -DisplayName "test" -Description "test" - - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraAdministrativeUnit" + Set-EntraAdministrativeUnit -AdministrativeUnitId bbbbbbbb-1111-1111-1111-cccccccccccc -DisplayName "test" -Description "test" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue $true From 010d79b32fb1c9bbe933be4064e5bf3bb511a7c6 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 17:40:54 +0530 Subject: [PATCH 22/64] updated UT --- .../Entra/Get-EntraApplication.Tests.ps1 | 2 +- .../Get-EntraGroupLifecyclePolicy.Tests.ps1 | 27 ++++++++++-------- test/module/Entra/Get-EntraUser.Tests.ps1 | 2 +- .../Entra/Remove-EntraApplication.Tests.ps1 | 2 +- .../module/Entra/Remove-EntraDevice.Tests.ps1 | 4 +-- test/module/Entra/Remove-EntraGroup.Tests.ps1 | 4 +-- ...Remove-EntraGroupLifecyclePolicy.Tests.ps1 | 23 +++++++++------ test/module/Entra/Remove-EntraUser.Tests.ps1 | 2 +- .../Entra/Set-EntraApplication.Tests.ps1 | 2 +- test/module/Entra/Set-EntraDevice.Tests.ps1 | 4 +-- test/module/Entra/Set-EntraGroup.Tests.ps1 | 2 +- .../Set-EntraGroupLifecyclePolicy.Tests.ps1 | 28 +++++++++++-------- .../EntraBeta/Get-EntraBetaUser.Tests.ps1 | 2 +- 13 files changed, 59 insertions(+), 45 deletions(-) diff --git a/test/module/Entra/Get-EntraApplication.Tests.ps1 b/test/module/Entra/Get-EntraApplication.Tests.ps1 index bb310d27c..8bf55a00a 100644 --- a/test/module/Entra/Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplication.Tests.ps1 @@ -141,7 +141,7 @@ Describe "Get-EntraApplication" { $DebugPreference = $originalDebugPreference } } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Get-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" Write-Verbose "Result : {$result}" -Verbose $result | Should -Not -BeNullOrEmpty diff --git a/test/module/Entra/Get-EntraGroupLifecyclePolicy.Tests.ps1 b/test/module/Entra/Get-EntraGroupLifecyclePolicy.Tests.ps1 index fb829c351..5a4be8d3d 100644 --- a/test/module/Entra/Get-EntraGroupLifecyclePolicy.Tests.ps1 +++ b/test/module/Entra/Get-EntraGroupLifecyclePolicy.Tests.ps1 @@ -34,9 +34,14 @@ Describe "Get-EntraGroupLifecyclePolicy" { Should -Invoke -CommandName Get-MgGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should execute successfully with Alias" { + $result = Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.GroupLifetimeInDays | Should -Be 200 + } It "Retrieve properties of an groupLifecyclePolicy" { - $result = Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $result.ObjectId | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' $result.GroupLifetimeInDays | Should -Be 200 @@ -47,22 +52,22 @@ Describe "Get-EntraGroupLifecyclePolicy" { Should -Invoke -CommandName Get-MgGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraGroupLifecyclePolicy -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupLifecyclePolicyId is empty" { + { Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'*" } - It "Should fail when Id is invalid" { - { Get-EntraGroupLifecyclePolicy -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string." } - It "Should contain GroupLifecyclePolicyId in parameters when passed Id to it" { - $result = Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain GroupLifecyclePolicyId in parameters when passed GroupLifecyclePolicyId to it" { + $result = Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result.Parameters $params.GroupLifecyclePolicyId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } It "Property parameter should work" { - $result = Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id + $result = Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -70,13 +75,13 @@ Describe "Get-EntraGroupLifecyclePolicy" { } It "Should fail when Property is empty" { - { Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupLifecyclePolicy" - $result = Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupLifecyclePolicy" @@ -94,7 +99,7 @@ Describe "Get-EntraGroupLifecyclePolicy" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Get-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUser.Tests.ps1 b/test/module/Entra/Get-EntraUser.Tests.ps1 index 0adfba7ce..d6639e7c8 100644 --- a/test/module/Entra/Get-EntraUser.Tests.ps1 +++ b/test/module/Entra/Get-EntraUser.Tests.ps1 @@ -62,7 +62,7 @@ Describe "Get-EntraUser" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Get-EntraUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" Write-Verbose "Result : {$result}" -Verbose $result | Should -Not -BeNullOrEmpty diff --git a/test/module/Entra/Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Remove-EntraApplication.Tests.ps1 index d671c82f0..a33ff613a 100644 --- a/test/module/Entra/Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplication.Tests.ps1 @@ -19,7 +19,7 @@ Describe "Remove-EntraApplication" { Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Remove-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty diff --git a/test/module/Entra/Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Remove-EntraDevice.Tests.ps1 index dd15c7e24..2f35c0eb0 100644 --- a/test/module/Entra/Remove-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDevice.Tests.ps1 @@ -19,8 +19,8 @@ Describe "Remove-EntraDevice" { Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { - $result = Remove-EntraDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc + It "Should execute successfully with Alias" { + $result = Remove-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 diff --git a/test/module/Entra/Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Remove-EntraGroup.Tests.ps1 index 1f39fdb55..af0e821d6 100644 --- a/test/module/Entra/Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroup.Tests.ps1 @@ -19,8 +19,8 @@ Describe "Remove-EntraGroup" { Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { - $result = Remove-EntraGroup -GroupId bbbbbbbb-1111-2222-3333-cccccccccccc + It "Should execute successfully with Alias" { + $result = Remove-EntraGroup -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 diff --git a/test/module/Entra/Remove-EntraGroupLifecyclePolicy.Tests.ps1 b/test/module/Entra/Remove-EntraGroupLifecyclePolicy.Tests.ps1 index 96969534b..7b3b2ce2d 100644 --- a/test/module/Entra/Remove-EntraGroupLifecyclePolicy.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroupLifecyclePolicy.Tests.ps1 @@ -13,24 +13,29 @@ BeforeAll { Describe "Remove-EntraGroupLifecyclePolicy" { Context "Test for Remove-EntraGroupLifecyclePolicy" { It "Should remove a groupLifecyclePolicies" { - $result = Remove-EntraGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should execute successfully with Alias" { + $result = Remove-EntraGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result | Should -BeNullOrEmpty - It "Should fail when Id is empty" { - { Remove-EntraGroupLifecyclePolicy -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + Should -Invoke -CommandName Remove-MgGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when GroupLifecyclePolicyId is empty" { + { Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraGroupLifecyclePolicy -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string." } - It "Should contain GroupLifecyclePolicyId in parameters when passed Id to it" { + It "Should contain GroupLifecyclePolicyId in parameters when passed GroupLifecyclePolicyId to it" { Mock -CommandName Remove-MgGroupLifecyclePolicy -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $params = Get-Parameters -data $result $params.GroupLifecyclePolicyId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } @@ -38,7 +43,7 @@ Describe "Remove-EntraGroupLifecyclePolicy" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupLifecyclePolicy" - Remove-EntraGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupLifecyclePolicy" @@ -54,7 +59,7 @@ Describe "Remove-EntraGroupLifecyclePolicy" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw + { Remove-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraUser.Tests.ps1 b/test/module/Entra/Remove-EntraUser.Tests.ps1 index 0e32a3f9c..3c839bb1c 100644 --- a/test/module/Entra/Remove-EntraUser.Tests.ps1 +++ b/test/module/Entra/Remove-EntraUser.Tests.ps1 @@ -19,7 +19,7 @@ Describe "Remove-EntraUser" { $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgUser -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Remove-EntraUser -ObjectId "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgUser -ModuleName Microsoft.Graph.Entra -Times 1 diff --git a/test/module/Entra/Set-EntraApplication.Tests.ps1 b/test/module/Entra/Set-EntraApplication.Tests.ps1 index 123bcb480..b53209e2a 100644 --- a/test/module/Entra/Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Set-EntraApplication.Tests.ps1 @@ -19,7 +19,7 @@ Describe "Set-EntraApplication"{ Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Set-EntraApplication -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -DisplayName "Mock-App" $result | Should -BeNullOrEmpty diff --git a/test/module/Entra/Set-EntraDevice.Tests.ps1 b/test/module/Entra/Set-EntraDevice.Tests.ps1 index 23ff8cba4..12381be3e 100644 --- a/test/module/Entra/Set-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Set-EntraDevice.Tests.ps1 @@ -19,8 +19,8 @@ Describe "Set-EntraDevice"{ Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { - $result = Set-EntraDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + It "Should execute successfully with Alias" { + $result = Set-EntraDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 diff --git a/test/module/Entra/Set-EntraGroup.Tests.ps1 b/test/module/Entra/Set-EntraGroup.Tests.ps1 index 40327b50e..fdc0ad991 100644 --- a/test/module/Entra/Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Set-EntraGroup.Tests.ps1 @@ -19,7 +19,7 @@ Describe "Set-EntraGroup" { Should -Invoke -CommandName Update-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Set-EntraGroup -Id bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" $result | Should -BeNullOrEmpty diff --git a/test/module/Entra/Set-EntraGroupLifecyclePolicy.Tests.ps1 b/test/module/Entra/Set-EntraGroupLifecyclePolicy.Tests.ps1 index de87873ed..cfd361dfc 100644 --- a/test/module/Entra/Set-EntraGroupLifecyclePolicy.Tests.ps1 +++ b/test/module/Entra/Set-EntraGroupLifecyclePolicy.Tests.ps1 @@ -25,7 +25,7 @@ BeforeAll { Describe "Set-EntraGroupLifecyclePolicy" { Context "Test for Set-EntraGroupLifecyclePolicy" { It "Should return updated GroupLifecyclePolicy" { - $result = Set-EntraGroupLifecyclePolicy -Id "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result = Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" $result.GroupLifetimeInDays | should -Be "100" @@ -34,32 +34,36 @@ Describe "Set-EntraGroupLifecyclePolicy" { Should -Invoke -CommandName Update-MgGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is invalid" { - { Set-EntraGroupLifecyclePolicy -Id "" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string.*" + It "Should execute successfully with Alias" { + $result = Set-EntraGroupLifecyclePolicy -Id "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result | Should -Not -BeNullOrEmpty } - It "Should fail when Id is empty" { - { Set-EntraGroupLifecyclePolicy -Id -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'Id'.*" + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string.*" + } + It "Should fail when GroupLifecyclePolicyId is empty" { + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'.*" } It "Should fail when GroupLifetimeInDays is invalid" { - { Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot process argument transformation on parameter 'GroupLifetimeInDays'.*" + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot process argument transformation on parameter 'GroupLifetimeInDays'.*" } It "Should fail when GroupLifetimeInDays is empty" { - { Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'GroupLifetimeInDays'.*" + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'GroupLifetimeInDays'.*" } It "Should fail when ManagedGroupTypes is empty" { - { Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'ManagedGroupTypes'.*" + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'ManagedGroupTypes'.*" } It "Should fail when AlternateNotificationEmails is empty" { - { Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes "Selected" -AlternateNotificationEmails } | Should -Throw "Missing an argument for parameter 'AlternateNotificationEmails'.*" + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes "Selected" -AlternateNotificationEmails } | Should -Throw "Missing an argument for parameter 'AlternateNotificationEmails'.*" } It "Result should Contain ObjectId" { - $result = Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result = Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" $result.ObjectId | should -Be "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroupLifecyclePolicy" - $result = Set-EntraGroupLifecyclePolicy -Id "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result = Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroupLifecyclePolicy" @@ -76,7 +80,7 @@ Describe "Set-EntraGroupLifecyclePolicy" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraGroupLifecyclePolicy -Id "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" -Debug } | Should -Not -Throw + { Set-EntraGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 index 30e788419..07f2beff0 100644 --- a/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUser.Tests.ps1 @@ -166,7 +166,7 @@ Describe "Get-EntraBetaUser" { $DebugPreference = $originalDebugPreference } } - It "Should return specific user with Alias" { + It "Should execute successfully with Alias" { $result = Get-EntraBetaUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" Write-Verbose "Result : {$result}" -Verbose $result | Should -Not -BeNullOrEmpty From 8963ad64ac2b8776e9a8a7b4dbd18263aaa2f0a1 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 18:35:10 +0530 Subject: [PATCH 23/64] updated UT --- .../Remove-EntraDeletedDirectoryObject.ps1 | 13 ++++++++++--- .../Remove-EntraDeletedDirectoryObject.md | 12 ++++++------ src/CompatibilityAdapterBuilder.ps1 | 1 - ...move-EntraDeletedDirectoryObject.Tests.ps1 | 19 +++++++++++++------ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/module/Entra/customizations/Remove-EntraDeletedDirectoryObject.ps1 b/module/Entra/customizations/Remove-EntraDeletedDirectoryObject.ps1 index 7bd155e14..605e7ab77 100644 --- a/module/Entra/customizations/Remove-EntraDeletedDirectoryObject.ps1 +++ b/module/Entra/customizations/Remove-EntraDeletedDirectoryObject.ps1 @@ -7,17 +7,24 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("Id")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DirectoryObjectId + ) + PROCESS { $params = @{} $Method = "DELETE" $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if ($null -ne $PSBoundParameters["Id"]) { - $params["Id"] = $PSBoundParameters["Id"] + if ($null -ne $PSBoundParameters["DirectoryObjectId"]) { + $params["DirectoryObjectId"] = $PSBoundParameters["DirectoryObjectId"] } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") - $URI = "https://graph.microsoft.com/v1.0/directory/deletedItems/$Id" + $URI = "https://graph.microsoft.com/v1.0/directory/deletedItems/$DirectoryObjectId" $response = Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method $Method $response } diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md index 8027629db..f9ca99482 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md @@ -27,7 +27,7 @@ Permanently delete a previously deleted directory object. ```powershell Remove-EntraDeletedDirectoryObject - -Id + -DirectoryObjectId [] ``` @@ -50,18 +50,18 @@ For delegated scenarios, the calling user needs to have at least one of the foll ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Group.ReadWrite.All','Application.ReadWrite.All','User.ReadWrite.All' -Remove-EntraDeletedDirectoryObject -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraDeletedDirectoryObject -DirectoryObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` -This example demonstrates how to permanently delete a previously deleted directory object by Id. +This example demonstrates how to permanently delete a previously deleted directory object by DirectoryObjectId. -- `-Id` parameter specifies the Id of the directory object that is permanently deleted. +- `-DirectoryObjectId` parameter specifies the Id of the directory object that is permanently deleted. ## Parameters -### -Id +### -DirectoryObjectId -The Id of the directory object that is permanently deleted. +The DirectoryObjectId of the directory object that is permanently deleted. ```yaml Type: System.String diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 60acd65e7..7041245a4 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -42,7 +42,6 @@ class CompatibilityAdapterBuilder { 'Set-EntraUserThumbnailPhoto', 'Reset-EntraLifeCycleGroup', 'Get-EntraObjectByObjectId', - 'Get-EntraGroupPermissionGrant', 'Remove-EntraPermissionGrantConditionSet', 'Get-EntraPermissionGrantPolicy', 'Remove-EntraOAuth2PermissionGrant', diff --git a/test/module/Entra/Remove-EntraDeletedDirectoryObject.Tests.ps1 b/test/module/Entra/Remove-EntraDeletedDirectoryObject.Tests.ps1 index 96dbd6e26..854eef784 100644 --- a/test/module/Entra/Remove-EntraDeletedDirectoryObject.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDeletedDirectoryObject.Tests.ps1 @@ -13,24 +13,31 @@ BeforeAll { Describe "Remove-EntraDeletedDirectoryObject" { Context "Test for Remove-EntraDeletedDirectoryObject" { It "Should delete a previously deleted directory object" { + $result = Remove-EntraDeletedDirectoryObject -DirectoryObjectId "11112222-bbbb-3333-cccc-4444dddd5555" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should execute successfully with Alias" { $result = Remove-EntraDeletedDirectoryObject -Id "11112222-bbbb-3333-cccc-4444dddd5555" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Remove-EntraDeletedDirectoryObject -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when DirectoryObjectId is empty" { + { Remove-EntraDeletedDirectoryObject -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraDeletedDirectoryObject -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when DirectoryObjectId is invalid" { + { Remove-EntraDeletedDirectoryObject -DirectoryObjectId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId' because it is an empty string." } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeletedDirectoryObject" - Remove-EntraDeletedDirectoryObject -Id "11112222-bbbb-3333-cccc-4444dddd5555" + Remove-EntraDeletedDirectoryObject -DirectoryObjectId "11112222-bbbb-3333-cccc-4444dddd5555" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeletedDirectoryObject" @@ -46,7 +53,7 @@ Describe "Remove-EntraDeletedDirectoryObject" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDeletedDirectoryObject -Id "11112222-bbbb-3333-cccc-4444dddd5555" -Debug } | Should -Not -Throw + { Remove-EntraDeletedDirectoryObject -DirectoryObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 6a90bd71b80c287a55ea7021882c84177d97af7a Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 25 Sep 2024 18:57:05 +0530 Subject: [PATCH 24/64] added condition --- src/CompatibilityAdapterBuilder.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 60acd65e7..cd04dfa3a 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -948,6 +948,8 @@ $OutputTransformations elseif([TransformationTypes]::Name -eq $param.ConversionType){ if(($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $param.TargetName){ $paramBlock = $this.GetParameterTransformationName($param.TargetName, $param.TargetName) + }else{ + $paramBlock = $this.GetParameterTransformationName($param.Name, $param.TargetName) } } elseif([TransformationTypes]::Bool2Switch -eq $param.ConversionType){ From 30605bfd2abe6cece9f0253ff3df0f3fd7c64c38 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 21:08:50 +0530 Subject: [PATCH 25/64] updated UT --- ...ntraApplicationExtensionProperty.Tests.ps1 | 28 +++++++++------ .../Entra/Get-EntraDirectoryRole.Tests.ps1 | 7 ++++ .../Entra/Get-EntraServicePrincipal.Tests.ps1 | 36 +++++++++++-------- ...traServicePrincipalKeyCredential.Tests.ps1 | 24 ++++++++----- ...ntraApplicationExtensionProperty.Tests.ps1 | 26 ++++++++------ .../Remove-EntraIdentityProvider.Tests.ps1 | 20 +++++++---- .../Remove-EntraServicePrincipal.Tests.ps1 | 22 +++++++----- 7 files changed, 104 insertions(+), 59 deletions(-) diff --git a/test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 index f9e7189c4..e66987f5b 100644 --- a/test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 @@ -25,39 +25,45 @@ BeforeAll { Describe "Get-EntraApplicationExtensionProperty" { Context "Test for Get-EntraApplicationExtensionProperty" { It "Should not return empty" { + $result = Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraApplicationExtensionProperty -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is empty" { + { Get-EntraApplicationExtensionProperty -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Result should Contain ObjectId" { - $result = Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" + It "Result should Contain ApplicationId" { + $result = Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" $result.ObjectId | should -Be "aaaaaaaa-1111-2222-3333-ccccccccccc" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "aaaaaaaa-1111-2222-3333-ccccccccccc" } It "Property parameter should work" { - $result = Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property Name + $result = Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property Name $result | Should -Not -BeNullOrEmpty $result.Name | Should -Be 'extension_222_324_NewAttribute' Should -Invoke -CommandName Get-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should fail when Property is empty" { - { Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationExtensionProperty" - $result = Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" + $result = Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationExtensionProperty" Should -Invoke -CommandName Get-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -72,7 +78,7 @@ BeforeAll { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 index cc5ba45db..f07dd363c 100644 --- a/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 @@ -36,6 +36,13 @@ BeforeAll { Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should execute successfully with Alias" { + $result = Get-EntraDirectoryRole -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should fail when DirectoryRoleId is empty" { { Get-EntraDirectoryRole -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } diff --git a/test/module/Entra/Get-EntraServicePrincipal.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipal.Tests.ps1 index 9c1179e42..4396f3ef2 100644 --- a/test/module/Entra/Get-EntraServicePrincipal.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipal.Tests.ps1 @@ -77,6 +77,14 @@ BeforeAll { Describe "Get-EntraServicePrincipal" { Context "Test for Get-EntraServicePrincipal" { It "Should return specific service" { + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should execute successfully with Alias" { $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -84,12 +92,12 @@ Describe "Get-EntraServicePrincipal" { Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipal -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipal -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraServicePrincipal -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is invalid" { + { Get-EntraServicePrincipal -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should return all service" { @@ -118,8 +126,8 @@ Describe "Get-EntraServicePrincipal" { { Get-EntraServicePrincipal -Top XY} | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } @@ -147,13 +155,13 @@ Describe "Get-EntraServicePrincipal" { { Get-EntraServicePrincipal -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } @@ -165,7 +173,7 @@ Describe "Get-EntraServicePrincipal" { } It "Property parameter should work" { - $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property DisplayName + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be "Windows Update for Business Deployment Service" @@ -173,12 +181,12 @@ Describe "Get-EntraServicePrincipal" { } It "Should fail when Property is empty" { - { Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipal" - $result = Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipal" @@ -196,7 +204,7 @@ Describe "Get-EntraServicePrincipal" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraServicePrincipal -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Get-EntraServicePrincipal -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalKeyCredential.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalKeyCredential.Tests.ps1 index 5467edb61..906c9d0a0 100644 --- a/test/module/Entra/Get-EntraServicePrincipalKeyCredential.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalKeyCredential.Tests.ps1 @@ -32,25 +32,33 @@ Describe "Get-EntraServicePrincipalKeyCredential" { Context "Test for Get-EntraServicePrincipalKeyCredential" { It "Should return specific principal key credential" { $objectId = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" - $result = Get-EntraServicePrincipalKeyCredential -ObjectId $objectId + $result = Get-EntraServicePrincipalKeyCredential -ServicePrincipalId $objectId $result | Should -Not -BeNullOrEmpty $result.KeyId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { + It "Should update the parameter with Alias" { + $objectId = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraServicePrincipalKeyCredential -ObjectId $objectId + $result | Should -Not -BeNullOrEmpty + $result.KeyId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + + Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ServicePrincipalId is empty" { $errorActionPreference = "Stop" - { Get-EntraServicePrincipalKeyCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraServicePrincipalKeyCredential -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is invalid" { + It "Should fail when ServicePrincipalId is invalid" { $errorActionPreference = "Stop" - { Get-EntraServicePrincipalKeyCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraServicePrincipalKeyCredential -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalKeyCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalKeyCredential -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $servicePrincipalKeyCredential = $result | ConvertTo-Json -Depth 10 | ConvertFrom-Json $params = Get-Parameters -data $servicePrincipalKeyCredential.Parameters $params.ServicePrincipalId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -59,7 +67,7 @@ Describe "Get-EntraServicePrincipalKeyCredential" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalKeyCredential" - $result = Get-EntraServicePrincipalKeyCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraServicePrincipalKeyCredential -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalKeyCredential" diff --git a/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 index 6f14c9b02..6e6e9e216 100644 --- a/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Remove-EntraApplicationExtensionProperty" { Context "Test for Remove-EntraApplicationExtensionProperty" { It "Should return empty object" { + $result = Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraApplicationExtensionProperty -ObjectId -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444"} | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Remove-EntraApplicationExtensionProperty -ApplicationId -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444"} | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraApplicationExtensionProperty -ObjectId "" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is invalid" { + { Remove-EntraApplicationExtensionProperty -ApplicationId "" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } It "Should fail when ExtensionPropertyId is empty" { - { Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId } | Should -Throw "Missing an argument for parameter 'ExtensionPropertyId'*" + { Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId } | Should -Throw "Missing an argument for parameter 'ExtensionPropertyId'*" } It "Should fail when ExtensionPropertyId is invalid" { - { Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "" } | Should -Throw "Cannot bind argument to parameter 'ExtensionPropertyId' because it is an empty string." + { Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "" } | Should -Throw "Cannot bind argument to parameter 'ExtensionPropertyId' because it is an empty string." } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Remove-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationExtensionProperty" - Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" + Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationExtensionProperty" @@ -56,7 +62,7 @@ Describe "Remove-EntraApplicationExtensionProperty" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw + { Remove-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ExtensionPropertyId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraIdentityProvider.Tests.ps1 b/test/module/Entra/Remove-EntraIdentityProvider.Tests.ps1 index 1901a35fd..f90f8909f 100644 --- a/test/module/Entra/Remove-EntraIdentityProvider.Tests.ps1 +++ b/test/module/Entra/Remove-EntraIdentityProvider.Tests.ps1 @@ -14,28 +14,34 @@ BeforeAll { Describe "Remove-EntraIdentityProvider" { Context "Test for Remove-EntraIdentityProvider" { It "Should return empty object" { + $result = Remove-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgIdentityProvider -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraIdentityProvider -Id "Google-OAUTH" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgIdentityProvider -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Id is empty" { - { Remove-EntraIdentityProvider -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + { Remove-EntraIdentityProvider -IdentityProviderBaseId } | Should -Throw "Missing an argument for parameter 'IdentityProviderBaseId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraIdentityProvider -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when IdentityProviderBaseId is invalid" { + { Remove-EntraIdentityProvider -IdentityProviderBaseId "" } | Should -Throw "Cannot bind argument to parameter 'IdentityProviderBaseId' because it is an empty string." } - It "Should contain IdentityProviderBaseId in parameters when passed Id to it" { + It "Should contain IdentityProviderBaseId in parameters when passed IdentityProviderBaseId to it" { Mock -CommandName Remove-MgIdentityProvider -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraIdentityProvider -Id "Google-OAUTH" + $result = Remove-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $params = Get-Parameters -data $result $params.IdentityProviderBaseId | Should -Be "Google-OAUTH" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraIdentityProvider" - Remove-EntraIdentityProvider -Id "Google-OAUTH" + Remove-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraIdentityProvider" @@ -51,7 +57,7 @@ Context "Test for Remove-EntraIdentityProvider" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraIdentityProvider -Id "Google-OAUTH" -Debug } | Should -Not -Throw + { Remove-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraServicePrincipal.Tests.ps1 b/test/module/Entra/Remove-EntraServicePrincipal.Tests.ps1 index 83cfdb698..cf6f3f935 100644 --- a/test/module/Entra/Remove-EntraServicePrincipal.Tests.ps1 +++ b/test/module/Entra/Remove-EntraServicePrincipal.Tests.ps1 @@ -12,21 +12,25 @@ BeforeAll { Describe "Remove-EntraServicePrincipal" { Context "Test for Remove-EntraServicePrincipal" { It "Should return empty object" { + $result = Remove-EntraServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Remove-EntraServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 } - - It "Should fail when ObjectId is empty" { - { Remove-EntraServicePrincipal -ObjectId }| Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Remove-EntraServicePrincipal -ServicePrincipalId }| Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraServicePrincipal -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is invalid" { + { Remove-EntraServicePrincipal -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { Mock -CommandName Remove-MgServicePrincipal -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" @@ -34,7 +38,7 @@ Describe "Remove-EntraServicePrincipal" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipal" - Remove-EntraServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Remove-EntraServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipal" @@ -51,7 +55,7 @@ Describe "Remove-EntraServicePrincipal" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 49c879dda3a6a3f52e08ae1171018cae23eb4334 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 22:03:18 +0530 Subject: [PATCH 26/64] updated UT --- .../Add-EntraServicePrincipalOwner.Tests.ps1 | 28 ++++++++++------- ...-EntraServicePrincipalMembership.Tests.ps1 | 31 +++++++++++-------- ...cePrincipalOAuth2PermissionGrant.tests.ps1 | 31 +++++++++++-------- .../Get-EntraServicePrincipalOwner.Tests.ps1 | 31 +++++++++++-------- ...rvicePrincipalPasswordCredential.Tests.ps1 | 23 +++++++++----- ...rvicePrincipalPasswordCredential.Tests.ps1 | 28 ++++++++++------- ...emove-EntraServicePrincipalOwner.Tests.ps1 | 28 ++++++++++------- ...rvicePrincipalPasswordCredential.Tests.ps1 | 24 ++++++++------ 8 files changed, 135 insertions(+), 89 deletions(-) diff --git a/test/module/Entra/Add-EntraServicePrincipalOwner.Tests.ps1 b/test/module/Entra/Add-EntraServicePrincipalOwner.Tests.ps1 index 71d6ff2a4..1fb3b6e4c 100644 --- a/test/module/Entra/Add-EntraServicePrincipalOwner.Tests.ps1 +++ b/test/module/Entra/Add-EntraServicePrincipalOwner.Tests.ps1 @@ -13,32 +13,38 @@ BeforeAll { Describe "Add-EntraServicePrincipalOwner" { Context "Test for Add-EntraServicePrincipalOwner" { It "Should return empty object" { + $result = Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgServicePrincipalOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgServicePrincipalOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraServicePrincipalOwner -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Add-EntraServicePrincipalOwner -ServicePrincipalId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraServicePrincipalOwner -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is invalid" { + { Add-EntraServicePrincipalOwner -ServicePrincipalId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { Mock -CommandName New-MgServicePrincipalOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } It "Should contain BodyParameter in parameters when passed RefObjectId to it" { - Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $value = @{"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbbbbb-1111-2222-3333-cccccccccccc"} Should -Invoke -CommandName New-MgServicePrincipalOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $BodyParameter.AdditionalProperties.'@odata.id' | Should -Be $value.'@odata.id' @@ -49,7 +55,7 @@ Describe "Add-EntraServicePrincipalOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraServicePrincipalOwner" - Add-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraServicePrincipalOwner" @@ -65,7 +71,7 @@ Describe "Add-EntraServicePrincipalOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraServicePrincipalOwner -ObjectId "0008861a-d455-4671-bd24-ce9b3bfce288" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraServicePrincipalOwner -ServicePrincipalId "0008861a-d455-4671-bd24-ce9b3bfce288" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 index 880f4ceb3..338b41568 100644 --- a/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 @@ -21,48 +21,53 @@ BeforeAll { } Describe "Get-EntraServicePrincipalMembership"{ It "Result should not be empty" { + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalMembership -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should return all applications" { - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." + { Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." } It "Should return top application" { - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalMembership" - $result = Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalMembership" Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -77,7 +82,7 @@ Describe "Get-EntraServicePrincipalMembership"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraServicePrincipalMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraServicePrincipalMembership -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 index 12b687bb3..51d886851 100644 --- a/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 @@ -25,48 +25,53 @@ BeforeAll { } Describe "Get-EntraServicePrincipalOAuth2PermissionGrant"{ It "Result should not be empty" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should return all applications" { - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." + { Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." } It "Should return top application" { - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOAuth2PermissionGrant" - $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOAuth2PermissionGrant" Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -81,7 +86,7 @@ Describe "Get-EntraServicePrincipalOAuth2PermissionGrant"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraServicePrincipalOAuth2PermissionGrant -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 index d80d1a2f3..13c22fe2a 100644 --- a/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 @@ -45,48 +45,53 @@ BeforeAll { } Describe "Get-EntraServicePrincipalOwner"{ It "Result should not be empty" { + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalOwner -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should return all applications" { - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." + { Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true} | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." } It "Should return top application" { - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Adams Smith' Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwner" - $result = Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwner" Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -101,7 +106,7 @@ Describe "Get-EntraServicePrincipalOwner"{ try { # Act & Assert: Ensure the function doesn't throw an exception - {Get-EntraServicePrincipalOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + {Get-EntraServicePrincipalOwner -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalPasswordCredential.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalPasswordCredential.Tests.ps1 index e75179543..40b4002e0 100644 --- a/test/module/Entra/Get-EntraServicePrincipalPasswordCredential.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalPasswordCredential.Tests.ps1 @@ -33,6 +33,15 @@ BeforeAll { Describe "Get-EntraServicePrincipalPasswordCredential" { Context "Test for Get-EntraServicePrincipalPasswordCredential" { It "Should return specific principal password credential" { + $ServicePrincipalId = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId $ServicePrincipalId + $result | Should -Not -BeNullOrEmpty + $result.KeyId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + + Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should update the parameter with Alias" { $ServicePrincipalId = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result = Get-EntraServicePrincipalPasswordCredential -ObjectId $ServicePrincipalId $result | Should -Not -BeNullOrEmpty @@ -41,18 +50,18 @@ Describe "Get-EntraServicePrincipalPasswordCredential" { Should -Invoke -CommandName Get-MgServicePrincipal -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { + It "Should fail when ServicePrincipalId is empty" { $errorActionPreference = "Stop" - { Get-EntraServicePrincipalPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is invalid" { + It "Should fail when ServicePrincipalId is invalid" { $errorActionPreference = "Stop" - { Get-EntraServicePrincipalPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraServicePrincipalPasswordCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { + $result = Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $servicePrincipalPasswordCredential = $result | ConvertTo-Json -Depth 10 | ConvertFrom-Json $params = Get-Parameters -data $servicePrincipalPasswordCredential.Parameters $params.ServicePrincipalId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -61,7 +70,7 @@ Describe "Get-EntraServicePrincipalPasswordCredential" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalPasswordCredential" - $result = Get-EntraServicePrincipalPasswordCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraServicePrincipalPasswordCredential -ServicePrincipalId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalPasswordCredential" diff --git a/test/module/Entra/New-EntraServicePrincipalPasswordCredential.Tests.ps1 b/test/module/Entra/New-EntraServicePrincipalPasswordCredential.Tests.ps1 index 6808aa657..28510b964 100644 --- a/test/module/Entra/New-EntraServicePrincipalPasswordCredential.Tests.ps1 +++ b/test/module/Entra/New-EntraServicePrincipalPasswordCredential.Tests.ps1 @@ -29,40 +29,46 @@ BeforeAll { Describe "New-EntraServicePrincipalPasswordCredential"{ Context "Test for New-EntraServicePrincipalPasswordCredential" { It "Should return created password credential for a service principal."{ - $result = New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" + $result = New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" $result | Should -Not -Be NullOrEmpty $result.StartDate | should -Be "16/09/2024 14:14:14" $result.EndDate | should -Be "16/12/2024 13:14:14" Should -Invoke -CommandName Add-MgServicePrincipalPassword -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectID is empty" { - {New-EntraServicePrincipalPasswordCredential -ObjectID } | Should -Throw "Missing an argument for parameter 'ObjectID'.*" + It "Should update the parameter with Alias" { + $result = New-EntraServicePrincipalPasswordCredential -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" + $result | Should -Not -Be NullOrEmpty + + Should -Invoke -CommandName Add-MgServicePrincipalPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ServicePrincipalId is empty" { + {New-EntraServicePrincipalPasswordCredential -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectID is Invalid" { - { New-EntraServicePrincipalPasswordCredential -ObjectID "" } | Should -Throw "Cannot bind argument to parameter 'ObjectID' because it is an empty string.*" + It "Should fail when ServicePrincipalId is Invalid" { + { New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should fail when StartDate is empty" { - { New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate } | Should -Throw "Missing an argument for parameter 'StartDate'.*" + { New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate } | Should -Throw "Missing an argument for parameter 'StartDate'.*" } It "Should fail when StartDate is invalid" { - { New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "xyz" } | Should -Throw "Cannot process argument transformation on parameter 'StartDate'. Cannot convert value*" + { New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "xyz" } | Should -Throw "Cannot process argument transformation on parameter 'StartDate'. Cannot convert value*" } It "Should fail when EndDate is empty" { - { New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -EndDate } | Should -Throw "Missing an argument for parameter 'EndDate'.*" + { New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -EndDate } | Should -Throw "Missing an argument for parameter 'EndDate'.*" } It "Should fail when EndDate is invalid" { - { New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -EndDate "xyz" } | Should -Throw "Cannot process argument transformation on parameter 'EndDate'. Cannot convert value*" + { New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -EndDate "xyz" } | Should -Throw "Cannot process argument transformation on parameter 'EndDate'. Cannot convert value*" } It "Result should Contain StartDate and EndDate" { - $result = New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" + $result = New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" $result.StartDate | should -Be "16/09/2024 14:14:14" $result.EndDate | should -Be "16/12/2024 13:14:14" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraServicePrincipalPasswordCredential" - $result = New-EntraServicePrincipalPasswordCredential -ObjectID "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" + $result = New-EntraServicePrincipalPasswordCredential -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -StartDate "2024-09-16T14:14:14Z" -EndDate "2024-12-16T13:14:14Z" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraServicePrincipalPasswordCredential" diff --git a/test/module/Entra/Remove-EntraServicePrincipalOwner.Tests.ps1 b/test/module/Entra/Remove-EntraServicePrincipalOwner.Tests.ps1 index b7d0ed84b..06a430fdd 100644 --- a/test/module/Entra/Remove-EntraServicePrincipalOwner.Tests.ps1 +++ b/test/module/Entra/Remove-EntraServicePrincipalOwner.Tests.ps1 @@ -13,34 +13,38 @@ BeforeAll { Describe "Remove-EntraServicePrincipalOwner" { Context "Test for Remove-EntraServicePrincipalOwner" { It "Should return empty object" { + $result = Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgServicePrincipalOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should update the parameter with Alias" { $result = Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgServicePrincipalOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - - It "Should fail when ObjectId is empty" { - { Remove-EntraServicePrincipalOwner -ObjectId -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" }| Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Remove-EntraServicePrincipalOwner -ServicePrincipalId -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" }| Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraServicePrincipalOwner -ObjectId "" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333"} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is invalid" { + { Remove-EntraServicePrincipalOwner -ServicePrincipalId "" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333"} | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should fail when OwnerId is empty" { - { Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'.*" + { Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'.*" } It "Should fail when OwnerId is invalid" { - { Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId ""} | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." + { Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId ""} | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { Mock -CommandName Remove-MgServicePrincipalOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result = Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Should contain DirectoryObjectId in parameters when passed OwnerId to it" { Mock -CommandName Remove-MgServicePrincipalOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result = Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } @@ -48,7 +52,7 @@ Describe "Remove-EntraServicePrincipalOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalOwner" - Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalOwner" @@ -65,7 +69,7 @@ Describe "Remove-EntraServicePrincipalOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraServicePrincipalOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -Debug } | Should -Not -Throw + { Remove-EntraServicePrincipalOwner -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccccc" -OwnerId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraServicePrincipalPasswordCredential.Tests.ps1 b/test/module/Entra/Remove-EntraServicePrincipalPasswordCredential.Tests.ps1 index 58d7fd4ec..28bd727f4 100644 --- a/test/module/Entra/Remove-EntraServicePrincipalPasswordCredential.Tests.ps1 +++ b/test/module/Entra/Remove-EntraServicePrincipalPasswordCredential.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Remove-EntraServicePrincipalPasswordCredential" { Context "Test for Remove-EntraServicePrincipalPasswordCredential" { It "Should return empty object" { - $result = Remove-EntraServicePrincipalPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result = Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgServicePrincipalPassword -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectID is empty" { - { Remove-EntraServicePrincipalPasswordCredential -ObjectID -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } | should -Throw "Missing an argument for parameter 'ObjectID'.*" + It "Should update the parameter with Alias" { + $result = Remove-EntraServicePrincipalPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgServicePrincipalPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ServicePrincipalId is empty" { + { Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } | should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectID is invalid" { - {Remove-EntraServicePrincipalPasswordCredential -ObjectID "" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } | should -Throw "Cannot bind argument to parameter 'ObjectID'*" + It "Should fail when ServicePrincipalId is invalid" { + {Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" } | should -Throw "Cannot bind argument to parameter 'ServicePrincipalId'*" } It "Should fail when KeyId is empty" { - {Remove-EntraServicePrincipalPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId } | should -Throw "Missing an argument for parameter 'KeyId'.*" + {Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId } | should -Throw "Missing an argument for parameter 'KeyId'.*" } It "Should fail when KeyId is invalid" { - { Remove-EntraServicePrincipalPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId ""} | should -Throw "Cannot bind argument to parameter 'KeyId'*" + { Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId ""} | should -Throw "Cannot bind argument to parameter 'KeyId'*" } It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { Mock -CommandName Remove-MgServicePrincipalPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraServicePrincipalPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result = Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalPasswordCredential" - Remove-EntraServicePrincipalPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + Remove-EntraServicePrincipalPasswordCredential -ServicePrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -KeyId "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalPasswordCredential" From 39cb9407440d462a2518e00f5d12b8649091f7e0 Mon Sep 17 00:00:00 2001 From: v-uansari <143997438+v-uansari@users.noreply.github.com> Date: Wed, 25 Sep 2024 22:17:14 +0530 Subject: [PATCH 27/64] Usability parameter name change custome script not null (#1074) * paramerte name changes * parameter name change * parameter name change * parameter name change * alice added * alias added * alias ut changes * alias UT changs * alias added * alias UT changes --- .../Add-EntraApplicationOwner.ps1 | 14 +++++- .../Get-EntraApplicationLogo.ps1 | 16 ++++++- .../Get-EntraApplicationOwner.ps1 | 16 ++++++- ...Get-EntraApplicationPasswordCredential.ps1 | 10 ++++- .../Entra/customizations/Get-EntraContact.ps1 | 22 +++++++-- .../Get-EntraDeviceRegisteredOwner.ps1 | 16 ++++++- .../Get-EntraDeviceRegisteredUser.ps1 | 16 ++++++- .../Get-EntraDirectoryRoleDefinition.ps1 | 20 ++++++++- .../Get-EntraDirectoryRoleMember.ps1 | 14 ++++-- .../customizations/Get-EntraGroupMember.ps1 | 16 ++++++- .../customizations/Get-EntraGroupOwner.ps1 | 16 ++++++- .../customizations/Get-EntraSubscribedSku.ps1 | 12 ++++- .../Get-EntraUserCreatedObject.ps1 | 16 ++++++- .../Get-EntraUserDirectReport.ps1 | 16 ++++++- .../customizations/Get-EntraUserManager.ps1 | 14 ++++-- .../Get-EntraUserOwnedDevice.ps1 | 16 ++++++- .../Get-EntraUserOwnedObject.ps1 | 16 ++++++- .../Get-EntraUserRegisteredDevice.ps1 | 16 ++++++- ...New-EntraApplicationPasswordCredential.ps1 | 18 +++++++- .../Set-EntraApplicationLogo.ps1 | 19 +++++++- .../Set-EntraIdentityProvider.ps1 | 20 +++++++-- .../Add-EntraApplicationOwner.md | 12 ++--- .../Get-EntraApplicationLogo.md | 12 ++--- .../Get-EntraApplicationOwner.md | 18 ++++---- .../Get-EntraApplicationPasswordCredential.md | 14 +++--- .../Microsoft.Graph.Entra/Get-EntraContact.md | 10 ++--- .../Get-EntraDeviceRegisteredOwner.md | 24 +++++----- .../Get-EntraDeviceRegisteredUser.md | 18 ++++---- .../Get-EntraDirectoryRoleDefinition.md | 16 +++---- .../Get-EntraDirectoryRoleMember.md | 12 ++--- .../Get-EntraGroupMember.md | 26 +++++------ .../Get-EntraGroupOwner.md | 20 ++++----- .../Get-EntraSubscribedSku.md | 14 +++--- .../Get-EntraUserCreatedObject.md | 20 ++++----- .../Get-EntraUserDirectReport.md | 22 ++++----- .../Get-EntraUserManager.md | 14 +++--- .../Get-EntraUserOwnedDevice.md | 14 +++--- .../Get-EntraUserOwnedObject.md | 22 ++++----- .../Get-EntraUserRegisteredDevice.md | 14 +++--- .../New-EntraApplicationPasswordCredential.md | 22 ++++----- .../Set-EntraApplicationLogo.md | 18 ++++---- .../Set-EntraIdentityProvider.md | 13 +++--- .../Entra/Add-EntraApplicationOwner.Tests.ps1 | 12 ++--- .../Entra/Get-EntraApplicationLogo.Tests.ps1 | 27 ++++++----- .../Entra/Get-EntraApplicationOwner.Tests.ps1 | 16 +++---- ...traApplicationPasswordCredential.Tests.ps1 | 18 ++++---- test/module/Entra/Get-EntraContact.Tests.ps1 | 39 +++++++++++----- .../Get-EntraDeviceRegisteredOwner.Tests.ps1 | 37 ++++++++------- .../Get-EntraDeviceRegisteredUser.Tests.ps1 | 35 +++++++++------ ...Get-EntraDirectoryRoleDefinition.Tests.ps1 | 26 +++++++---- .../Get-EntraDirectoryRoleMember.Tests.ps1 | 29 +++++++----- .../Entra/Get-EntraGroupMember.Tests.ps1 | 23 +++++----- .../Entra/Get-EntraGroupOwner.Tests.ps1 | 44 ++++++++++-------- .../Entra/Get-EntraSubscribedSku.Tests.ps1 | 17 ++++--- .../Get-EntraUserCreatedObject.Tests.ps1 | 38 +++++++++------- .../Entra/Get-EntraUserDirectReport.Tests.ps1 | 39 +++++++++------- .../Entra/Get-EntraUserManager.Tests.ps1 | 38 +++++++++++----- .../Entra/Get-EntraUserOwnedDevice.Tests.ps1 | 32 ++++++++----- .../Entra/Get-EntraUserOwnedObject.Tests.ps1 | 45 ++++++++++++------- .../Get-EntraUserRegisteredDevice.Tests.ps1 | 35 +++++++++------ ...traApplicationPasswordCredential.Tests.ps1 | 30 ++++++------- .../Entra/Set-EntraApplicationLogo.Tests.ps1 | 20 ++++++--- 62 files changed, 836 insertions(+), 458 deletions(-) diff --git a/module/Entra/customizations/Add-EntraApplicationOwner.ps1 b/module/Entra/customizations/Add-EntraApplicationOwner.ps1 index 03cee0b3a..942021a52 100644 --- a/module/Entra/customizations/Add-EntraApplicationOwner.ps1 +++ b/module/Entra/customizations/Add-EntraApplicationOwner.ps1 @@ -7,11 +7,20 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $RefObjectId + ) + PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } $newOwner = @{} @@ -71,5 +80,6 @@ Write-Debug("=========================================================================`n") New-MgApplicationOwnerByRef @params -Headers $customHeaders +} '@ } \ No newline at end of file diff --git a/module/Entra/customizations/Get-EntraApplicationLogo.ps1 b/module/Entra/customizations/Get-EntraApplicationLogo.ps1 index f0a2dd7f5..bb6e3140c 100644 --- a/module/Entra/customizations/Get-EntraApplicationLogo.ps1 +++ b/module/Entra/customizations/Get-EntraApplicationLogo.ps1 @@ -7,14 +7,26 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Boolean] $View, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FileName, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FilePath + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/v1.0/applications' $Method = "GET" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $URI = "$baseUri/$($params.ApplicationId)" } diff --git a/module/Entra/customizations/Get-EntraApplicationOwner.ps1 b/module/Entra/customizations/Get-EntraApplicationOwner.ps1 index 3cb00e337..3a2baf1e3 100644 --- a/module/Entra/customizations/Get-EntraApplicationOwner.ps1 +++ b/module/Entra/customizations/Get-EntraApplicationOwner.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -20,9 +32,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $URI = "$baseUri/$($params.ApplicationId)/owners?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraApplicationPasswordCredential.ps1 b/module/Entra/customizations/Get-EntraApplicationPasswordCredential.ps1 index ce8ba762c..0a59c1ece 100644 --- a/module/Entra/customizations/Get-EntraApplicationPasswordCredential.ps1 +++ b/module/Entra/customizations/Get-EntraApplicationPasswordCredential.ps1 @@ -7,6 +7,14 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -17,7 +25,7 @@ # TODO : Invoke API and apply the correct Select query - $response = (Get-MgApplication -Headers $customHeaders -ApplicationId $PSBoundParameters["ObjectId"]).PasswordCredentials + $response = (Get-MgApplication -Headers $customHeaders -ApplicationId $PSBoundParameters["ApplicationId"]).PasswordCredentials if($null -ne $PSBoundParameters["Property"]) { diff --git a/module/Entra/customizations/Get-EntraContact.ps1 b/module/Entra/customizations/Get-EntraContact.ps1 index 8e2b00106..85e240103 100644 --- a/module/Entra/customizations/Get-EntraContact.ps1 +++ b/module/Entra/customizations/Get-EntraContact.ps1 @@ -6,14 +6,28 @@ TargetName = $null Parameters = $null outputs = $null - CustomScript = @' + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $OrgContactId, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - $keysChanged = @{ObjectId = "Id"} - if($null -ne $PSBoundParameters["ObjectId"]) + $keysChanged = @{OrgContactId = "Id"} + if($null -ne $PSBoundParameters["OrgContactId"]) { - $params["OrgContactId"] = $PSBoundParameters["ObjectId"] + $params["OrgContactId"] = $PSBoundParameters["OrgContactId"] } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 b/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 index be25e5c7c..220782474 100644 --- a/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 +++ b/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -20,9 +32,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DeviceId"]) { - $params["DeviceId"] = $PSBoundParameters["ObjectId"] + $params["DeviceId"] = $PSBoundParameters["DeviceId"] $URI = "$baseUri/$($params.DeviceId)/registeredOwners?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 b/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 index bb25e96f5..345116cf8 100644 --- a/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 +++ b/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -20,9 +32,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DeviceId"]) { - $params["DeviceId"] = $PSBoundParameters["ObjectId"] + $params["DeviceId"] = $PSBoundParameters["DeviceId"] $URI = "$baseUri/$($params.DeviceId)/registeredUsers?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 index 99aba85fe..b221639b5 100644 --- a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 +++ b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 @@ -7,13 +7,29 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('Id')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DirectoryRoleId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $keysChanged = @{SearchString = "Filter"} - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["DirectoryRoleId"]) { - $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["Id"] + $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["DirectoryRoleId"] } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/Entra/customizations/Get-EntraDirectoryRoleMember.ps1 b/module/Entra/customizations/Get-EntraDirectoryRoleMember.ps1 index 5414fcc71..5bdc239e6 100644 --- a/module/Entra/customizations/Get-EntraDirectoryRoleMember.ps1 +++ b/module/Entra/customizations/Get-EntraDirectoryRoleMember.ps1 @@ -7,6 +7,14 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DirectoryRoleId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -19,10 +27,10 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DirectoryRoleId"]) { - $params["ObjectId"] = $PSBoundParameters["ObjectId"] - $URI = "$baseUri/$($params.ObjectId)/members?$properties" + $params["DirectoryRoleId"] = $PSBoundParameters["DirectoryRoleId"] + $URI = "$baseUri/$($params.DirectoryRoleId)/members?$properties" } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug diff --git a/module/Entra/customizations/Get-EntraGroupMember.ps1 b/module/Entra/customizations/Get-EntraGroupMember.ps1 index 8edb5a21b..bedc6e100 100644 --- a/module/Entra/customizations/Get-EntraGroupMember.ps1 +++ b/module/Entra/customizations/Get-EntraGroupMember.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -21,9 +33,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["GroupId"]) { - $params["GroupId"] = $PSBoundParameters["ObjectId"] + $params["GroupId"] = $PSBoundParameters["GroupId"] $URI = "$baseUri/$($params.GroupId)/members?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraGroupOwner.ps1 b/module/Entra/customizations/Get-EntraGroupOwner.ps1 index a29ad599e..c2e988b3e 100644 --- a/module/Entra/customizations/Get-EntraGroupOwner.ps1 +++ b/module/Entra/customizations/Get-EntraGroupOwner.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -20,9 +32,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["GroupId"]) { - $params["GroupId"] = $PSBoundParameters["ObjectId"] + $params["GroupId"] = $PSBoundParameters["GroupId"] $URI = "$baseUri/$($params.GroupId)/owners?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraSubscribedSku.ps1 b/module/Entra/customizations/Get-EntraSubscribedSku.ps1 index 9c45e18f2..cd046d7f6 100644 --- a/module/Entra/customizations/Get-EntraSubscribedSku.ps1 +++ b/module/Entra/customizations/Get-EntraSubscribedSku.ps1 @@ -7,6 +7,14 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SubscribedSkuId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +22,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["SubscribedSkuId"]) { - $params["SubscribedSkuId"] = $PSBoundParameters["ObjectId"] + $params["SubscribedSkuId"] = $PSBoundParameters["SubscribedSkuId"] } if($PSBoundParameters.ContainsKey("Debug")) { diff --git a/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 b/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 index 626fcc24c..700a4be94 100644 --- a/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 +++ b/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +26,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/Entra/customizations/Get-EntraUserDirectReport.ps1 b/module/Entra/customizations/Get-EntraUserDirectReport.ps1 index 6fbfcc7e7..64464f2ec 100644 --- a/module/Entra/customizations/Get-EntraUserDirectReport.ps1 +++ b/module/Entra/customizations/Get-EntraUserDirectReport.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -20,9 +32,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] $URI = "$baseUri/$($params.UserId)/directReports?$properties" } if($null -ne $PSBoundParameters["All"]) diff --git a/module/Entra/customizations/Get-EntraUserManager.ps1 b/module/Entra/customizations/Get-EntraUserManager.ps1 index 5a4a6c805..07081c2ff 100644 --- a/module/Entra/customizations/Get-EntraUserManager.ps1 +++ b/module/Entra/customizations/Get-EntraUserManager.ps1 @@ -7,14 +7,22 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $Method = "GET" - $keysChanged = @{ObjectId = "Id"} - if($null -ne $PSBoundParameters["ObjectId"]) + $keysChanged = @{UserId = "Id"} + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } $URI = "https://graph.microsoft.com/v1.0/users/$($params.UserId)/manager?`$select=*" diff --git a/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 b/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 index 902436e87..32cc548da 100644 --- a/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 +++ b/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +26,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 b/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 index 03d3f9f7c..ce6d5fa78 100644 --- a/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 +++ b/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 @@ -7,11 +7,23 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand - if ($null -ne $PSBoundParameters["ObjectId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + if ($null -ne $PSBoundParameters["UserId"]) { + $params["UserId"] = $PSBoundParameters["UserId"] } $URI = "/v1.0/users/$($params.UserId)/ownedObjects" diff --git a/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 b/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 index 9a3bf1b9f..f62ad012d 100644 --- a/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 +++ b/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +26,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/Entra/customizations/New-EntraApplicationPasswordCredential.ps1 b/module/Entra/customizations/New-EntraApplicationPasswordCredential.ps1 index 8a3fe5e23..e33894429 100644 --- a/module/Entra/customizations/New-EntraApplicationPasswordCredential.ps1 +++ b/module/Entra/customizations/New-EntraApplicationPasswordCredential.ps1 @@ -7,6 +7,20 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Value, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $CustomKeyIdentifier, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $StartDate, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $EndDate + ) PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand @@ -24,9 +38,9 @@ { $body["displayName"] = $PSBoundParameters["CustomKeyIdentifier"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($PSBoundParameters.ContainsKey("Verbose")) { diff --git a/module/Entra/customizations/Set-EntraApplicationLogo.ps1 b/module/Entra/customizations/Set-EntraApplicationLogo.ps1 index eb8d4e667..1b5f661ad 100644 --- a/module/Entra/customizations/Set-EntraApplicationLogo.ps1 +++ b/module/Entra/customizations/Set-EntraApplicationLogo.ps1 @@ -7,15 +7,30 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'File')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = "Stream")] + [Parameter(ParameterSetName = "File")] + [Parameter(ParameterSetName = "ByteArray")] + [System.String] $ApplicationId, + [Parameter(ParameterSetName = "ByteArray", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Byte[]] $ImageByteArray, + [Parameter(ParameterSetName = "File", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FilePath, + [Parameter(ParameterSetName = "Stream", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.IO.Stream] $FileStream + ) PROCESS { try{ $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/v1.0/applications' $Method = "PUT" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $URI = "$baseUri/$($params.ApplicationId)/logo" } if($null -ne $PSBoundParameters["FilePath"]){ diff --git a/module/Entra/customizations/Set-EntraIdentityProvider.ps1 b/module/Entra/customizations/Set-EntraIdentityProvider.ps1 index 8c1cd05b8..c048bf81c 100644 --- a/module/Entra/customizations/Set-EntraIdentityProvider.ps1 +++ b/module/Entra/customizations/Set-EntraIdentityProvider.ps1 @@ -7,13 +7,27 @@ Parameters = $null outputs = $null CustomScript = @' - PROCESS { + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Name, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ClientId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Type, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ClientSecret, + [Alias('Id')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $IdentityProviderBaseId + ) + PROCESS { $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $body = @{} - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["IdentityProviderBaseId"]) { - $params["IdentityProviderBaseId"] = $PSBoundParameters["Id"] + $params["IdentityProviderBaseId"] = $PSBoundParameters["IdentityProviderBaseId"] } if($null -ne $PSBoundParameters["Type"]) { diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraApplicationOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraApplicationOwner.md index 2de3a2e77..626edce35 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraApplicationOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraApplicationOwner.md @@ -26,7 +26,7 @@ Adds an owner to an application. ```powershell Add-EntraApplicationOwner - -ObjectId + -ApplicationId -RefObjectId [] ``` @@ -42,25 +42,25 @@ The `Add-EntraApplicationOwner` cmdlet adds an owner to a Microsoft Entra ID app ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' $ApplicationId = (Get-EntraApplication -Top 1).ObjectId -$UserObjectId = (Get-EntraUser -ObjectId 'SawyerM@contoso.com').ObjectId -Add-EntraApplicationOwner -ObjectId $ApplicationId -RefObjectId $UserObjectId +$UserObjectId = (Get-EntraUser -UserId 'SawyerM@contoso.com').ObjectId +Add-EntraApplicationOwner -ApplicationId $ApplicationId -RefObjectId $UserObjectId ``` This example demonstrates how to add an owner to an application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of an application. +- `-ApplicationId` parameter specifies the ID of an application. - `-RefObjectId` parameter specifies the ID of a user. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationLogo.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationLogo.md index e8f599244..741be683c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationLogo.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationLogo.md @@ -27,7 +27,7 @@ Retrieve the logo of an application. ```powershell Get-EntraApplicationLogo - -ObjectId + -ApplicationId [-FileName ] [-View ] [-FilePath ] @@ -36,7 +36,7 @@ Get-EntraApplicationLogo ## Description -The `Get-EntraApplicationLogo` cmdlet retrieves the logo that is set for an application. Specify the `ObjectId` parameter to get a specific application logo for an application. +The `Get-EntraApplicationLogo` cmdlet retrieves the logo that is set for an application. Specify the `ApplicationId` parameter to get a specific application logo for an application. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraApplicationLogo` cmdlet retrieves the logo that is set for an appl ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraApplicationLogo -ObjectId 'bbbbbbbb-1111-1111-1111-cccccccccccc' -FilePath 'D:\outfile1.jpg' +Get-EntraApplicationLogo -ApplicationId 'bbbbbbbb-1111-1111-1111-cccccccccccc' -FilePath 'D:\outfile1.jpg' ``` This example shows how to retrieve the application logo for an application that is specified through the Object ID parameter. @@ -83,14 +83,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId -The ObjectID of the application for which the logo is to be retrieved. +The ApplicationId of the application for which the logo is to be retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationOwner.md index 17c4b4743..4b79b9de8 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationOwner.md @@ -27,7 +27,7 @@ Gets the owner of an application. ```powershell Get-EntraApplicationOwner - -ObjectId + -ApplicationId [-All] [-Top ] [-Property ] @@ -45,7 +45,7 @@ The `Get-EntraApplicationOwner` cmdlet get an owner of an Microsoft Entra ID app ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraApplication -SearchString '' -Get-EntraApplicationOwner -ObjectId $Application.ObjectId +Get-EntraApplicationOwner -ApplicationId $Application.ObjectId ``` ```Output @@ -59,7 +59,7 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example demonstrates how to get the owners of an application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ### Example 2: Get the details about the owner of an application @@ -94,7 +94,7 @@ This example demonstrates how to get the owners of an application in Microsoft E ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraApplication -SearchString '' -Get-EntraApplicationOwner -ObjectId $Application.ObjectId -All +Get-EntraApplicationOwner -ApplicationId $Application.ObjectId -All ``` ```Output @@ -108,14 +108,14 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example demonstrates how to get the all owners of a specified application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ### Example 4: Get top two owners of an application ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraApplication -SearchString '' -Get-EntraApplicationOwner -ObjectId $Application.ObjectId -Top 2 +Get-EntraApplicationOwner -ApplicationId $Application.ObjectId -Top 2 ``` ```Output @@ -127,7 +127,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example demonstrates how to get the two owners of a specified application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ## Parameters @@ -147,14 +147,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationPasswordCredential.md index 7db5647d7..f14f78835 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationPasswordCredential.md @@ -26,14 +26,14 @@ Gets the password credential for an application. ```powershell Get-EntraApplicationPasswordCredential - -ObjectId + -ApplicationId [-Property ] [] ``` ## Description -The `Get-EntraApplicationPasswordCredential` cmdlet receives the password credentials for a Microsoft Entra ID application. Specify `ObjectId` parameter to cmdlet receives the password credentials. +The `Get-EntraApplicationPasswordCredential` cmdlet receives the password credentials for a Microsoft Entra ID application. Specify `ApplicationId` parameter to cmdlet receives the password credentials. ## Examples @@ -42,7 +42,7 @@ The `Get-EntraApplicationPasswordCredential` cmdlet receives the password creden ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraApplicationPasswordCredential -ObjectId $application.ObjectId +Get-EntraApplicationPasswordCredential -ApplicationId $application.ObjectId ``` ```Output @@ -53,18 +53,18 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This example shows how to retrieve the password credential for specified application. -- `-ObjectId` specifies the ID of an application object in Microsoft Entra ID. +- `-ApplicationId` specifies the ID of an application object in Microsoft Entra ID. ## Parameters -### -ObjectId +### -ApplicationId -The objectID of the application for which to get the password credential. Use `Get-EntraApplication` for more details. +The ApplicationId of the application for which to get the password credential. Use `Get-EntraApplication` for more details. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContact.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContact.md index 747db4b4c..fb0bcb0cb 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContact.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContact.md @@ -39,7 +39,7 @@ Get-EntraContact ```powershell Get-EntraContact - -ObjectId + -OrgContactId [-All] [-Property ] [] @@ -73,7 +73,7 @@ This example retrieves all contact objects in the directory. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' -Get-EntraContact -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraContact -OrgContactId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -84,7 +84,7 @@ Contoso Contact aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb contact@contoso.com This example retrieves specified contact in the directory. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 3: Retrieve all contacts objects in the directory @@ -173,14 +173,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredOwner.md index 3b541878f..1149f5438 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredOwner.md @@ -27,7 +27,7 @@ Gets the registered owner of a device. ```powershell Get-EntraDeviceRegisteredOwner - -ObjectId + -DeviceId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraDeviceRegisteredOwner ## Description -The `Get-EntraDeviceRegisteredOwner` cmdlet gets the registered owner of a device in Microsoft Entra ID. Specify `ObjectId` parameter gets the registered owner of a device. +The `Get-EntraDeviceRegisteredOwner` cmdlet gets the registered owner of a device in Microsoft Entra ID. Specify `DeviceId` parameter gets the registered owner of a device. ## Examples @@ -45,7 +45,7 @@ The `Get-EntraDeviceRegisteredOwner` cmdlet gets the registered owner of a devic ```powershell Connect-Entra -Scopes 'Device.Read.All' $DevId = (Get-EntraDevice -Top 1).ObjectId -Get-EntraDeviceRegisteredOwner -ObjectId $DevId +Get-EntraDeviceRegisteredOwner -DeviceId $DevId ``` ```Output @@ -56,13 +56,13 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example shows how to find the registered owner of a device.. -- `-ObjectId` parameter specifies the device's ID. +- `-DeviceId` parameter specifies the device's ID. ### Example 2: Retrieve the registered owner of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDeviceRegisteredOwner -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraDeviceRegisteredOwner -DeviceId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -74,13 +74,13 @@ cccccccc-2222-3333-4444-dddddddddddd This command gets the registered owner of a device. -- `-ObjectId` parameter specifies the device's ID +- `-DeviceId` parameter specifies the device's ID ### Example 3: Retrieve all the registered owners of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDeviceRegisteredOwner -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' -All +Get-EntraDeviceRegisteredOwner -DeviceId 'bbbbbbbb-1111-2222-3333-cccccccccccc' -All ``` ```Output @@ -92,13 +92,13 @@ cccccccc-2222-3333-4444-dddddddddddd This command retrieves all the registered owners of a device. -- `-ObjectId` parameter specifies the device's ID. +- `-DeviceId` parameter specifies the device's ID. ### Example 4: Retrieve top one registered owner of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDeviceRegisteredOwner -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' -Top 1 +Get-EntraDeviceRegisteredOwner -DeviceId 'bbbbbbbb-1111-2222-3333-cccccccccccc' -Top 1 ``` ```Output @@ -109,7 +109,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This command retrieves all the registered owners of a device. -- `-ObjectId` parameter specifies the device's ID. +- `-DeviceId` parameter specifies the device's ID. ## Parameters @@ -129,14 +129,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredUser.md index 4b3fa8945..810e5ec60 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeviceRegisteredUser.md @@ -27,7 +27,7 @@ Retrieve a list of users that are registered users of the device. ```powershell Get-EntraDeviceRegisteredUser - -ObjectId + -DeviceId [-All ] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraDeviceRegisteredUser ## Description -The `Get-EntraDeviceRegisteredUser` cmdlet gets a registered user for a Microsoft Entra ID device. Specify `ObjectId` parameter to get a registered user for a Microsoft Entra ID device. +The `Get-EntraDeviceRegisteredUser` cmdlet gets a registered user for a Microsoft Entra ID device. Specify `DeviceId` parameter to get a registered user for a Microsoft Entra ID device. ## Examples @@ -45,7 +45,7 @@ The `Get-EntraDeviceRegisteredUser` cmdlet gets a registered user for a Microsof ```powershell Connect-Entra -Scopes 'Device.Read.All' $DevId = (Get-EntraDevice -Top 1).ObjectId -Get-EntraDeviceRegisteredUser -ObjectId $DevId +Get-EntraDeviceRegisteredUser -DeviceId $DevId ``` ```Output @@ -63,7 +63,7 @@ This example demonstrates how to retrieve registered user for a specific Microso ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDeviceRegisteredUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -All +Get-EntraDeviceRegisteredUser -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -All ``` ```Output @@ -77,13 +77,13 @@ ffffffff-4444-5555-6666-gggggggggggg This example demonstrates how to retrieve all registered users for a specified device. -- `-ObjectId` parameter specifies an object ID of a device, which you want to retrieve. +- `-DeviceId` parameter specifies an object ID of a device, which you want to retrieve. ### Example 3: Get top two registered users of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDeviceRegisteredUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 2 +Get-EntraDeviceRegisteredUser -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 2 ``` ```Output @@ -95,7 +95,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example demonstrates how to retrieve top two registered users for the specified device. -- `-ObjectId` parameter specifies an object ID of a device, which you want to retrieve. +- `-DeviceId` parameter specifies an object ID of a device, which you want to retrieve. ## Parameters @@ -115,14 +115,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies an object ID of a device. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md index 4f207c541..976040d1d 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md @@ -49,7 +49,7 @@ Get-EntraDirectoryRoleDefinition ```powershell Get-EntraDirectoryRoleDefinition - -Id + -DirectoryRoleId [-All] [-Property ] [] @@ -57,7 +57,7 @@ Get-EntraDirectoryRoleDefinition ## Description -The `Get-EntraDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `Id` parameter. Specify the `SearchString` or `Filter` parameter to find particular role definition. +The `Get-EntraDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `DirectoryRoleId` parameter. Specify the `SearchString` or `Filter` parameter to find particular role definition. In delegated scenarios with work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: @@ -89,11 +89,11 @@ Restricted Guest User 2af84b1e-32c8-42b7-82bc-daa8240402 This command returns all the role definitions present. -### Example 2: Get a role definition by ID +### Example 2: Get a role definition by DirectoryRoleId ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory','EntitlementManagement.Read.All' -Get-EntraDirectoryRoleDefinition -Id '1a327991-10cb-4266-877a-998fb4df78ec' +Get-EntraDirectoryRoleDefinition -DirectoryRoleId '1a327991-10cb-4266-877a-998fb4df78ec' ``` ```Output @@ -104,7 +104,7 @@ Restricted Guest User 2af84b1e-32c8-42b7-82bc-daa8240402 This command returns a specified role definition. -- `-Id` parameter specifies the roleDefinition object ID. +- `-DirectoryRoleId` parameter specifies the roleDefinition object ID. ### Example 3: Filter role definitions by display name @@ -134,7 +134,7 @@ DisplayName Id TemplateId Restricted Guest User 00aa00aa-bb11-cc22-dd33-44ee44ee44ee 2af84b1e-32c8-42b7-82bc-daa82404023b Restricted role for guest users. Can read a limited set of directory information. True True ``` -This command return top two the role definitions in Microsoft Entra ID. +This command return top two the role definitions in Microsoft Entra DirectoryRoleId. ### Example 5: Filter role definitions by display name @@ -154,14 +154,14 @@ This command return all the role definitions containing the specified display na ## Parameters -### -Id +### -DirectoryRoleId Specifies the ID of the role definition. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleMember.md index eb44519bb..3238d3cb0 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleMember.md @@ -27,14 +27,14 @@ Gets members of a directory role. ```powershell Get-EntraDirectoryRoleMember - -ObjectId + -DirectoryRoleId [-Property ] [] ``` ## Description -The `Get-EntraDirectoryRoleMember` cmdlet retrieves the members of a directory role in Microsoft Entra ID. To obtain the members of a specific directory role, specify the `ObjectId`. Use the `Get-EntraDirectoryRole` cmdlet to get the `ObjectId` value. +The `Get-EntraDirectoryRoleMember` cmdlet retrieves the members of a directory role in Microsoft Entra ID. To obtain the members of a specific directory role, specify the `DirectoryRoleId`. Use the `Get-EntraDirectoryRole` cmdlet to get the `DirectoryRoleId` value. ## Examples @@ -42,7 +42,7 @@ The `Get-EntraDirectoryRoleMember` cmdlet retrieves the members of a directory r ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory' -Get-EntraDirectoryRoleMember -ObjectId '1d73e796-aac5-4b3a-b7e7-74a3d1926a85' +Get-EntraDirectoryRoleMember -DirectoryRoleId '1d73e796-aac5-4b3a-b7e7-74a3d1926a85' ``` ```Output @@ -53,18 +53,18 @@ bbbbbbbb-7777-8888-9999-cccccccccccc This example retrieves the members of the specified role. -- `-ObjectId` parameter specifies directory role ID. +- `-DirectoryRoleId` parameter specifies directory role ID. ## Parameters -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupMember.md index 0f81deabe..bdd0673a0 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupMember.md @@ -25,7 +25,7 @@ Gets a member of a group. ```powershell Get-EntraGroupMember - -ObjectId + -GroupId [-All] [-Top ] [-Property ] @@ -34,7 +34,7 @@ Get-EntraGroupMember ## Description -The `Get-EntraGroupMember` cmdlet gets a member of a group in Microsoft Entra ID. Specify the `ObjectId` parameter to get a member of a group. +The `Get-EntraGroupMember` cmdlet gets a member of a group in Microsoft Entra ID. Specify the `GroupId` parameter to get a member of a group. In delegated scenarios, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: `microsoft.directory/groups/members/read`, `microsoft.directory/groups/members/limitedRead`, or `microsoft.directory/groups/hiddenMembers/read` (for hidden members). The following least privileged roles support this operation: @@ -59,7 +59,7 @@ To list members of a hidden group, the `Member.Read.Hidden` permission is also r ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraGroupMember -GroupId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -70,13 +70,13 @@ bbbbbbbb-7777-8888-9999-cccccccccccc This example demonstrates how to retrieve group member by ID. -- `-ObjectId` Specifies the ID of a group. +- `-GroupId` Specifies the ID of a group. ### Example 2: Get two group member ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -ObjectId 'hhhhhhhh-8888-9999-8888-cccccccccccc' -Top 2 +Get-EntraGroupMember -GroupId 'hhhhhhhh-8888-9999-8888-cccccccccccc' -Top 2 ``` ```Output @@ -88,13 +88,13 @@ Id DeletedDateTime This example demonstrates how to retrieve top two groups from Microsoft Entra ID. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ### Example 3: Get all members within a group by group ID ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -ObjectId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' -All +Get-EntraGroupMember -GroupId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' -All ``` ```Output @@ -109,13 +109,13 @@ cccccccc-8888-9999-0000-dddddddddddd This example retrieves all members within a group by group ID. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ### Example 4: Retrieve and Select Group Member Properties ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -ObjectId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' +Get-EntraGroupMember -GroupId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' ``` ```Output @@ -127,9 +127,9 @@ test2 #microsoft.graph.servicePrincipal test3 #microsoft.graph.servicePrincipal ``` -This example retrieves the members of a specified group by its `ObjectId` and selects only the `DisplayName` and `@odata.type` properties for each member. +This example retrieves the members of a specified group by its `GroupId` and selects only the `DisplayName` and `@odata.type` properties for each member. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ## Parameters @@ -149,14 +149,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupOwner.md index 0e4db35dd..340e3463a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupOwner.md @@ -27,7 +27,7 @@ Gets an owner of a group. ```powershell Get-EntraGroupOwner - -ObjectId + -GroupId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraGroupOwner ## Description -The `Get-EntraGroupOwner` cmdlet gets an owner of a group in Microsoft Entra ID. Specify `ObjectId` parameter gets an owner of a group. +The `Get-EntraGroupOwner` cmdlet gets an owner of a group in Microsoft Entra ID. Specify `GroupId` parameter gets an owner of a group. In delegated scenarios, the signed-in user must have a supported Microsoft Entra role or a custom role with the `microsoft.directory/groups/owners/read` permission. The following least privileged roles support this operation: @@ -52,7 +52,7 @@ In delegated scenarios, the signed-in user must have a supported Microsoft Entra ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupOwner -ObjectId 'vvvvvvvv-7777-9999-7777-jjjjjjjjjjjj' +Get-EntraGroupOwner -GroupId 'vvvvvvvv-7777-9999-7777-jjjjjjjjjjjj' ``` ```Output @@ -66,13 +66,13 @@ dddddddd-3333-4444-5555-eeeeeeeeeeee This example demonstrates how to retrieve the owner of a specific group. -- `-ObjectId` Parameter specifies the ID of a group. +- `-GroupId` Parameter specifies the ID of a group. ### Example 2: Gets all group owners ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupOwner -ObjectId 'zzzzzzzz-6666-8888-9999-pppppppppppp' -All +Get-EntraGroupOwner -GroupId 'zzzzzzzz-6666-8888-9999-pppppppppppp' -All ``` ```Output @@ -86,13 +86,13 @@ dddddddd-3333-4444-5555-eeeeeeeeeeee This example demonstrates how to retrieve the all owner of a specific group. -- `-ObjectId` Parameter specifies the ID of a group. +- `-GroupId` Parameter specifies the ID of a group. ### Example 3: Gets two group owners ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupOwner -ObjectId 'vvvvvvvv-8888-9999-0000-jjjjjjjjjjjj' -Top 2 +Get-EntraGroupOwner -GroupId 'vvvvvvvv-8888-9999-0000-jjjjjjjjjjjj' -Top 2 ``` ```Output @@ -104,7 +104,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example demonstrates how to retrieve the top two owners of a specific group. -- `-ObjectId` parameter specifies the ID of a group. +- `-GroupId` parameter specifies the ID of a group. ## Parameters @@ -124,14 +124,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraSubscribedSku.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraSubscribedSku.md index 948ebb73f..ee73b1370 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraSubscribedSku.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraSubscribedSku.md @@ -36,7 +36,7 @@ Get-EntraSubscribedSku ```powershell Get-EntraSubscribedSku - -ObjectId + -SubscribedSkuId [-Property ] [] ``` @@ -64,11 +64,11 @@ cccc2222-dd33-4444-55ee-666666ffffff 2222cccc-33dd-eeee-ff44-aaaaaa555555 M365x9 This example demonstrates how to retrieve subscribed SKUs to Microsoft services. -### Example 2: Get subscribed SKUs by ObjectId +### Example 2: Get subscribed SKUs by SubscribedSkuId ```powershell Connect-Entra -Scopes 'Organization.Read.All' -Get-EntraSubscribedSku -ObjectId 'abcdefgh-1111-2222-bbbb-cccc33333333_dddddddd-4444-5555-eeee-666666666666' +Get-EntraSubscribedSku -SubscribedSkuId 'abcdefgh-1111-2222-bbbb-cccc33333333_dddddddd-4444-5555-eeee-666666666666' ``` ```Output @@ -79,7 +79,7 @@ aaaa0000-bb11-2222-33cc-444444dddddd 0000aaaa-11bb-cccc-dd22-eeeeee333333 M365x9 This example demonstrates how to retrieve specified subscribed SKUs to Microsoft services. -- `-ObjectId` parameter specifies the ID of the SKU (Stock Keeping Unit). +- `-SubscribedSkuId` parameter specifies the ID of the SKU (Stock Keeping Unit). ### Example 3: Get a list of users, their assigned licenses, and licensing source @@ -105,7 +105,7 @@ foreach ($User in $SelectedUsers) { try { # Check if the group display name is already in the hashtable if (-not $GroupDisplayNames.ContainsKey($AssignedByGroup)) { - $Group = Get-EntraGroup -ObjectId $AssignedByGroup + $Group = Get-EntraGroup -GroupId $AssignedByGroup $GroupDisplayNames[$AssignedByGroup] = $Group.DisplayName } @@ -141,14 +141,14 @@ This example shows a list of users, their licenses, and the source of the licens ## Parameters -### -ObjectId +### -SubscribedSkuId The object ID of the SKU (Stock Keeping Unit). ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserCreatedObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserCreatedObject.md index c764c6b47..56eb9c60b 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserCreatedObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserCreatedObject.md @@ -26,7 +26,7 @@ Get objects created by the user. ```powershell Get-EntraUserCreatedObject - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraUserCreatedObject` cmdlet gets objects created by a user in Micros ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserCreatedObject -ObjectId 'SawyerM@contoso.com' +Get-EntraUserCreatedObject -UserId 'SawyerM@contoso.com' ``` ```Output @@ -57,13 +57,13 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example retrieves an object created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ### Example 2: Get all user-created objects ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserCreatedObject -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserCreatedObject -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -77,13 +77,13 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example retrieves all objects created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ### Example 3: Get a top one user-created object ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserCreatedObject -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraUserCreatedObject -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -94,7 +94,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example retrieves top one object created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ## Parameters @@ -114,14 +114,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID (as a UserPrincipalName or ObjectId) of a user in Microsoft Entra ID. +Specifies the ID (as a UserPrincipalName or UserId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserDirectReport.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserDirectReport.md index 580cd2fb8..0a4ea05e0 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserDirectReport.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserDirectReport.md @@ -27,7 +27,7 @@ Get the user's direct reports. ```powershell Get-EntraUserDirectReport - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraUserDirectReport ## Description -The `Get-EntraUserDirectReport` cmdlet gets the direct reports for a user in Microsoft Entra ID. Specify `ObjectId` parameter gets the direct reports for a user. +The `Get-EntraUserDirectReport` cmdlet gets the direct reports for a user in Microsoft Entra ID. Specify `UserId` parameter gets the direct reports for a user. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraUserDirectReport` cmdlet gets the direct reports for a user in Mic ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserDirectReport -ObjectId 'SawyerM@contoso.com' +Get-EntraUserDirectReport -UserId 'SawyerM@contoso.com' ``` ```Output @@ -58,13 +58,13 @@ dddddddd-3333-4444-5555-eeeeeeeeeeee This example demonstrates how to retrieve direct reports for a user in Microsoft Entra ID. -- `-ObjectId` Parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` Parameter specifies the ID of a user (UserPrincipalName or UserId). ### Example 2: Get all direct reports ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserDirectReport -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserDirectReport -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -76,13 +76,13 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example demonstrates how to retrieve all direct reports for a user in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the ID of a user (UserPrincipalName or UserId). ### Example 3: Get a top two direct reports ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserDirectReport -ObjectId 'SawyerM@contoso.com' -Top 2 +Get-EntraUserDirectReport -UserId 'SawyerM@contoso.com' -Top 2 ``` ```Output @@ -94,7 +94,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example demonstrates how to retrieve top five direct reports for a user in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the ID of a user (UserPrincipalName or UserId). ## Parameters @@ -114,14 +114,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user's UserPrincipalName or ObjectId in Microsoft Entra ID. +Specifies the ID of a user's UserPrincipalName or UserId in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserManager.md index 522c0b4df..c053a5f63 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserManager.md @@ -27,7 +27,7 @@ Gets the manager of a user. ```powershell Get-EntraUserManager - -ObjectId + -UserId [-Property ] [] ``` @@ -35,7 +35,7 @@ Get-EntraUserManager ## Description The `Get-EntraUserManager` cmdlet gets the manager of a user in Microsoft Entra ID. Specify -`ObjectId` parameter to get the specific manager of user. +`UserId` parameter to get the specific manager of user. ## Examples @@ -43,7 +43,7 @@ The `Get-EntraUserManager` cmdlet gets the manager of a user in Microsoft Entra ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserManager -ObjectId 'SawyerM@contoso.com' +Get-EntraUserManager -UserId 'SawyerM@contoso.com' ``` ```Output @@ -62,18 +62,18 @@ displayName : Sawyer Miller This example demonstrates how to retrieve the manager of a specific user. -- `-ObjectId` Parameter specifies ObjectID or User Principal Name of User. +- `-UserId` Parameter specifies UserId or User Principal Name of User. ## Parameters -### -ObjectId +### -UserId -The unique identifier of a user in Microsoft Entra ID (User Principal Name or ObjectId). +The unique identifier of a user in Microsoft Entra ID (User Principal Name or UserId). ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedDevice.md index 309cb4c2a..b6f4ade3c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedDevice.md @@ -27,7 +27,7 @@ Get registered devices owned by a user. ```powershell Get-EntraUserOwnedDevice - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraUserOwnedDevice` cmdlet gets registered devices owned by the speci ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserOwnedDevice -ObjectId 'SawyerM@contoso.com' +Get-EntraUserOwnedDevice -UserId 'SawyerM@contoso.com' ``` ```Output @@ -60,7 +60,7 @@ This command gets the registered devices owned by the specified user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserOwnedDevice -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserOwnedDevice -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -76,7 +76,7 @@ This command gets all the registered devices owned by the specified user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserOwnedDevice -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraUserOwnedDevice -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -105,14 +105,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedObject.md index 6561f974c..cc4f9de59 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOwnedObject.md @@ -27,7 +27,7 @@ Get objects owned by a user. ```powershell Get-EntraUserOwnedObject - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraUserOwnedObject ## Description -The `Get-EntraUserOwnedObject` cmdlet gets objects owned by a user in Microsoft Entra ID. Specify `ObjectId` parameter to get objects owned by user. +The `Get-EntraUserOwnedObject` cmdlet gets objects owned by a user in Microsoft Entra ID. Specify `UserId` parameter to get objects owned by user. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraUserOwnedObject` cmdlet gets objects owned by a user in Microsoft ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserOwnedObject -ObjectId 'SawyerM@contoso.com' +Get-EntraUserOwnedObject -UserId 'SawyerM@contoso.com' ``` ```Output @@ -60,7 +60,7 @@ hhhhhhhh-5555-6666-7777-iiiiiiiiiiii This example retrieves objects owned by the specified user. -- `-ObjectId` Parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` Parameter specifies the ID of a user as a UserPrincipalName or UserId. ### Example 2: Get objects owned by a user with additional details @@ -92,7 +92,7 @@ This example retrieves objects owned by the specified user with more lookup deta ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserOwnedObject -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserOwnedObject -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -108,13 +108,13 @@ hhhhhhhh-5555-6666-7777-iiiiiiiiiiii This example retrieves all the objects owned by the specified user. -- `-ObjectId` parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` parameter specifies the ID of a user as a UserPrincipalName or UserId. ### Example 4: Get top three objects owned by a user ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserOwnedObject -ObjectId 'SawyerM@contoso.com' -Top 3 +Get-EntraUserOwnedObject -UserId 'SawyerM@contoso.com' -Top 3 ``` ```Output @@ -127,7 +127,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example retrieves the top three objects owned by the specified user. -- `-ObjectId` parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` parameter specifies the ID of a user as a UserPrincipalName or UserId. ## Parameters @@ -147,14 +147,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserRegisteredDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserRegisteredDevice.md index 348f572e0..c58d964a6 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserRegisteredDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserRegisteredDevice.md @@ -26,7 +26,7 @@ Get devices registered by a user. ```powershell Get-EntraUserRegisteredDevice - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraUserRegisteredDevice` cmdlet gets devices registered by a user in ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' +Get-EntraUserRegisteredDevice -UserId 'SawyerM@contoso.com' ``` ```Output @@ -59,7 +59,7 @@ This command gets the devices that are registered to the specified user. ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserRegisteredDevice -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -75,7 +75,7 @@ This command gets all the devices that are registered to the specified user. ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraUserRegisteredDevice -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -104,14 +104,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md index 975180c11..e92bc799c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md @@ -27,7 +27,7 @@ Creates a password credential for an application. ```powershell New-EntraApplicationPasswordCredential - -ObjectId + -ApplicationId [-CustomKeyIdentifier ] [-StartDate ] [-EndDate ] @@ -45,7 +45,7 @@ The `New-EntraApplicationPasswordCredential` cmdlet creates a password credentia ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq ''" -New-EntraApplicationPasswordCredential -ObjectId $application.Id +New-EntraApplicationPasswordCredential -ApplicationId $application.Id ``` ```Output @@ -56,7 +56,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. ### Example 2: Create a password credential using CustomKeyIdentifier parameter @@ -64,7 +64,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq ''" $params = @{ - ObjectId = $application.Id + ApplicationId = $application.Id CustomKeyIdentifier = '' } @@ -79,7 +79,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-CustomKeyIdentifier` Speicifies unique binary identifier. ### Example 3: Create a password credential using StartDate parameter @@ -88,7 +88,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq ''" $params = @{ - ObjectId = $application.Id + ApplicationId = $application.Id StartDate = (Get-Date).AddYears(0) CustomKeyIdentifier = '' } @@ -104,7 +104,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-StartDate` Speicifies the date and time at which the password becomes valid. ### Example 4: Create a password credential using EndDate parameter @@ -113,7 +113,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq ''" $params = @{ - ObjectId = $application.Id + ApplicationId = $application.Id EndDate = (Get-Date).AddYears(2) CustomKeyIdentifier = '' } @@ -129,19 +129,19 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-EndDate` Speicifies The date and time at which the password expires. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplicationLogo.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplicationLogo.md index 0e9f0bc8c..a16ecb356 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplicationLogo.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraApplicationLogo.md @@ -28,7 +28,7 @@ Sets the logo for an Application ```powershell Set-EntraApplicationLogo - -ObjectId + -ApplicationId -FilePath [] ``` @@ -37,7 +37,7 @@ Set-EntraApplicationLogo ```powershell Set-EntraApplicationLogo - -ObjectId + -ApplicationId [] ``` @@ -45,7 +45,7 @@ Set-EntraApplicationLogo ```powershell Set-EntraApplicationLogo - -ObjectId + -ApplicationId [] ``` @@ -55,7 +55,7 @@ The `Set-EntraApplicationLogo` cmdlet is used to set the logo for an application ## Examples -### Example 1: Sets the application logo for the application specified by the ObjectID parameter +### Example 1: Sets the application logo for the application specified by the ApplicationId parameter ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' @@ -67,7 +67,7 @@ $params = @{ Set-EntraApplicationLogo @params ``` -This cmdlet sets the application logo for the application specified by the `-ObjectId` parameter to the image specified with the `-FilePath` parameter. +This cmdlet sets the application logo for the application specified by the `-ApplicationId` parameter to the image specified with the `-FilePath` parameter. ## Parameters @@ -75,7 +75,7 @@ This cmdlet sets the application logo for the application specified by the `-Obj The file path of the file that is to be uploaded as the application logo. -```yaml +```yamlset-EntraApplicationLogo Type: System.String Parameter Sets: File Aliases: @@ -87,14 +87,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId -The ObjectID of the Application for which the logo is set. +The ApplicationId of the Application for which the logo is set. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: False Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraIdentityProvider.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraIdentityProvider.md index 8f9fc6cd6..0df279f66 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraIdentityProvider.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraIdentityProvider.md @@ -27,7 +27,7 @@ Update the properties of an existing identity provider configured in the directo ```powershell Set-EntraIdentityProvider - -Id + -IdentityProviderBaseId [-Type ] [-ClientSecret ] [-ClientId ] @@ -48,7 +48,7 @@ The type of the identity provider can't be modified. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' ClientId = 'NewClientID' } Set-EntraIdentityProvider @params @@ -64,7 +64,7 @@ This example updates the client ID for the specified identity provider. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' ClientSecret = 'NewClientSecret' } Set-EntradentityProvider @params @@ -80,7 +80,7 @@ This example updates the client secret for the specified identity provider. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' Name = 'NewGoogleName' } Set-EntraIdentityProvider @params @@ -125,14 +125,13 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id - +### -IdentityProviderBaseId The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 index 211bbff13..50c7b5f89 100644 --- a/test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 @@ -13,24 +13,24 @@ BeforeAll { Describe "Add-EntraApplicationOwner" { Context "Test for Add-EntraApplicationOwner" { It "Should return empty object"{ - $result = Add-EntraApplicationOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraApplicationOwner -ApplicationId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when parameters are empty" { - { Add-EntraApplicationOwner -ObjectId "" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + { Add-EntraApplicationOwner -ApplicationId "" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter*" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraApplicationOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraApplicationOwner -ApplicationId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-1111-2222-3333-cccccccccccc" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraApplicationOwner" - Add-EntraApplicationOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraApplicationOwner -ApplicationId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraApplicationOwner" Should -Invoke -CommandName New-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -44,7 +44,7 @@ Describe "Add-EntraApplicationOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraApplicationOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraApplicationOwner -ApplicationId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraApplicationLogo.Tests.ps1 b/test/module/Entra/Get-EntraApplicationLogo.Tests.ps1 index cd55842ef..093e9e754 100644 --- a/test/module/Entra/Get-EntraApplicationLogo.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationLogo.Tests.ps1 @@ -22,37 +22,42 @@ BeforeAll { } Describe "Get-EntraApplicationLogo" { + It "Should return empty" { + $result = Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should return empty" { $result = Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return empty when passed ileName parameter" { - $result = Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FileName "image" + $result = Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FileName "image" $result | Should -BeNullOrEmpty } It "Should fail when FileName is empty" { - { Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FileName } | Should -Throw "Missing an argument for parameter 'FileName'*" + { Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FileName } | Should -Throw "Missing an argument for parameter 'FileName'*" } It "Should return empty when passed ileName parameter" { - $result = Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View $true + $result = Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View $true $result | Should -BeNullOrEmpty } It "Should fail when View is invalid" { - { Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View "cc" } | Should -Throw "Cannot process argument transformation on parameter 'View'*" + { Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View "cc" } | Should -Throw "Cannot process argument transformation on parameter 'View'*" } It "Should fail when View is empty" { - { Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View } | Should -Throw "Missing an argument for parameter 'View'*" + { Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -View } | Should -Throw "Missing an argument for parameter 'View'*" } - It "Should fail when ObjectId is empty" { - { Get-EntraApplicationLogo -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Get-EntraApplicationLogo -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraApplicationLogo -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Get-EntraApplicationLogo -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationLogo" - Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" + Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationLogo" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -66,7 +71,7 @@ Describe "Get-EntraApplicationLogo" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraApplicationLogo -ObjectId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" -Debug } | Should -Not -Throw + { Get-EntraApplicationLogo -ApplicationId "aaaaaaaa-1111-2222-3333-ccccccccccc" -FilePath "D:\image.jpg" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 index ebde421cd..c0de5b74f 100644 --- a/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 @@ -32,18 +32,18 @@ BeforeAll { Describe "Get-EntraApplicationOwner"{ Context "Test for Get-EntraApplicationOwner"{ It "Should return application owner" { - $result = Get-EntraApplicationOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraApplicationOwner -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" Write-Host $result $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb') Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraApplicationOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is empty" { + { Get-EntraApplicationOwner -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Should fail when ObjectId is null" { - { Get-EntraApplicationOwner -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Get-EntraApplicationOwner -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when All has an argument" { { Get-EntraApplicationOwner -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" @@ -55,13 +55,13 @@ Describe "Get-EntraApplicationOwner"{ { Get-EntraApplicationOwner -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Property parameter should work" { - $result = Get-EntraApplicationOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraApplicationOwner -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationOwner" - $result = Get-EntraApplicationOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraApplicationOwner -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationOwner" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -76,7 +76,7 @@ Describe "Get-EntraApplicationOwner"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraApplicationOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraApplicationOwner -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 index 115c04eeb..126b30ab1 100644 --- a/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 @@ -27,21 +27,21 @@ BeforeAll { Describe "Get-EntraApplicationPasswordCredential" { Context "Test for Get-EntraApplicationPasswordCredential" { It "Should not return empty" { - $result = Get-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Get-EntraApplicationPasswordCredential -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Get-EntraApplicationPasswordCredential -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when invalid parameter is passed" { { Get-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" } It "Property parameter should work" { - $result = Get-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be "Test" @@ -49,12 +49,12 @@ BeforeAll { } It "Should fail when Property is empty" { - { Get-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationPasswordCredential" - $result = Get-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationPasswordCredential" Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -69,7 +69,7 @@ BeforeAll { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraContact.Tests.ps1 b/test/module/Entra/Get-EntraContact.Tests.ps1 index d6f2760e6..1ba8b88d6 100644 --- a/test/module/Entra/Get-EntraContact.Tests.ps1 +++ b/test/module/Entra/Get-EntraContact.Tests.ps1 @@ -48,6 +48,20 @@ BeforeAll { Describe "Get-EntraContact" { Context "Test for Get-EntraContact" { It "Should return specific Contact" { + $result = Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + $result.OnPremisesSyncEnabled | Should -BeNullOrEmpty + $result.OnPremisesLastSyncDateTime | Should -BeNullOrEmpty + $result.Phones | Should -BeNullOrEmpty + $result.ServiceProvisioningErrors | Should -BeNullOrEmpty + $result.Mobile | Should -BeNullOrEmpty + $result.TelephoneNumber | Should -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgContact -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific Contact alias" { $result = Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -60,13 +74,14 @@ Describe "Get-EntraContact" { Should -Invoke -CommandName Get-MgContact -ModuleName Microsoft.Graph.Entra -Times 1 } + - It "Should fail when ObjectId is empty" { - { Get-EntraContact -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when OrgContactId is empty" { + { Get-EntraContact -OrgContactId } | Should -Throw "Missing an argument for parameter 'OrgContactId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraContact -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when OrgContactId is invalid" { + { Get-EntraContact -OrgContactId "" } | Should -Throw "Cannot bind argument to parameter 'OrgContactId' because it is an empty string." } It "Should return all contact" { @@ -106,31 +121,31 @@ Describe "Get-EntraContact" { { Get-EntraContact -Top xy } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Result should Contain OrgContactId" { + $result = Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } - It "Should contain OrgContactId in parameters when passed ObjectId to it" { - $result = Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain OrgContactId in parameters when passed OrgContactId to it" { + $result = Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result.Parameters $params.OrgContactId | Should -Match "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } It "Property parameter should work" { - $result = Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property DisplayName + $result = Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Bob Kelly (TAILSPIN)' Should -Invoke -CommandName Get-MgContact -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraContact" - $result = Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraContact" @@ -148,7 +163,7 @@ Describe "Get-EntraContact" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraContact -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Get-EntraContact -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDeviceRegisteredOwner.Tests.ps1 b/test/module/Entra/Get-EntraDeviceRegisteredOwner.Tests.ps1 index 18c3b502f..1588867f3 100644 --- a/test/module/Entra/Get-EntraDeviceRegisteredOwner.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeviceRegisteredOwner.Tests.ps1 @@ -36,20 +36,27 @@ BeforeAll { Describe "Get-EntraDeviceRegisteredOwner" { Context "Test for Get-EntraDeviceRegisteredOwner" { It "Should return specific device registered owner" { + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific device registered owner with alias" { $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraDeviceRegisteredOwner -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DeviceId is empty" { + { Get-EntraDeviceRegisteredOwner -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraDeviceRegisteredOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when DeviceId is invalid" { + { Get-EntraDeviceRegisteredOwner -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } It "Should return all device registered owner" { - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -57,24 +64,24 @@ Describe "Get-EntraDeviceRegisteredOwner" { } It "Should fail when All is invalid" { - { Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" + { Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" } It "Should return top device registered owner" { - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should contain Alias property" { - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.DeletionTimestamp | should -Be $null $result.DirSyncEnabled | should -Be $null @@ -89,7 +96,7 @@ Describe "Get-EntraDeviceRegisteredOwner" { } It "Should contain DeviceId in parameters when passed Name to it" { - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $para= $params | ConvertTo-json | ConvertFrom-Json $para.URI | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" @@ -97,7 +104,7 @@ Describe "Get-EntraDeviceRegisteredOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeviceRegisteredOwner" - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeviceRegisteredOwner" @@ -109,7 +116,7 @@ Describe "Get-EntraDeviceRegisteredOwner" { } It "Property parameter should work" { - $result = Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property mobilePhone + $result = Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property mobilePhone $result | Should -Not -BeNullOrEmpty $result.mobilePhone | Should -Be '425-555-0100' @@ -117,7 +124,7 @@ Describe "Get-EntraDeviceRegisteredOwner" { } It "Should fail when Property is empty" { - { Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error" { @@ -127,7 +134,7 @@ Describe "Get-EntraDeviceRegisteredOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDeviceRegisteredUser.Tests.ps1 b/test/module/Entra/Get-EntraDeviceRegisteredUser.Tests.ps1 index a0aa4e9df..34aa7d687 100644 --- a/test/module/Entra/Get-EntraDeviceRegisteredUser.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeviceRegisteredUser.Tests.ps1 @@ -36,20 +36,27 @@ BeforeAll { Describe "Get-EntraDeviceRegisteredUser" { Context "Test for Get-EntraDeviceRegisteredUser" { It "Should return specific device registered User" { + $result = Get-EntraDeviceRegisteredUser -DeviceId "8542ebd1-3d49-4073-9dce-30f197c67755" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific device registered User with alias" { $result = Get-EntraDeviceRegisteredUser -ObjectId "8542ebd1-3d49-4073-9dce-30f197c67755" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraDeviceRegisteredUser -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DeviceId is empty" { + { Get-EntraDeviceRegisteredUser -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraDeviceRegisteredUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when DeviceId is invalid" { + { Get-EntraDeviceRegisteredUser -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } It "Should return all device registered owner" { - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -57,21 +64,21 @@ Describe "Get-EntraDeviceRegisteredUser" { } It "Should return top device registered owner" { - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should contain Alias property" { - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.DeletionTimestamp | should -Be $null $result.DirSyncEnabled | should -Be $null @@ -86,7 +93,7 @@ Describe "Get-EntraDeviceRegisteredUser" { } It "Should contain DeviceId in parameters when passed Name to it" { - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $Para= $params | ConvertTo-json | ConvertFrom-Json $para.URI | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" @@ -94,7 +101,7 @@ Describe "Get-EntraDeviceRegisteredUser" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeviceRegisteredUser" - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $a= $params | ConvertTo-json | ConvertFrom-Json $a.headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -103,7 +110,7 @@ Describe "Get-EntraDeviceRegisteredUser" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeviceRegisteredUser" - $result = Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeviceRegisteredUser" @@ -115,7 +122,7 @@ Describe "Get-EntraDeviceRegisteredUser" { } It "Should fail when Property is empty" { - { Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error" { @@ -125,7 +132,7 @@ Describe "Get-EntraDeviceRegisteredUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 index a107c363f..941d47518 100644 --- a/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 @@ -35,6 +35,14 @@ BeforeAll { Describe "Get-EntraDirectoryRoleDefinition" { Context "Test for Get-EntraDirectoryRoleDefinition" { It "Should return specificrole Defination" { + $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | Should -Be "Mock-App" + $result.Id | Should -Be "0000aaaa-11bb-cccc-dd22-eeeeee333333" + + Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specificrole Defination With Alias" { $result = Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be "Mock-App" @@ -42,11 +50,11 @@ Describe "Get-EntraDirectoryRoleDefinition" { Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraDirectoryRoleDefinition -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when DirectoryRoleId is empty" { + { Get-EntraDirectoryRoleDefinition -DirectoryRoleId } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'*" } - It "Should fail when Id is invalid" { - { Get-EntraDirectoryRoleDefinition -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when DirectoryRoleId is invalid" { + { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } It "Should return all role assignments" { $result = Get-EntraDirectoryRoleDefinition -All @@ -90,7 +98,7 @@ Describe "Get-EntraDirectoryRoleDefinition" { { Get-EntraDirectoryRoleDefinition -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" } It "Result should Contain ObjectId" { - $result = Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" + $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" $result.ObjectId | should -Be "0000aaaa-11bb-cccc-dd22-eeeeee333333" } It "Should contain Filter in parameters when passed SearchString to it" { @@ -99,19 +107,19 @@ Describe "Get-EntraDirectoryRoleDefinition" { $params.Filter | Should -Match "Mock-App" } It "Property parameter should work" { - $result = Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property DisplayName + $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleDefinition" - Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" + Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleDefinition" @@ -127,7 +135,7 @@ Describe "Get-EntraDirectoryRoleDefinition" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDirectoryRoleDefinition -Id "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Debug } | Should -Not -Throw + { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDirectoryRoleMember.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRoleMember.Tests.ps1 index 298a59403..a24871e3a 100644 --- a/test/module/Entra/Get-EntraDirectoryRoleMember.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRoleMember.Tests.ps1 @@ -30,20 +30,27 @@ BeforeAll { Describe "EntraDirectoryRoleMember" { Context "Test for EntraDirectoryRoleMember" { It "Should return specific directory rolemember" { + $result = (Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb") | ConvertTo-json | ConvertFrom-json + $result | Should -Not -BeNullOrEmpty + $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific directory rolemember with alias" { $result = (Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb") | ConvertTo-json | ConvertFrom-json $result | Should -Not -BeNullOrEmpty $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraDirectoryRoleMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DirectoryRoleId is empty" { + { Get-EntraDirectoryRoleMember -DirectoryRoleId } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraDirectoryRoleMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when DirectoryRoleId is invalid" { + { Get-EntraDirectoryRoleMember -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string.*" } It "Result should Contain Alias property" { - $result = Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.DirSyncEnabled | should -Be $null $result.LastDirSyncTime | should -Be $null @@ -51,27 +58,27 @@ Describe "EntraDirectoryRoleMember" { $result.ProvisioningErrors | Should -BeNullOrEmpty $result.TelephoneNumber | should -Be "425-555-0100" } - It "Should contain ObjectId in URI" { - $result = Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain DirectoryRoleId in URI" { + $result = Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $Para= $params | ConvertTo-json | ConvertFrom-Json $Para.URI | Should -match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleMember" - Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleMember" @@ -87,7 +94,7 @@ Describe "EntraDirectoryRoleMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraGroupMember.Tests.ps1 b/test/module/Entra/Get-EntraGroupMember.Tests.ps1 index a30b6124f..93ff0695b 100644 --- a/test/module/Entra/Get-EntraGroupMember.Tests.ps1 +++ b/test/module/Entra/Get-EntraGroupMember.Tests.ps1 @@ -27,19 +27,17 @@ BeforeAll { Describe "Get-EntraGroupMember" { Context "Test for Get-EntraGroupMember" { It "Should return specific group" { - $result = Get-EntraGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Contain 'bbbbbbbb-1111-2222-3333-cccccccccccc' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - - It "Should fail when ObjectId is invalid" { - { Get-EntraGroupMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraGroupMember -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - - It "Should fail when ObjectId is empty" { - { Get-EntraGroupMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraGroupMember -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } It "Should fail when Top is empty" { @@ -51,18 +49,17 @@ Describe "Get-EntraGroupMember" { } It "Should return all group" { - $result = Get-EntraGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result = Get-EntraGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" - } - + { Get-EntraGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + } It "Should return top group" { - $result = Get-EntraGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 + $result = @(Get-EntraGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1) $result | Should -Not -BeNullOrEmpty $result | Should -HaveCount 1 @@ -84,7 +81,7 @@ Describe "Get-EntraGroupMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupMember" - $result = Get-EntraGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupMember" diff --git a/test/module/Entra/Get-EntraGroupOwner.Tests.ps1 b/test/module/Entra/Get-EntraGroupOwner.Tests.ps1 index 1fd46c400..99c92ed68 100644 --- a/test/module/Entra/Get-EntraGroupOwner.Tests.ps1 +++ b/test/module/Entra/Get-EntraGroupOwner.Tests.ps1 @@ -34,7 +34,15 @@ BeforeAll { Describe "Get-EntraGroupOwner" { Context "Test for Get-EntraGroupOwner" { - It "Get a group owner by Id" { + It "Get a group owner by GroupId" { + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' + $result.DeletedDateTime | should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Get a group owner by alias" { $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' @@ -43,54 +51,54 @@ Describe "Get-EntraGroupOwner" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraGroupOwner -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraGroupOwner -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraGroupOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraGroupOwner -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Gets all group owners" { - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } It "Gets two group owners" { - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 2 + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 2 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top XY} | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top XY} | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Result should Contain GroupId" { + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } - It "Should contain GroupId in parameters when passed ObjectId to it" { - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should contain GroupId in parameters when passed GroupId to it" { + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $groupId= $params | ConvertTo-json | ConvertFrom-Json $groupId.Uri -match "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -BeTrue } It "Property parameter should work" { - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" @@ -98,13 +106,13 @@ Describe "Get-EntraGroupOwner" { } It "Should fail when Property is empty" { - { Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupOwner" - $result = Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupOwner" @@ -122,7 +130,7 @@ Describe "Get-EntraGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraGroupOwner -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraGroupOwner -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraSubscribedSku.Tests.ps1 b/test/module/Entra/Get-EntraSubscribedSku.Tests.ps1 index 2d92feaa7..108d31293 100644 --- a/test/module/Entra/Get-EntraSubscribedSku.Tests.ps1 +++ b/test/module/Entra/Get-EntraSubscribedSku.Tests.ps1 @@ -36,17 +36,24 @@ $scriptblock = { Describe "Get-EntraSubscribedSku" { Context "Test for Get-EntraSubscribedSku" { It "Should return specific SubscribedSku" { + $result = Get-EntraSubscribedSku -SubscribedSkuId "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" + + Should -Invoke -CommandName Get-MgSubscribedSku -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific SubscribedSku with alias" { $result = Get-EntraSubscribedSku -ObjectId "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" Should -Invoke -CommandName Get-MgSubscribedSku -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId empty" { - { Get-EntraSubscribedSku -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when SubscribedSkuId empty" { + { Get-EntraSubscribedSku -SubscribedSkuId } | Should -Throw "Missing an argument for parameter 'SubscribedSkuId'*" } - It "Should fail when ObjectId invalid" { - { Get-EntraSubscribedSku -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when SubscribedSkuId invalid" { + { Get-EntraSubscribedSku -SubscribedSkuId "" } | Should -Throw "Cannot bind argument to parameter 'SubscribedSkuId' because it is an empty string." } It "Should return all SubscribedSku" { $result = Get-EntraSubscribedSku @@ -83,7 +90,7 @@ Describe "Get-EntraSubscribedSku" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraSubscribedSku -ObjectId "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" -Debug } | Should -Not -Throw + { Get-EntraSubscribedSku -SubscribedSkuId "00001111-aaaa-2222-bbbb-3333cccc4444_11112222-bbbb-3333-cccc-4444dddd5555" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserCreatedObject.Tests.ps1 b/test/module/Entra/Get-EntraUserCreatedObject.Tests.ps1 index da2688fd6..73d29e283 100644 --- a/test/module/Entra/Get-EntraUserCreatedObject.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserCreatedObject.Tests.ps1 @@ -55,6 +55,14 @@ BeforeAll { Describe "Get-EntraUserCreatedObject" { Context "Test for Get-EntraUserCreatedObject" { It "Should return specific User" { + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgUserCreatedObject -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific User with alias" { $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty @@ -62,41 +70,41 @@ Describe "Get-EntraUserCreatedObject" { Should -Invoke -CommandName Get-MgUserCreatedObject -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string value" { - { Get-EntraUserCreatedObject -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Get-EntraUserCreatedObject -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraUserCreatedObject -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraUserCreatedObject -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should return all contact" { - $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserCreatedObject -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } It "Should return top user" { - $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserCreatedObject -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top HH } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top HH } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -104,7 +112,7 @@ Describe "Get-EntraUserCreatedObject" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserCreatedObject" - $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserCreatedObject" @@ -116,7 +124,7 @@ Describe "Get-EntraUserCreatedObject" { } It "Property parameter should work" { - $result = Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property appDisplayName + $result = Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property appDisplayName $result | Should -Not -BeNullOrEmpty $result.appDisplayName | Should -Be "Microsoft Graph Command Line Tools" @@ -124,7 +132,7 @@ Describe "Get-EntraUserCreatedObject" { } It "Should fail when Property is empty" { - { Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error" { @@ -134,7 +142,7 @@ Describe "Get-EntraUserCreatedObject" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserCreatedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserCreatedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserDirectReport.Tests.ps1 b/test/module/Entra/Get-EntraUserDirectReport.Tests.ps1 index 419df4cfb..ca3f93239 100644 --- a/test/module/Entra/Get-EntraUserDirectReport.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserDirectReport.Tests.ps1 @@ -37,53 +37,60 @@ BeforeAll { Describe "Get-EntraUserDirectReport" { Context "Test for Get-EntraUserDirectReport" { It "Should return specific user direct report" { + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific user direct report with alias" { $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraUserDirectReport -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraUserDirectReport -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraUserDirectReport -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when UserId is invalid" { + { Get-EntraUserDirectReport -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string.*" } It "Should return all user direct reports" { - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 user direct report" { - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Property parameter should work" { - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be "Mock-User" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Result should contain Properties" { - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.DeletionTimestamp | Should -Be $null $result.DirSyncEnabled | Should -Be $null @@ -96,16 +103,16 @@ Describe "Get-EntraUserDirectReport" { $result.UserStateChangedOn | Should -Be $null } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $para= $params | ConvertTo-json | ConvertFrom-Json $para.URI | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserDirectReport" - $result = Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserDirectReport" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -120,7 +127,7 @@ Describe "Get-EntraUserDirectReport" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserDirectReport -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserDirectReport -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserManager.Tests.ps1 b/test/module/Entra/Get-EntraUserManager.Tests.ps1 index befa64f50..4abfdbc63 100644 --- a/test/module/Entra/Get-EntraUserManager.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserManager.Tests.ps1 @@ -38,6 +38,24 @@ BeforeAll { Describe "Get-EntraUserManager" { Context "Test for Get-EntraUserManager" { It "Should return specific User" { + $result = Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.ageGroup | Should -BeNullOrEmpty + $result.onPremisesLastSyncDateTime | Should -BeNullOrEmpty + $result.creationType | Should -BeNullOrEmpty + $result.imAddresses | Should -Be @("test@contoso.com") + $result.preferredLanguage | Should -BeNullOrEmpty + $result.mail | Should -Be "test@contoso.com" + $result.securityIdentifier | Should -Be "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result.identities | Should -HaveCount 1 + $result.identities[0].signInType | Should -Be "userPrincipalName" + $result.identities[0].issuer | Should -Be "contoso.com" + $result.identities[0].issuerAssignedId | Should -Be "test@contoso.com" + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific User wit alias" { $result = Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $result.ageGroup | Should -BeNullOrEmpty @@ -55,16 +73,16 @@ Describe "Get-EntraUserManager" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string value" { - { Get-EntraUserManager -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Get-EntraUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraUserManager -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraUserManager -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result.Parameters $params.Uri | Should -Match "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } @@ -72,7 +90,7 @@ Describe "Get-EntraUserManager" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserManager" - $result = Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserManager" @@ -84,7 +102,7 @@ Describe "Get-EntraUserManager" { } It "Property parameter should work" { - $result = Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id + $result = Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -92,7 +110,7 @@ Describe "Get-EntraUserManager" { } It "Should fail when Property is empty" { - { Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error" { @@ -102,7 +120,7 @@ Describe "Get-EntraUserManager" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserManager -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Get-EntraUserManager -UserId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserOwnedDevice.Tests.ps1 b/test/module/Entra/Get-EntraUserOwnedDevice.Tests.ps1 index 74ce4bac7..6d31703e5 100644 --- a/test/module/Entra/Get-EntraUserOwnedDevice.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserOwnedDevice.Tests.ps1 @@ -48,6 +48,16 @@ BeforeAll { Describe "Get-EntraUserOwnedDevice" { Context "Test for Get-EntraUserOwnedDevice" { It "Should get devices owned by a user" { + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" + $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-3333-4444-5555-bbbbbbbbbbbb" + $result.AdditionalProperties.displayName | Should -Be "Sawyer Miller" + + Should -Invoke -CommandName Get-MgUserOwnedDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should get devices owned by a user with alias" { $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" @@ -58,20 +68,20 @@ Context "Test for Get-EntraUserOwnedDevice" { } It "Property parameter should work" { - $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Property DisplayName $result.Id | Should -Be 'aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb' } It "Should fail when ObjectlId is empty" { - { Get-EntraUserOwnedDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraUserOwnedDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } It "Should fail when ObjectlId is invalid" { - { Get-EntraUserOwnedDevice -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraUserOwnedDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should get all devices owned by a user" { - $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -All + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | Should -Contain "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" @@ -83,7 +93,7 @@ Context "Test for Get-EntraUserOwnedDevice" { } It "Should get top one device owned by a user" { - $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-2222-3333-4444-bbbbbbbbbbbb" $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-3333-4444-5555-bbbbbbbbbbbb" @@ -93,22 +103,22 @@ Context "Test for Get-EntraUserOwnedDevice" { } It "Should fail when Top is empty" { - { Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top "XCX" } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Top "XCX" } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOwnedDevice" - $result = Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOwnedDevice" Should -Invoke -CommandName Get-MgUserOwnedDevice -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -123,7 +133,7 @@ Context "Test for Get-EntraUserOwnedDevice" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserOwnedDevice -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserOwnedDevice -UserId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserOwnedObject.Tests.ps1 b/test/module/Entra/Get-EntraUserOwnedObject.Tests.ps1 index f6ee59f74..55f025d0a 100644 --- a/test/module/Entra/Get-EntraUserOwnedObject.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserOwnedObject.Tests.ps1 @@ -31,7 +31,7 @@ BeforeAll { Describe "Get-EntraUserOwnedObject" { Context "Test for Get-EntraUserOwnedObject" { It "Should return specific User" { - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -44,42 +44,55 @@ Describe "Get-EntraUserOwnedObject" { should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } + It "Should return specific User with alias" { + $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result.applicationTemplateId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.appId | Should -Be "11112222-bbbb-3333-cccc-4444dddd5555" + $result.signInAudience | Should -Be "AzureADMyOrg" + $result.publisherDomain | Should -Be "contoso.com" + $result.DisplayName | Should -Be "ToGraph_443DEM" - It "Should fail when ObjectId is empty string value" { - { Get-EntraUserOwnedObject -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + + should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when UserId is empty string value" { + { Get-EntraUserOwnedObject -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraUserOwnedObject -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraUserOwnedObject -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should return top user" { - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return all contact" { - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.Uri | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -87,7 +100,7 @@ Describe "Get-EntraUserOwnedObject" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOwnedObject" - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOwnedObject" @@ -99,7 +112,7 @@ Describe "Get-EntraUserOwnedObject" { } It "Property parameter should work" { - $result = Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property displayName + $result = Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property displayName $result | Should -Not -BeNullOrEmpty $result.displayName | Should -Be "ToGraph_443DEM" @@ -107,7 +120,7 @@ Describe "Get-EntraUserOwnedObject" { } It "Should fail when Property is empty" { - { Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error" { @@ -117,7 +130,7 @@ Describe "Get-EntraUserOwnedObject" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserOwnedObject -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserOwnedObject -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserRegisteredDevice.Tests.ps1 b/test/module/Entra/Get-EntraUserRegisteredDevice.Tests.ps1 index d8d895bc3..3d09369cd 100644 --- a/test/module/Entra/Get-EntraUserRegisteredDevice.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserRegisteredDevice.Tests.ps1 @@ -35,6 +35,15 @@ BeforeAll { Describe "Get-EntraUserRegisteredDevice" { Context "Test for Get-EntraUserRegisteredDevice" { It "Should return specific user registered device" { + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "ffffffff-5555-6666-7777-aaaaaaaaaaaa" + $result.AdditionalProperties.deviceId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.AdditionalProperties.displayName | Should -Be "Mock-App" + + Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific user registered device with alias" { $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "ffffffff-5555-6666-7777-aaaaaaaaaaaa" @@ -44,13 +53,13 @@ Context "Test for Get-EntraUserRegisteredDevice" { Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ObjectlId is empty" { - { Get-EntraUserRegisteredDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } It "Should fail when ObjectlId is invalid" { - { Get-EntraUserRegisteredDevice -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return All user registered devices" { - $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "ffffffff-5555-6666-7777-aaaaaaaaaaaa" $result.AdditionalProperties.deviceId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" @@ -59,10 +68,10 @@ Context "Test for Get-EntraUserRegisteredDevice" { Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 user registered device" { - $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "ffffffff-5555-6666-7777-aaaaaaaaaaaa" $result.AdditionalProperties.deviceId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" @@ -71,29 +80,29 @@ Context "Test for Get-EntraUserRegisteredDevice" { Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Property parameter should work" { - $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.AdditionalProperties.displayName | Should -Be "Mock-App" Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserRegisteredDevice" - $result = Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserRegisteredDevice" Should -Invoke -CommandName Get-MgUserRegisteredDevice -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -108,7 +117,7 @@ Context "Test for Get-EntraUserRegisteredDevice" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserRegisteredDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserRegisteredDevice -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 index a83231fd8..6a309f0e2 100644 --- a/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 +++ b/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 @@ -26,53 +26,53 @@ BeforeAll { } Describe "New-EntraApplicationPasswordCredential"{ It "Should return created password credential"{ - $result = New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.KeyId | should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $result.SecretText | Should -Be "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { New-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { New-EntraApplicationPasswordCredential -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { New-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { New-EntraApplicationPasswordCredential -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when StartDate is empty" { - { New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate "" } | Should -Throw "Cannot process argument transformation on parameter 'StartDate'*" + { New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate "" } | Should -Throw "Cannot process argument transformation on parameter 'StartDate'*" } It "Should fail when StartDate is null" { - { New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate } | Should -Throw "Missing an argument for parameter 'StartDate'*" + { New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate } | Should -Throw "Missing an argument for parameter 'StartDate'*" } It "Should fail when EndDate is empty" { - { New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate "" } | Should -Throw "Cannot process argument transformation on parameter 'EndDate'*" + { New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate "" } | Should -Throw "Cannot process argument transformation on parameter 'EndDate'*" } It "Should fail when EndDate is null" { - { New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate } | Should -Throw "Missing an argument for parameter 'EndDate'*" + { New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate } | Should -Throw "Missing an argument for parameter 'EndDate'*" } It "Should fail when invalid parameter is passed" { { New-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "should contain startDateTime in body parameter when passed StartDate to it"{ - $result = New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate (get-date).AddYears(0) + $result = New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -StartDate (get-date).AddYears(0) $params = Get-Parameters -data $result.Parameters $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json $a.startDateTime | Should -Not -BeNullOrEmpty } It "should contain endDateTime in body parameter when passed EndDate to it"{ - $result = New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate (get-date).AddYears(0) + $result = New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -EndDate (get-date).AddYears(0) $params = Get-Parameters -data $result.Parameters $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json $a.endDateTime | Should -Not -BeNullOrEmpty } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationPasswordCredential" - $result = New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationPasswordCredential" Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -87,7 +87,7 @@ Describe "New-EntraApplicationPasswordCredential"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraApplicationPasswordCredential -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { New-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraApplicationLogo.Tests.ps1 b/test/module/Entra/Set-EntraApplicationLogo.Tests.ps1 index 18b271160..c051aa861 100644 --- a/test/module/Entra/Set-EntraApplicationLogo.Tests.ps1 +++ b/test/module/Entra/Set-EntraApplicationLogo.Tests.ps1 @@ -13,23 +13,29 @@ BeforeAll { Describe "Set-EntraApplicationLogo"{ Context "Test for Set-EntraApplicationLogo" { It "Should return empty object"{ + $result = Set-EntraApplicationLogo -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias"{ $result = Set-EntraApplicationLogo -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraApplicationLogo -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + + It "Should fail when ApplicationId is empty" { + { Set-EntraApplicationLogo -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Set-EntraApplicationLogo -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Set-EntraApplicationLogo -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when filepath invalid"{ - { Set-EntraApplicationLogo -ObjectId f82a3f32-6bb6-404b-843c-5512fb3b35b8 -FilePath "sdd" } | Should -Throw "FilePath is invalid" + { Set-EntraApplicationLogo -ApplicationId f82a3f32-6bb6-404b-843c-5512fb3b35b8 -FilePath "sdd" } | Should -Throw "FilePath is invalid" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplicationLogo" - Set-EntraApplicationLogo -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" + Set-EntraApplicationLogo -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplicationLogo" @@ -45,7 +51,7 @@ Describe "Set-EntraApplicationLogo"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraApplicationLogo -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" -Debug } | Should -Not -Throw + { Set-EntraApplicationLogo -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" -FilePath "https://th.bing.com/th?q=Application+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From e6fbfc73328b691a3f022a16df68469096c9ce68 Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Wed, 25 Sep 2024 22:42:05 +0530 Subject: [PATCH 28/64] parameter updates (#1065) * parameter updates * updates * updates * updates * updates * updated mock cases * updated * updated --------- Co-authored-by: Snehal Kotwal (Perennial Systems Inc) --- .../Add-EntraBetaDeviceRegisteredUser.md | 10 +-- .../Get-EntraBetaDirectoryRoleAssignment.md | 12 +-- ...raBetaServicePrincipalAppRoleAssignedTo.md | 18 ++--- ...raBetaServicePrincipalAppRoleAssignment.md | 18 ++--- .../Remove-EntraBetaDeviceRegisteredUser.md | 10 +-- ...Remove-EntraBetaDirectoryRoleAssignment.md | 13 +-- ...Remove-EntraBetaDirectoryRoleDefinition.md | 13 ++- ...raBetaServicePrincipalAppRoleAssignment.md | 10 +-- .../Set-EntraBetaDirectoryRoleDefinition.md | 80 +++++++++---------- .../Add-EntraDeviceRegisteredUser.md | 10 +-- .../Get-EntraDirectoryRoleAssignment.md | 12 +-- ...-EntraServicePrincipalAppRoleAssignedTo.md | 12 +-- ...-EntraServicePrincipalAppRoleAssignment.md | 12 +-- .../Remove-EntraDeviceRegisteredUser.md | 10 +-- .../Remove-EntraDirectoryRoleAssignment.md | 11 +-- .../Remove-EntraDirectoryRoleDefinition.md | 13 ++- ...-EntraServicePrincipalAppRoleAssignment.md | 18 ++--- .../Set-EntraDirectoryRoleDefinition.md | 68 ++++++---------- .../Add-EntraDeviceRegisteredUser.Tests.ps1 | 30 ++++--- ...Get-EntraDirectoryRoleAssignment.Tests.ps1 | 26 +++--- ...ervicePrincipalAppRoleAssignedTo.Tests.ps1 | 61 +++++++++----- ...ervicePrincipalAppRoleAssignment.Tests.ps1 | 55 +++++++++---- ...Remove-EntraDeviceRegisteredUser.Tests.ps1 | 28 ++++--- ...ove-EntraDirectoryRoleAssignment.Tests.ps1 | 20 +++-- ...ove-EntraDirectoryRoleDefinition.Tests.ps1 | 20 +++-- ...ervicePrincipalAppRoleAssignment.Tests.ps1 | 38 ++++++--- ...Set-EntraDirectoryRoleDefinition.Tests.ps1 | 36 +++++---- 27 files changed, 368 insertions(+), 296 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md index c02904aa9..6882839af 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md @@ -27,7 +27,7 @@ Adds a registered user for a device. ```powershell Add-EntraBetaDeviceRegisteredUser - -ObjectId + -DeviceId -RefObjectId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Device.ReadWrite.All' $User = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' $Device = Get-EntraBetaDevice -SearchString '' $params = @{ - ObjectId = $Device.ObjectId + DeviceId = $Device.ObjectId RefObjectId = $User.ObjectId } Add-EntraBetaDeviceRegisteredUser @params @@ -53,20 +53,20 @@ Add-EntraBetaDeviceRegisteredUser @params This example shows how to add a registered user to a device. -- `-ObjectId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraBetaDevice` to get device Id. +- `-DeviceId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraBetaDevice` to get device Id. - `-RefObjectId` parameter specifies the unique identifier (Object ID) of the user who will be added as a registered user of the device. The $User.ObjectId variable should contain the Object ID of the user. You can use the command `Get-EntraBetaUser` to get user Id. ## Parameters -### -ObjectId +### -DeviceId Specifies the ID of the device. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleAssignment.md index 7d80e58d6..9e7e5f304 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleAssignment.md @@ -39,7 +39,7 @@ Get-EntraBetaDirectoryRoleAssignment ```powershell Get-EntraBetaDirectoryRoleAssignment - -Id + -UnifiedRoleAssignmentId [-All] [-Property ] [] @@ -56,7 +56,7 @@ Get-EntraBetaDirectoryRoleAssignment ## Description -The `Get-EntraBetaDirectoryRoleAssignment` cmdlet gets information about role assignments in Microsoft Entra ID. To get a role assignment, specify the `Id` parameter. Specify the `SearchString` or `Filter` parameter to find a particular role assignment. +The `Get-EntraBetaDirectoryRoleAssignment` cmdlet gets information about role assignments in Microsoft Entra ID. To get a role assignment, specify the `UnifiedRoleAssignmentId` parameter. Specify the `SearchString` or `Filter` parameter to find a particular role assignment. In delegated scenarios with work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: @@ -114,7 +114,7 @@ This command gets all the role assignments in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory','EntitlementManagement.Read.All' -Get-EntraBetaDirectoryRoleAssignment -Id '00001111-aaaa-2222-bbbb-3333cccc4444' +Get-EntraBetaDirectoryRoleAssignment -UnifiedRoleAssignmentId '00001111-aaaa-2222-bbbb-3333cccc4444' ``` ```Output @@ -125,7 +125,7 @@ Id PrincipalId Ro This command gets the role assignments using specified roleAssignment Id. -- `Id` parameter specifies the roleAssignment object ID. +- `UnifiedRoleAssignmentId` parameter specifies the roleAssignment object ID. ### Example 4: Get role assignments filter by principalId @@ -213,14 +213,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -Id +### -UnifiedRoleAssignmentId The unique identifier of a Microsoft Entra ID roleAssignment object. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignedTo.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignedTo.md index 8941ee434..3aad9b28f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignedTo.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignedTo.md @@ -27,7 +27,7 @@ Gets app role assignments for this app or service, granted to users, groups and ```powershell Get-EntraBetaServicePrincipalAppRoleAssignedTo - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -56,7 +56,7 @@ For delegated scenarios, the calling user needs at least one of the following Mi ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalAppRoleAssignedTo -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalAppRoleAssignedTo -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -67,14 +67,14 @@ Id AppRoleId This example shows how to get app role assignments for an app or service, granted to users, groups and other service principals. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ### Example 2: Get all app role assignments ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" - Get-EntraBetaServicePrincipalAppRoleAssignedTo -ObjectId $ServicePrincipal.ObjectId -All + Get-EntraBetaServicePrincipalAppRoleAssignedTo -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -89,14 +89,14 @@ Id AppRoleId This command gets the all app role assignments for the service principal granted to users, groups and other service principals. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ### Example 3: Get five app role assignments ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalAppRoleAssignedTo -ObjectId $ServicePrincipal.ObjectId -Top 5 +Get-EntraBetaServicePrincipalAppRoleAssignedTo -ServicePrincipalId $ServicePrincipal.ObjectId -Top 5 ``` ```Output @@ -111,7 +111,7 @@ Id AppRoleId This command gets the five app role assignments for the service principal granted to users, groups and other service principals. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ## Parameters @@ -131,14 +131,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignment.md index b3dc9b615..9a5107689 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalAppRoleAssignment.md @@ -27,7 +27,7 @@ Gets a service principal application role assignment. ```powershell Get-EntraBetaServicePrincipalAppRoleAssignment - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -56,7 +56,7 @@ For delegated scenarios, the calling user needs at least one of the following Mi ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" - Get-EntraBetaServicePrincipalAppRoleAssignment -ObjectId $ServicePrincipal.ObjectId + Get-EntraBetaServicePrincipalAppRoleAssignment -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -67,14 +67,14 @@ Id AppRoleId This command gets application role assignments for specified service principal. You can use the command `Get-EntraBetaServicePrincipal` to get service principal Id. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ### Example 2: Retrieve all application role assignments for a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" - Get-EntraBetaServicePrincipalAppRoleAssignment -ObjectId $ServicePrincipal.ObjectId -All + Get-EntraBetaServicePrincipalAppRoleAssignment -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -89,14 +89,14 @@ Id AppRoleId This command gets all application role assignments for specified service principal. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ### Example 3: Retrieve the top three application role assignments for a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalAppRoleAssignment -ObjectId $ServicePrincipal.ObjectId -Top 3 +Get-EntraBetaServicePrincipalAppRoleAssignment -ServicePrincipalId $ServicePrincipal.ObjectId -Top 3 ``` ```Output @@ -109,7 +109,7 @@ Id AppRoleId This command gets top three application role assignments for specified service principal. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ## Parameters @@ -129,14 +129,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md index 229afe3d0..910e0ff37 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md @@ -27,7 +27,7 @@ Removes a registered user from a device. ```powershell Remove-EntraBetaDeviceRegisteredUser - -ObjectId + -DeviceId -UserId [] ``` @@ -43,22 +43,22 @@ The `Remove-EntraBetaDeviceRegisteredUser` cmdlet removes a registered user from ```Powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraBetaDevice -Top 1 -$User = Get-EntraBetaDeviceRegisteredUser -ObjectId $Device.ObjectId -Remove-EntraBetaDeviceRegisteredUser -ObjectId $Device.ObjectId -OwnerId $Owner.ObjectId +$User = Get-EntraBetaDeviceRegisteredUser -DeviceId $Device.ObjectId +Remove-EntraBetaDeviceRegisteredUser -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId ``` This example shows how to remove the registered user from device. ## Parameters -### -ObjectId +### -DeviceId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md index f9fcab52d..70467da70 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md @@ -26,7 +26,7 @@ Delete a Microsoft Entra ID roleAssignment. ```powershell Remove-EntraBetaDirectoryRoleAssignment - -Id + -UnifiedRoleAssignmentId [] ``` @@ -39,24 +39,25 @@ The `Remove-EntraBetaDirectoryRoleAssignment` cmdlet removes a role assignment f ### Example 1: Remove a role assignment ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory','EntitlementManagement.ReadWrite.All' -Remove-EntraBetaDirectoryRoleAssignment -Id 'Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1' + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' #For the directory (Microsoft Entra ID) provider + Connect-Entra -Scopes 'EntitlementManagement.ReadWrite.All' #For the entitlement management provider + Remove-EntraBetaDirectoryRoleAssignment -UnifiedRoleAssignmentId 'Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1' ``` This example removes the specified role assignment from Microsoft Entra ID. -- `-Id` parameter specifies the role assignment ID. +- `-UnifiedRoleAssignmentId` parameter specifies the role assignment ID. ## Parameters -### -Id +### -UnifiedRoleAssignmentId The unique identifier of an object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: 0 diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md index e24ce1f5e..aac13c062 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md @@ -26,7 +26,7 @@ Delete a Microsoft Entra ID Directory roleDefinition object. ```powershell Remove-EntraBetaDirectoryRoleDefinition - -Id + -UnifiedRoleDefinitionId [] ``` @@ -41,25 +41,24 @@ You can't delete built-in roles. This feature requires a Microsoft Entra ID P1 o ### Example 1: Remove a specified role definition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$DirectoryRoleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq 'Guest Inviter'" -Remove-EntraBetaDirectoryRoleDefinition -Id $DirectoryRoleDefinition.ObjectId + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + Remove-EntraBetaDirectoryRoleDefinition -UnifiedRoleDefinitionId 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' ``` This example demonstrates how to remove the specified role definition from Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. ## Parameters -### -Id +### -UnifiedRoleDefinitionId The unique identifier of an object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: 0 diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalAppRoleAssignment.md index 7cbd3366a..89848d1ec 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalAppRoleAssignment.md @@ -27,7 +27,7 @@ Removes a service principal application role assignment. ```powershell Remove-EntraBetaServicePrincipalAppRoleAssignment - -ObjectId + -ServicePrincipalId -AppRoleAssignmentId [] ``` @@ -57,7 +57,7 @@ For delegated scenarios, the calling user needs at least one of the following Mi Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId AppRoleAssignmentId = '2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6' } @@ -66,7 +66,7 @@ Remove-EntraBetaServicePrincipalAppRoleAssignment @params This example demonstrates how to remove a service principal application role assignment in Microsoft Entra ID. -- `-ObjectId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. +- `-ServicePrincipalId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. - `-AppRoleAssignmentId` - specifies the unique identifier (ID) of the app role assignment that you want to remove. The value `2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6` represents the ID of the specific app role assignment to be removed. @@ -88,14 +88,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md index f7a18e36e..b6392aefb 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md @@ -26,7 +26,7 @@ Update an existing Microsoft Entra ID roleDefinition. ```powershell Set-EntraBetaDirectoryRoleDefinition - -Id + -UnifiedRoleDefinitionId [-IsEnabled ] [-InheritsPermissionsFrom ] [-Version ] @@ -47,78 +47,74 @@ Updates a Microsoft Entra roleDefinition object identified by ID. You can't upda ### Example 1: Update an roleDefinition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - DisplayName = 'UpdatedDisplayName' -} -Set-EntraBetaDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + $params = @{ + UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' + DisplayName = 'UpdatedDisplayName' + } + Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-DisplayName` parameter specifies the display name for the role definition. ### Example 2: Update an roleDefinition with Description ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - Description = 'MYROLEUPDATE1S' -} -Set-EntraBetaDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + $params = @{ + UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' + Description = 'MYROLEUPDATE1S' + } + Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the Description of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-Description` parameter specifies the description for the role definition. ### Example 3: Update an roleDefinition with IsEnabled ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - IsEnabled = $true -} -Set-EntraBetaDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + $params = @{ + UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' + IsEnabled = $true + } + Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the IsEnabled of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-IsEnabled` parameter specifies whether the role definition is enabled. ### Example 4: Update an roleDefinition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" -$RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission -$RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") -$params = @{ - Id = $roleDefinition.ObjectId - Description = 'Update' - DisplayName = 'Update' - ResourceScopes = '/' - IsEnabled = $false - RolePermissions = $RolePermissions - TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' - Version = 2 -} + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission + $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") + $params = @{ + UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' + Description = 'Update' + DisplayName = 'Update' + ResourceScopes = '/' + IsEnabled = $false + RolePermissions = $RolePermissions + TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' + Version = 2 + } Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the RolePermissions, TemplateId, TemplateId, ResourceScopes of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-RolePermissions` parameter specifies the permissions for the role definition. - `-IsEnabled` parameter specifies whether the role definition is enabled. - `-DisplayName` parameter specifies the display name for the role definition. @@ -161,14 +157,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -UnifiedRoleDefinitionId Specifies the roleDefinition object ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md index 1d0398982..8ca18f41e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md @@ -27,7 +27,7 @@ Adds a registered user for a device. ```powershell Add-EntraDeviceRegisteredUser - -ObjectId + -DeviceId -RefObjectId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Device.ReadWrite.All' $User = Get-EntraUser -ObjectId 'SawyerM@contoso.com' $Device = Get-EntraDevice -SearchString '' $params = @{ - ObjectId = $Device.ObjectId + DeviceId = $Device.ObjectId RefObjectId = $User.ObjectId } Add-EntraDeviceRegisteredUser @params @@ -53,20 +53,20 @@ Add-EntraDeviceRegisteredUser @params This example shows how to add a registered user to a device. -- `-ObjectId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraDevice` to get device Id. +- `-DeviceId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraDevice` to get device Id. - `-RefObjectId` parameter specifies the unique identifier (Object ID) of the user who will be added as a registered user of the device. The $User.ObjectId variable should contain the Object ID of the user. You can use the command `Get-EntraUser` to get user Id. ## Parameters -### -ObjectId +### -DeviceId Specifies the ID of the device. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleAssignment.md index 94fbb08da..7c86ba6f9 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleAssignment.md @@ -48,7 +48,7 @@ Get-EntraDirectoryRoleAssignment ```powershell Get-EntraDirectoryRoleAssignment - -Id + -UnifiedRoleAssignmentId [-All] [-Property ] [] @@ -56,7 +56,7 @@ Get-EntraDirectoryRoleAssignment ## Description -The `Get-EntraDirectoryRoleAssignment` cmdlet gets information about role assignments in Microsoft Entra ID. To get a role assignment, specify the `Id` parameter. Specify the `SearchString` or `Filter` parameter to find a particular role assignment. +The `Get-EntraDirectoryRoleAssignment` cmdlet gets information about role assignments in Microsoft Entra ID. To get a role assignment, specify the `UnifiedRoleAssignmentId` parameter. Specify the `SearchString` or `Filter` parameter to find a particular role assignment. In delegated scenarios with work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: @@ -114,7 +114,7 @@ This command gets all the role assignments in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory','EntitlementManagement.Read.All' -Get-EntraDirectoryRoleAssignment -Id '00001111-aaaa-2222-bbbb-3333cccc4444' +Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId '00001111-aaaa-2222-bbbb-3333cccc4444' ``` ```Output @@ -125,7 +125,7 @@ Id PrincipalId Ro This command gets the role assignments using specified roleAssignment Id. -- `Id` parameter specifies the roleAssignment object ID. +- `UnifiedRoleAssignmentId` parameter specifies the roleAssignment object ID. ### Example 4: Get role assignments filter by principalId @@ -180,14 +180,14 @@ This command gets top two role assignments. ## Parameters -### -Id +### -UnifiedRoleAssignmentId The unique identifier of a Microsoft Entra ID roleAssignment object. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignedTo.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignedTo.md index 41c616179..891274acd 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignedTo.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignedTo.md @@ -26,7 +26,7 @@ Gets app role assignments for this app or service, granted to users, groups and ```powershell Get-EntraServicePrincipalAppRoleAssignedTo - -ObjectId + -ServicePrincipalId [-All ] [-Top ] [-Property ] @@ -55,7 +55,7 @@ For delegated scenarios, the calling user needs at least one of the following Mi ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId - Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId $ServicePrincipalId + Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId $ServicePrincipalId ``` This example shows how to get app role assignments for an app or service, granted to users, groups and other service principals. @@ -68,7 +68,7 @@ This example shows how to get app role assignments for an app or service, grante ```powershell Connect-Entra -Scopes 'Application.Read.All' - Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId 00001111-aaaa-2222-bbbb-3333cccc4444 -All + Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId 00001111-aaaa-2222-bbbb-3333cccc4444 -All ``` ```output @@ -86,7 +86,7 @@ This command gets the all app role assignments for the service principal granted ### Example 3: Get five app role assignments ```powershell - Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId 00001111-aaaa-2222-bbbb-3333cccc4444 -Top 5 + Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId 00001111-aaaa-2222-bbbb-3333cccc4444 -Top 5 ``` ```Output @@ -119,14 +119,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md index e7672455e..f5f413180 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md @@ -26,7 +26,7 @@ Gets a service principal application role assignment. ```powershell Get-EntraServicePrincipalAppRoleAssignment - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraServicePrincipalAppRoleAssignment` cmdlet gets a role assignment f ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId - Get-EntraServicePrincipalAppRoleAssignment -ObjectId $ServicePrincipalId + Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId $ServicePrincipalId ``` ```Output @@ -63,7 +63,7 @@ This command gets application role assignments for specified service principal. ```powershell Connect-Entra -Scopes 'Application.Read.All' - Get-EntraServicePrincipalAppRoleAssignment -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' -All + Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' -All ``` ```Output @@ -82,7 +82,7 @@ This command gets all application role assignments for specified service princip ```powershell Connect-Entra -Scopes 'Application.Read.All' - Get-EntraServicePrincipalAppRoleAssignment -ObjectId '00001111-aaaa-2222-bbbb-3333cccc4444' -Top 3 + Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId '00001111-aaaa-2222-bbbb-3333cccc4444' -Top 3 ``` ```Output @@ -113,14 +113,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md index 4b1a2c4c9..79e3631e7 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md @@ -26,7 +26,7 @@ Removes a registered user from a device. ```powershell Remove-EntraDeviceRegisteredUser - -ObjectId + -DeviceId -UserId [] ``` @@ -42,22 +42,22 @@ The `Remove-EntraDeviceRegisteredUser` cmdlet removes a registered user from a M ```Powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraDevice -Top 1 -$User = Get-EntraDeviceRegisteredUser -ObjectId $Device.ObjectId -Remove-EntraDeviceRegisteredOwner -ObjectId $Device.ObjectId -OwnerId $Owner.ObjectId +$User = Get-EntraDeviceRegisteredUser -DeviceId $Device.ObjectId +Remove-EntraDeviceRegisteredOwner -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId ``` This example shows how to remove the registered user from device. ## Parameters -### -ObjectId +### -DeviceId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md index cb54592f6..bee29b3b1 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md @@ -26,7 +26,7 @@ Delete a Microsoft Entra ID roleAssignment. ```powershell Remove-EntraDirectoryRoleAssignment - -Id + -UnifiedRoleAssignmentId [] ``` @@ -39,8 +39,9 @@ The `Remove-EntraDirectoryRoleAssignment` cmdlet removes a role assignment from ### Example 1: Remove a role assignment ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory','EntitlementManagement.ReadWrite.All' -Remove-EntraDirectoryRoleAssignment -Id 'Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1' + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' #For the directory (Microsoft Entra ID) provider + Connect-Entra -Scopes 'EntitlementManagement.ReadWrite.All' #For the entitlement management provider + Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1 ``` This example removes the specified role assignment from Microsoft Entra ID. @@ -49,14 +50,14 @@ This example removes the specified role assignment from Microsoft Entra ID. ## Parameters -### -Id +### -UnifiedRoleAssignmentId The unique identifier of an object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: 0 diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md index c92a9e2ce..49dd26d35 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md @@ -27,7 +27,7 @@ Delete a Microsoft Entra ID Directory roleDefinition object. ```powershell Remove-EntraDirectoryRoleDefinition - -Id + -UnifiedRoleDefinitionId [] ``` @@ -42,25 +42,24 @@ You can't delete built-in roles. This feature requires a Microsoft Entra ID P1 o ### Example 1: Remove a specified role definition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$DirectoryRoleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq 'Guest Inviter'" -Remove-EntraDirectoryRoleDefinition -Id $DirectoryRoleDefinition.ObjectId + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 ``` This example demonstrates how to remove the specified role definition from Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. ## Parameters -### -Id +### -UnifiedRoleDefinitionId The unique identifier of an object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: 0 diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md index 0a205738f..56525891a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md @@ -27,8 +27,8 @@ Removes a service principal application role assignment. ```powershell Remove-EntraServicePrincipalAppRoleAssignment - -AppRoleAssignmentId - -ObjectId + -AppRoleAssignmentId + -ServicePrincipalId [] ``` @@ -55,18 +55,12 @@ For delegated scenarios, the calling user needs at least one of the following Mi ```powershell Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' -$servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -$params = @{ - ObjectId = $servicePrincipal.ObjectId - AppRoleAssignmentId = '2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6' -} - -Remove-EntraServicePrincipalAppRoleAssignment @params +Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId '11112222-bbbb-3333-cccc-4444dddd5555' -AppRoleAssignmentId '2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6' ``` This example demonstrates how to remove a service principal application role assignment in Microsoft Entra ID. -- `-ObjectId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. +- `-ServicePrincipalId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. In this example, `11112222-bbbb-3333-cccc-4444dddd5555` is the Object ID of the target service principal or user. - `-AppRoleAssignmentId` - specifies the unique identifier (ID) of the app role assignment that you want to remove. The value `2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6` represents the ID of the specific app role assignment to be removed. @@ -88,14 +82,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md index 286ac17e2..f84bac18f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md @@ -29,7 +29,7 @@ Set-EntraDirectoryRoleDefinition [-TemplateId ] [-DisplayName ] [-RolePermissions ] --Id +-UnifiedRoleDefinitionId [-Description ] [-Version ] [-IsEnabled ] @@ -46,78 +46,62 @@ Updates a Microsoft Entra roleDefinition object identified by ID. You can't upda ### Example 1: Update an roleDefinition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - DisplayName = 'UpdatedDisplayName' -} -Set-EntraDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -DisplayName 'UpdatedDisplayName' ``` This example updates the specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-DisplayName` parameter specifies the display name for the role definition. ### Example 2: Update an roleDefinition with Description ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - Description = 'MYROLEUPDATE1S' -} -Set-EntraDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -Description 'MYROLEUPDATE1S' ``` This example updates the Description of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-Description` parameter specifies the description for the role definition. ### Example 3: Update an roleDefinition with IsEnabled ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" -$params = @{ - Id = $roleDefinition.ObjectId - IsEnabled = $true -} -Set-EntraDirectoryRoleDefinition @params + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -IsEnabled $true ``` This example updates the IsEnabled of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-IsEnabled` parameter specifies whether the role definition is enabled. ### Example 4: Update an roleDefinition ```powershell -Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' -$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" -$RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission -$RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") -$params = @{ - Id = $roleDefinition.ObjectId - Description = 'Update' - DisplayName = 'Update' - ResourceScopes = '/' - IsEnabled = $false - RolePermissions = $RolePermissions - TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' - Version = 2 -} + Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' + $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission + $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") + $params = @{ + UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' + Description = 'Update' + DisplayName = 'Update' + ResourceScopes = '/' + IsEnabled = $false + RolePermissions = $RolePermissions + TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' + Version = 2 + } Set-EntraDirectoryRoleDefinition @params ``` This example updates the RolePermissions, TemplateId, TemplateId, ResourceScopes of specified role definition in Microsoft Entra ID. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. - `-RolePermissions` parameter specifies the permissions for the role definition. - `-IsEnabled` parameter specifies whether the role definition is enabled. - `-DisplayName` parameter specifies the display name for the role definition. @@ -128,14 +112,14 @@ This example updates the RolePermissions, TemplateId, TemplateId, ResourceScopes ## Parameters -### -Id +### -UnifiedRoleDefinitionId Specifies the roleDefinition object ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/Entra/Add-EntraDeviceRegisteredUser.Tests.ps1 b/test/module/Entra/Add-EntraDeviceRegisteredUser.Tests.ps1 index 756a6761b..3b581ef33 100644 --- a/test/module/Entra/Add-EntraDeviceRegisteredUser.Tests.ps1 +++ b/test/module/Entra/Add-EntraDeviceRegisteredUser.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Add-EntraDeviceRegisteredUser" { Context "Test for Add-EntraDeviceRegisteredUser" { It "Should return empty object" { - $result = Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraDeviceRegisteredUser -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when DeviceId is empty" { + { Add-EntraDeviceRegisteredUser -DeviceId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DeviceId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraDeviceRegisteredUser -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DeviceId is invalid" { + { Add-EntraDeviceRegisteredUser -DeviceId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain DeviceId in parameters when passed ObjectId to it" { + It "Should execute successfully with Alias" { + $result = Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should contain DeviceId in parameters when passed DeviceId to it" { Mock -CommandName New-MgDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain BodyParameter in parameters when passed RefObjectId to it" { Mock -CommandName New-MgDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $value = @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbbbbb-1111-2222-3333-cccccccccccc"} Should -Invoke -CommandName New-MgDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -52,7 +58,7 @@ Describe "Add-EntraDeviceRegisteredUser" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDeviceRegisteredUser" - Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDeviceRegisteredUser" @@ -69,7 +75,7 @@ Describe "Add-EntraDeviceRegisteredUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDirectoryRoleAssignment.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRoleAssignment.Tests.ps1 index d45d30fa8..c5cc6ec69 100644 --- a/test/module/Entra/Get-EntraDirectoryRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRoleAssignment.Tests.ps1 @@ -32,16 +32,22 @@ BeforeAll { Describe "Get-EntraDirectoryRoleAssignment" { Context "Test for Get-EntraDirectoryRoleAssignment" { It "Should return specific role assignment" { + $result = Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraDirectoryRoleAssignment -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when Get-EntraDirectoryRoleAssignment is empty" { + { Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId } | Should -Throw "Missing an argument for parameter 'UnifiedRoleAssignmentId'*" } - It "Should fail when Id is invalid" { - { Get-EntraDirectoryRoleAssignment -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when Get-EntraDirectoryRoleAssignment is invalid" { + { Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'UnifiedRoleAssignmentId' because it is an empty string." } It "Should return all role assignments" { $result = Get-EntraDirectoryRoleAssignment -All @@ -76,28 +82,28 @@ Describe "Get-EntraDirectoryRoleAssignment" { } It "Result should Contain ObjectId" { - $result = Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result = Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $result.ObjectId | should -Be "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" } It "Should contain UnifiedRoleAssignmentId in parameters when passed Id to it" { - $result = Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result = Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $params = Get-Parameters -data $result.Parameters $params.UnifiedRoleAssignmentId | Should -Be "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" } It "Property parameter should work" { - $result = Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Property PrincipalId + $result = Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Property PrincipalId $result | Should -Not -BeNullOrEmpty $result.PrincipalId | Should -Be 'aaaaaaaa-bbbb-cccc-1111-222222222222' Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleAssignment" - Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleAssignment" @@ -113,7 +119,7 @@ Describe "Get-EntraDirectoryRoleAssignment" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Debug } | Should -Not -Throw + { Get-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignedTo.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignedTo.Tests.ps1 index be1b10fe7..df71bf8d6 100644 --- a/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignedTo.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignedTo.Tests.ps1 @@ -29,56 +29,77 @@ BeforeAll { Describe "Get-EntraServicePrincipalAppRoleAssignedTo" { Context "Test for Get-EntraServicePrincipalAppRoleAssignedTo" { It "Should return app role assignments" { - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" $result | Should -Not -BeNullOrEmpty $result.PrincipalId | should -Be '4d8fcb23-adc7-4d47-9328-2420eb1075ef' Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should execute successfully with Alias" { + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" + $result | Should -Not -BeNullOrEmpty + $result.PrincipalId | should -Be '4d8fcb23-adc7-4d47-9328-2420eb1075ef' + + Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - {Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" + } + It "Should fail when ServicePrincipalId is invalid" { + {Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should return all app role assignments" { - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -All + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return top app role assignments " { - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -top 1 + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" - $result.ObjectId | should -Be "I8uPTcetR02TKCQg6xB170ZWgaqJluBEqPHHxTxJ9Hs" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" + $result.ObjectID | should -Be "I8uPTcetR02TKCQg6xB170ZWgaqJluBEqPHHxTxJ9Hs" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { Mock -CommandName Get-MgServicePrincipalAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" + $result = Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "4d8fcb23-adc7-4d47-9328-2420eb1075ef" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgServicePrincipalAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignedTo" + $result= Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" + $result | Should -Not -BeNullOrEmpty + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignedTo" + Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' - $result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - } + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraServicePrincipalAppRoleAssignedTo -ServicePrincipalId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } } } \ No newline at end of file diff --git a/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignment.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignment.Tests.ps1 index c98ddabfb..34372eeeb 100644 --- a/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalAppRoleAssignment.Tests.ps1 @@ -29,57 +29,78 @@ BeforeAll { Describe "Get-EntraServiceAppRoleAssigned" { Context "Test for Get-EntraServiceAppRoleAssigned" { It "Should return service principal application role assignment." { + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" + $result | Should -Not -BeNullOrEmpty + $result.ResourceId | should -Be '021510b7-e753-40aa-b668-29753295ca34' + + Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" $result | Should -Not -BeNullOrEmpty $result.ResourceId | should -Be '021510b7-e753-40aa-b668-29753295ca34' Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraServicePrincipalAppRoleAssignment -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraServicePrincipalAppRoleAssignment -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is invalid" { + { Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should return all service principal application role assignment." { - $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" -All + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return top service principal application role assignment." { - $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" -top 1 + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" -top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" + It "Result should Contain ServicePrincipalId" { + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" $result.ObjectId | should -Be "qjltmaz9l02qPcgftHNirITXiOnmHR5GmW_oEXl_ZL8" } It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { Mock -CommandName Get-MgServicePrincipalAppRoleAssignedTo -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "021510b7-e753-40aa-b668-29753295ca34" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgServicePrincipalAppRoleAssignedTo -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignment" + $result = Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" + $result | Should -Not -BeNullOrEmpty + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignment" + Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' - $result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - } + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "021510b7-e753-40aa-b668-29753295ca34" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } } } \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraDeviceRegisteredUser.Tests.ps1 b/test/module/Entra/Remove-EntraDeviceRegisteredUser.Tests.ps1 index 253e50113..b2f4e8fa4 100644 --- a/test/module/Entra/Remove-EntraDeviceRegisteredUser.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDeviceRegisteredUser.Tests.ps1 @@ -14,34 +14,40 @@ BeforeAll { Describe "Remove-EntraDeviceRegisteredUser" { Context "Test for Remove-EntraDeviceRegisteredUser" { It "Should return empty object" { - $result = Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraDeviceRegisteredUser -ObjectId -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'ObjectId'*" } + It "Should execute successfully with Alias" { + $result = Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DeviceId is empty" { + { Remove-EntraDeviceRegisteredUser -DeviceId -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'DeviceId'*" } } - It "Should fail when ObjectId is invalid" { - { Remove-EntraDeviceRegisteredUser -ObjectId "" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" } + It "Should fail when DeviceId is invalid" { + { Remove-EntraDeviceRegisteredUser -DeviceId "" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } } It "Should fail when UserId is empty" { - { Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId | Should -Throw "Missing an argument for parameter 'UserId'*" } + { Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId | Should -Throw "Missing an argument for parameter 'UserId'*" } } It "Should fail when UserId is invalid" { - { Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "" | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string.*" } + { Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "" | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string.*" } } It "Should contain DeviceId in parameters when passed UserId to it" { Mock -CommandName Remove-MgDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain DirectoryObjectId in parameters when passed UserId to it" { Mock -CommandName Remove-MgDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -49,7 +55,7 @@ Describe "Remove-EntraDeviceRegisteredUser" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeviceRegisteredUser" - Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeviceRegisteredUser" @@ -66,7 +72,7 @@ Describe "Remove-EntraDeviceRegisteredUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraDirectoryRoleAssignment.Tests.ps1 b/test/module/Entra/Remove-EntraDirectoryRoleAssignment.Tests.ps1 index 0294f4481..dfe4307d6 100644 --- a/test/module/Entra/Remove-EntraDirectoryRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDirectoryRoleAssignment.Tests.ps1 @@ -13,28 +13,34 @@ BeforeAll { Describe "Remove-EntraDirectoryRoleAssignment" { Context "Test for Remove-EntraDirectoryRoleAssignment" { It "Should return empty object" { + $result = Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgRoleManagementDirectoryRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgRoleManagementDirectoryRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Remove-EntraDirectoryRoleAssignment -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when UnifiedRoleAssignmentId is empty" { + { Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId } | Should -Throw "Missing an argument for parameter 'UnifiedRoleAssignmentId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraDirectoryRoleAssignment -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when UnifiedRoleAssignmentId is invalid" { + { Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'UnifiedRoleAssignmentId' because it is an empty string." } It "Should contain UnifiedRoleAssignmentId in parameters when passed Id to it" { Mock -CommandName Remove-MgRoleManagementDirectoryRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + $result = Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $params = Get-Parameters -data $result $params.UnifiedRoleAssignmentId | Should -Be "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleAssignment" - Remove-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" + Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleAssignment" @@ -50,7 +56,7 @@ Describe "Remove-EntraDirectoryRoleAssignment" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDirectoryRoleAssignment -Id "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Debug } | Should -Not -Throw + { Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId "Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraDirectoryRoleDefinition.Tests.ps1 b/test/module/Entra/Remove-EntraDirectoryRoleDefinition.Tests.ps1 index 79cd12682..1b70b45f5 100644 --- a/test/module/Entra/Remove-EntraDirectoryRoleDefinition.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDirectoryRoleDefinition.Tests.ps1 @@ -13,28 +13,34 @@ BeforeAll { Describe "Remove-EntraDirectoryRoleDefinition" { Context "Test for Remove-EntraDirectoryRoleDefinition" { It "Should return empty object" { + $result = Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Remove-EntraDirectoryRoleDefinition -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when UnifiedRoleDefinitionId is empty" { + { Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId } | Should -Throw "Missing an argument for parameter 'UnifiedRoleDefinitionId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraDirectoryRoleDefinition -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string*" + It "Should fail when UnifiedRoleDefinitionId is invalid" { + { Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "" } | Should -Throw "Cannot bind argument to parameter 'UnifiedRoleDefinitionId' because it is an empty string*" } It "Should contain UnifiedRoleDefinitionId in parameters when passed Id to it" { Mock -CommandName Remove-MgRoleManagementDirectoryRoleDefinition -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result $params.UnifiedRoleDefinitionId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleDefinition" - Remove-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleDefinition" @@ -50,7 +56,7 @@ Describe "Remove-EntraDirectoryRoleDefinition" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 b/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 index 640044344..9a505dca2 100644 --- a/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 @@ -11,28 +11,33 @@ BeforeAll { } Describe "Remove-EntraServicePrincipalAppRoleAssignment" { Context "Test for Remove-EntraServicePrincipalAppRoleAssignment" { - It "Should return empty object" { + It "Should return empty ServicePrincipalId" { + $result = Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraServicePrincipalAppRoleAssignment -ObjectId -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww"}| Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when ServicePrincipalId is empty" { + { Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww"}| Should -Throw "Missing an argument for parameter 'ServicePrincipalId'.*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" + It "Should fail when ServicePrincipalId is invalid" { + { Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string.*" } It "Should fail when AppRoleAssignmentId is empty" { - { Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId }| Should -Throw "Missing an argument for parameter 'AppRoleAssignmentId'.*" + { Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId }| Should -Throw "Missing an argument for parameter 'AppRoleAssignmentId'.*" } It "Should fail when AppRoleAssignmentId is invalid" { - { Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleAssignmentId' because it is an empty string.*" + { Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleAssignmentId' because it is an empty string.*" } - It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { Mock -CommandName Remove-MgServicePrincipalAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" + $result = Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" $params = Get-Parameters -data $result $params.ServicePrincipalId | Should -Be "cc7fcc82-ac1b-4785-af47-2ca3b7052886" @@ -41,9 +46,22 @@ Describe "Remove-EntraServicePrincipalAppRoleAssignment" { Mock -CommandName Remove-MgServicePrincipalAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalAppRoleAssignment" - $result = Remove-EntraServicePrincipalAppRoleAssignment -ObjectId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" + $result = Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" $params = Get-Parameters -data $result $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } } } \ No newline at end of file diff --git a/test/module/Entra/Set-EntraDirectoryRoleDefinition.Tests.ps1 b/test/module/Entra/Set-EntraDirectoryRoleDefinition.Tests.ps1 index 3c46286f9..133166f8c 100644 --- a/test/module/Entra/Set-EntraDirectoryRoleDefinition.Tests.ps1 +++ b/test/module/Entra/Set-EntraDirectoryRoleDefinition.Tests.ps1 @@ -13,6 +13,14 @@ BeforeAll { Describe "Set-EntraDirectoryRoleDefinition" { Context "Test for Set-EntraDirectoryRoleDefinition" { It "Should return empty object" { + $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission + $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") + $result = Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 3 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should execute successfully with Alias" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") $result = Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 3 @@ -20,51 +28,51 @@ Describe "Set-EntraDirectoryRoleDefinition" { Should -Invoke -CommandName Update-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Set-EntraDirectoryRoleDefinition -Id -DisplayName 'Mock-App' -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when UnifiedRoleDefinitionId is empty" { + { Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId -DisplayName 'Mock-App' -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Missing an argument for parameter 'UnifiedRoleDefinitionId'*" } - It "Should fail when Id is invalid" { - { Set-EntraDirectoryRoleDefinition -Id "" -IsEnabled $false -DisplayName 'Mock-App' -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 3 } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string*" + It "Should fail when UnifiedRoleDefinitionId is invalid" { + { Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "" -IsEnabled $false -DisplayName 'Mock-App' -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 3 } | Should -Throw "Cannot bind argument to parameter 'UnifiedRoleDefinitionId' because it is an empty string*" } It "Should fail when RolePermissions is empty" { - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions } | Should -Throw "Missing an argument for parameter 'RolePermissions'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions } | Should -Throw "Missing an argument for parameter 'RolePermissions'*" } It "Should fail when IsEnabled is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -IsEnabled } | Should -Throw "Missing an argument for parameter 'IsEnabled'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -IsEnabled } | Should -Throw "Missing an argument for parameter 'IsEnabled'*" } It "Should fail when DisplayName is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'*" } It "Should fail when ResourceScopes is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -ResourceScopes } | Should -Throw "Missing an argument for parameter 'ResourceScopes'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -ResourceScopes } | Should -Throw "Missing an argument for parameter 'ResourceScopes'*" } It "Should fail when Description is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description } | Should -Throw "Missing an argument for parameter 'Description'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description } | Should -Throw "Missing an argument for parameter 'Description'*" } It "Should fail when TemplateId is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -TemplateId } | Should -Throw "Missing an argument for parameter 'TemplateId'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -TemplateId } | Should -Throw "Missing an argument for parameter 'TemplateId'*" } It "Should fail when Version is empty" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - {Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Version } | Should -Throw "Missing an argument for parameter 'Version'*" + {Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Version } | Should -Throw "Missing an argument for parameter 'Version'*" } It "Should contain UnifiedRoleDefinitionId in parameters when passed Id to it" { Mock -CommandName Update-MgRoleManagementDirectoryRoleDefinition -MockWith {$args} -ModuleName Microsoft.Graph.Entra $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - $result = Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 + $result = Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 $params = Get-Parameters -data $result $params.UnifiedRoleDefinitionId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } @@ -73,7 +81,7 @@ Describe "Set-EntraDirectoryRoleDefinition" { $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/basic/read") - Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 + Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraDirectoryRoleDefinition" @@ -91,7 +99,7 @@ Describe "Set-EntraDirectoryRoleDefinition" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraDirectoryRoleDefinition -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 -Debug } | Should -Not -Throw + { Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -RolePermissions $RolePermissions -IsEnabled $false -DisplayName 'Mock-App' -ResourceScopes "/" -Description "Mock-App" -TemplateId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Version 2 -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From af9c5f36099e49681c2b1d1e7aec2ddbe3168da2 Mon Sep 17 00:00:00 2001 From: v-uansari <143997438+v-uansari@users.noreply.github.com> Date: Wed, 25 Sep 2024 22:43:24 +0530 Subject: [PATCH 29/64] Usability parameter changes for autogenerated and custom script (#1063) * get-entragroup * get-entradeletedGroup * EntraGroupAppRoleAssignment * alice changges * alice change * alice changes * alice change * alice added * alice added * alias added * Ut changes * doc updated * UT fix * UT fix * ut change * ut alias changes --------- Co-authored-by: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> --- .../Add-EntraBetaAdministrativeUnitMember.md | 10 ++-- .../Add-EntraBetaApplicationOwner.md | 10 ++-- .../Add-EntraBetaGroupMember.md | 12 ++-- .../Add-EntraBetaGroupOwner.md | 14 ++--- .../Get-EntraBetaAdministrativeUnit.md | 12 ++-- .../Get-EntraBetaAdministrativeUnitMember.md | 26 ++++----- .../Get-EntraBetaDeletedGroup.md | 18 +++--- .../Get-EntraBetaGroup.md | 14 ++--- .../Get-EntraBetaGroupAppRoleAssignment.md | 20 +++---- .../Get-EntraBetaGroupOwner.md | 18 +++--- .../New-EntraBetaGroupAppRoleAssignment.md | 20 +++---- .../Remove-EntraBetaAdministrativeUnit.md | 12 ++-- ...emove-EntraBetaAdministrativeUnitMember.md | 12 ++-- .../Remove-EntraBetaGroupAppRoleAssignment.md | 10 ++-- .../Remove-EntraBetaGroupMember.md | 10 ++-- .../Remove-EntraBetaGroupOwner.md | 12 ++-- .../Remove-EntraBetaScopedRoleMembership.md | 14 ++--- .../Set-EntraBetaAdministrativeUnit.md | 20 +++---- .../Set-EntraBetaUser.md | 30 +++++----- .../Add-EntraGroupMember.md | 8 +-- .../Add-EntraGroupOwner.md | 12 ++-- .../Get-EntraDeletedGroup.md | 18 +++--- .../Microsoft.Graph.Entra/Get-EntraGroup.md | 12 ++-- .../Get-EntraGroupAppRoleAssignment.md | 14 ++--- .../New-EntraGroupAppRoleAssignment.md | 27 +++++---- .../Remove-EntraGroupAppRoleAssignment.md | 22 +++----- .../Remove-EntraGroupMember.md | 20 +++---- .../Remove-EntraGroupOwner.md | 18 ++---- .../Microsoft.Graph.Entra/Set-EntraUser.md | 55 +++++-------------- .../Entra/Add-EntraGroupMember.Tests.ps1 | 24 ++++---- .../Entra/Add-EntraGroupOwner.Tests.ps1 | 22 ++++---- .../Entra/Get-EntraDeletedGroup.Tests.ps1 | 33 +++++++---- test/module/Entra/Get-EntraGroup.Tests.ps1 | 26 ++++++--- .../Get-EntraGroupAppRoleAssignment.Tests.ps1 | 45 +++++++++------ .../New-EntraGroupAppRoleAssignment.Tests.ps1 | 37 ++++++++----- ...move-EntraGroupAppRoleAssignment.Tests.ps1 | 26 +++++---- .../Entra/Remove-EntraGroupMember.Tests.ps1 | 22 ++++---- .../Entra/Remove-EntraGroupOwner.Tests.ps1 | 22 ++++---- test/module/Entra/Set-EntraUser.Tests.ps1 | 22 ++++---- .../Add-EntraBetaGroupMember.Tests.ps1 | 24 ++++---- .../Add-EntraBetaGroupOwner.Tests.ps1 | 24 ++++---- .../Get-EntraBetaAdministrativeUnit.Tests.ps1 | 31 +++++++---- ...ntraBetaAdministrativeUnitMember.Tests.ps1 | 43 +++++++++------ .../EntraBeta/Get-EntraBetaGroup.Tests.ps1 | 28 +++++----- ...move-EntraBetaAdministrativeUnit.Tests.ps1 | 22 +++++--- ...ntraBetaAdministrativeUnitMember.Tests.ps1 | 22 +++++--- .../Remove-EntraBetaGroupMember.Tests.ps1 | 22 ++++---- .../Remove-EntraBetaGroupOwner.Tests.ps1 | 24 ++++---- ...ve-EntraBetaScopedRoleMembership.Tests.ps1 | 26 +++++---- .../Set-EntraBetaAdministrativeUnit.Tests.ps1 | 20 +++---- .../EntraBeta/Set-EntraBetaUser.Tests.ps1 | 40 ++++---------- 51 files changed, 565 insertions(+), 540 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaAdministrativeUnitMember.md index ae1fc24a5..6b8392f4a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaAdministrativeUnitMember.md @@ -28,7 +28,7 @@ Adds an administrative unit member. ```powershell Add-EntraBetaAdministrativeUnitMember -RefObjectId - -ObjectId + -AdministrativeUnitId [] ``` @@ -49,7 +49,7 @@ Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $User = Get-EntraBetaUser -SearchString '' $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId RefObjectId = $User.ObjectId } Add-EntraBetaAdministrativeUnitMember @params @@ -57,19 +57,19 @@ Add-EntraBetaAdministrativeUnitMember @params This example shows how to add an administrative unit member. You can use the command `Get-EntraBetaAdministrativeUnit` to get administrative unit ID. You can use the command `Get-EntraBetaUser` to get user ID. -- `ObjectId` parameter specifies the ID of an administrative unit. +- `AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `RefObjectId` parameter specifies the ID of the user or group you want to add as a member of the administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of a Microsoft Entra ID administrative unit. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaApplicationOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaApplicationOwner.md index 75c593811..74c538e9a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaApplicationOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaApplicationOwner.md @@ -26,7 +26,7 @@ Adds an owner to an application. ```powershell Add-EntraBetaApplicationOwner - -ObjectId + -ApplicationId -RefObjectId [] ``` @@ -44,7 +44,7 @@ Connect-Entra -Scopes 'Application.ReadWrite.All' $ApplicationId = (Get-EntraBetaApplication -SearchString '').ObjectId $UserObjectId = (Get-EntraBetaUser -SearchString '').ObjectId $params = @{ - ObjectId = $ApplicationId + ApplicationId = $ApplicationId RefObjectId = $UserObjectId } Add-EntraBetaApplicationOwner @params @@ -52,19 +52,19 @@ Add-EntraBetaApplicationOwner @params This example demonstrates how to add an owner to an application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of an application. +- `-ApplicationId` parameter specifies the ID of an application. - `-RefObjectId` parameter specifies the ID of a user. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupMember.md index 3cf97b1db..7a31cd553 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupMember.md @@ -25,16 +25,16 @@ Add a member to a group. ```powershell Add-EntraBetaGroupMember - -ObjectId + -GroupId -RefObjectId [] ``` ## Description -The `Add-EntraBetaGroupMember` cmdlet adds a member to a group. Specify the `ObjectId` and `RefObjectId` parameters to add a member to a group. +The `Add-EntraBetaGroupMember` cmdlet adds a member to a group. Specify the `GroupId` and `RefObjectId` parameters to add a member to a group. -`-ObjectId` - specifies the unique identifier (Object ID) of the group to which you want to add a member. +`-GroupId` - specifies the unique identifier (Object ID) of the group to which you want to add a member. `-RefObjectId` - specifies the unique identifier (Object ID) of the member to be added to the group. @@ -45,7 +45,7 @@ The `Add-EntraBetaGroupMember` cmdlet adds a member to a group. Specify the `Obj ```powershell Connect-Entra -Scopes 'GroupMember.ReadWrite.All' $params = @{ - ObjectId = 'dddddddd-2222-3333-5555-rrrrrrrrrrrr' + GroupId = 'dddddddd-2222-3333-5555-rrrrrrrrrrrr' RefObjectId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } @@ -56,14 +56,14 @@ This example demonstrates how to add a member to a group. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md index d715acf55..b9c39d6a2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md @@ -26,16 +26,16 @@ Adds an owner to a group. ```powershell Add-EntraBetaGroupOwner - -ObjectId + -GroupId -RefObjectId [] ``` ## Description -The `Add-EntraBetaGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group. Specify the `ObjectId` and `RefObjectId` parameters to add an owner to a group. +The `Add-EntraBetaGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group. Specify the `GroupId` and `RefObjectId` parameters to add an owner to a group. -`-ObjectId` - specifies the unique identifier (Object ID) of the group to which you want to add an owner. +`-GroupId` - specifies the unique identifier (Object ID) of the group to which you want to add an owner. `-RefObjectId` - specifies the unique identifier (Object ID) of the owner to be added to the group (user or service principal). @@ -46,9 +46,9 @@ The `Add-EntraBetaGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$user = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +$user = Get-EntraBetaUser -GroupId 'SawyerM@contoso.com' $params = @{ - ObjectId = $group.ObjectId + GroupId = $group.ObjectId RefObjectId = $user.ObjectId } @@ -59,14 +59,14 @@ This example demonstrates how to add an owner to a group. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnit.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnit.md index 329dfbe88..817e2eb72 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnit.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnit.md @@ -40,7 +40,7 @@ Get-EntraBetaAdministrativeUnit ```powershell Get-EntraBetaAdministrativeUnit - -ObjectId + -AdministrativeUnitId [-All] [-Property ] [] @@ -48,7 +48,7 @@ Get-EntraBetaAdministrativeUnit ## Description -The `Get-EntraBetaAdministrativeUnit` cmdlet gets a Microsoft Entra ID administrative unit. Specify `ObjectId` parameter to get a specific administrative unit. +The `Get-EntraBetaAdministrativeUnit` cmdlet gets a Microsoft Entra ID administrative unit. Specify `AdministrativeUnitId` parameter to get a specific administrative unit. ## Examples @@ -98,7 +98,7 @@ This command gets all the administrative units. ```powershell Connect-Entra -Scopes 'AdministrativeUnit.Read.All' -Get-EntraBetaAdministrativeUnit -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaAdministrativeUnit -AdministrativeUnitId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -109,7 +109,7 @@ DeletedDateTime Id Description Displa This example returns the details of the specified administrative unit. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ### Example 4: Get administrative units filter by display name @@ -176,14 +176,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md index 42ef22a84..79ae52af6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md @@ -27,7 +27,7 @@ Gets a member of an administrative unit. ```powershell Get-EntraBetaAdministrativeUnitMember - -ObjectId + -AdministrativeUnitId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraBetaAdministrativeUnitMember ## Description -The `Get-EntraBetaAdministrativeUnitMember` cmdlet gets a member of a Microsoft Entra ID administrative unit. Specify `ObjectId` parameters to retrieve an administrative unit member. +The `Get-EntraBetaAdministrativeUnitMember` cmdlet gets a member of a Microsoft Entra ID administrative unit. Specify `AdministrativeUnitId` parameters to retrieve an administrative unit member. In delegated scenarios with work or school accounts, the signed-in user must either be a member user or be assigned a supported Microsoft Entra role, or a custom role with the necessary permissions. The following least privileged roles are supported for this operation: @@ -46,12 +46,12 @@ In delegated scenarios with work or school accounts, the signed-in user must eit ## Examples -### Example 1: Get an administrative unit member by ObjectId +### Example 1: Get an administrative unit member by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId ``` ```Output @@ -66,14 +66,14 @@ ffffffff-5555-6666-7777-aaaaaaaaaaaa This example returns the list of administrative unit members from specified administrative unit ObjectId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. -### Example 2: Get all administrative unit members by ObjectId +### Example 2: Get all administrative unit members by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId -All +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -All ``` ```Output @@ -88,14 +88,14 @@ ffffffff-5555-6666-7777-aaaaaaaaaaaa This example returns the list of all administrative unit members from specified administrative unit ObjectId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. -### Example 3: Get top three administrative unit members by ObjectId +### Example 3: Get top three administrative unit members by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -ObjectId $AdministrativeUnit.ObjectId -Top 3 +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -Top 3 ``` ```Output @@ -108,18 +108,18 @@ dddddddd-3333-4444-5555-eeeeeeeeeeee This example returns top three administrative unit members from specified administrative unit ObjectId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md index 8e85a64b5..554ce613c 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md @@ -39,7 +39,7 @@ Get-EntraBetaDeletedGroup ```powershell Get-EntraBetaDeletedGroup - -Id + -GroupId [-All] [-Property ] [] @@ -79,7 +79,7 @@ test23 cccccccc-2222-3333-4444-dddddddddddd test23 desc3 {Unifi test24 dddddddd-3333-4444-5555-eeeeeeeeeeee test24 desc4 {Unified, DynamicMembership} ``` -This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra ID. +This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra GroupId. ### Example 2: Get deleted groups in the directory using All parameter @@ -148,11 +148,11 @@ test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unifi This cmdlet retrieves deleted groups in the directory, having the specified display name. -### Example 6: Get deleted group by Id +### Example 6: Get deleted group by GroupId ```powershell Connect-Entra -Scopes 'Group.Read.All' -Get-EntraBetaDeletedGroup -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaDeletedGroup -GroupId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -161,9 +161,9 @@ DisplayName Id MailNickname Description GroupT test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unified, DynamicMembership} ``` -This cmdlet retrieves the deleted group specified by Id. +This cmdlet retrieves the deleted group specified by GroupId. -- `-Id` parameter specifies the deleted group ID. +- `-GroupId` parameter specifies the deleted group ID. ## Parameters @@ -200,14 +200,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -Id +### -GroupId -The Id of the deleted group to be retrieved. +The GroupId of the deleted group to be retrieved. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroup.md index 20841688e..5e8b59d8b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroup.md @@ -48,7 +48,7 @@ Get-EntraBetaGroup ```powershell Get-EntraBetaGroup - -ObjectId + -GroupId [-All] [-Property ] [] @@ -56,7 +56,7 @@ Get-EntraBetaGroup ## Description -The `Get-EntraBetaGroup` cmdlet gets a group in Microsoft Entra ID. Specify the `ObjectId` parameter to get a specific group. +The `Get-EntraBetaGroup` cmdlet gets a group in Microsoft Entra ID. Specify the `GroupId` parameter to get a specific group. ## Examples @@ -79,11 +79,11 @@ SimpleGroup eeeeeeee-4444-5555-6666-ffffff This example demonstrates how to get all groups from Microsoft Entra ID. -### Example 2: Get a specific group by using an ObjectId +### Example 2: Get a specific group by using an GroupId ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroup -ObjectId 'eeeeeeee-4444-5555-6666-ffffffffffff' +Get-EntraBetaGroup -GroupId 'eeeeeeee-4444-5555-6666-ffffffffffff' ``` ```Output @@ -225,14 +225,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId -The unique identifier of a group in Microsoft Entra ID. (ObjectId). +The unique identifier of a group in Microsoft Entra ID. (GroupId) ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupAppRoleAssignment.md index f283f85a8..f45016c3d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupAppRoleAssignment.md @@ -26,7 +26,7 @@ Gets a group application role assignment. ```powershell Get-EntraBetaGroupAppRoleAssignment - -ObjectId + -GroupId [-All] [-Top ] [-Property ] @@ -35,7 +35,7 @@ Get-EntraBetaGroupAppRoleAssignment ## Description -The `Get-EntraBetaGroupAppRoleAssignment` cmdlet gets a group application role assignment in Microsoft Entra ID. Specify the `ObjectId` parameter to get a group application role assignment. +The `Get-EntraBetaGroupAppRoleAssignment` cmdlet gets a group application role assignment in Microsoft Entra ID. Specify the `GroupId` parameter to get a group application role assignment. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraBetaGroupAppRoleAssignment` cmdlet gets a group application role a ```powershell Connect-Entra -Scopes 'Directory.Read.All' $GroupId = (Get-EntraBetaGroup -Top 1).ObjectId -Get-EntraBetaGroupAppRoleAssignment -ObjectId $GroupId +Get-EntraBetaGroupAppRoleAssignment -GroupId $GroupId ``` ```Output @@ -57,13 +57,13 @@ MSVrBV4APk--eAGnHqMKBDtEqPRvu8xLqWHDSXUhoTE M365 License Manager This example retrieves the application role assignments of a group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ### Example 2: Retrieve all application role assignments of a group ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaGroupAppRoleAssignment -ObjectId 'eeeeeeee-4444-5555-6666-ffffffffffff' -All +Get-EntraBetaGroupAppRoleAssignment -GroupId 'eeeeeeee-4444-5555-6666-ffffffffffff' -All ``` ```Output @@ -76,13 +76,13 @@ MSVrBV4APk--eAGnHqMKBDtEqPRvu8xLqWHDSXUhoTE M365 License Manager This example retrieves all application role assignments of the specified group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ### Example 3: Retrieve top two application role assignments of a group ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaGroupAppRoleAssignment -ObjectId 'cccccccc-8888-9999-0000-dddddddddddd' -Top 2 +Get-EntraBetaGroupAppRoleAssignment -GroupId 'cccccccc-8888-9999-0000-dddddddddddd' -Top 2 ``` ```Output @@ -94,7 +94,7 @@ MSVrBV4APk--eAGnHqMKBExhQK4StEFHidLvUymzo4I ProvisioningPowerBi This example retrieves top two application role assignments of the specified group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ## Parameters @@ -114,14 +114,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md index e43e19141..6ebe9d48b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md @@ -25,7 +25,7 @@ Gets an owner of a group. ```powershell Get-EntraBetaGroupOwner - -ObjectId + -GroupId [-All] [-Top ] [-Property ] @@ -50,7 +50,7 @@ In delegated scenarios, the signed-in user must have a supported Microsoft Entra ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupOwner -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraBetaGroupOwner -GroupId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -61,13 +61,13 @@ cccccccc-2222-3333-4444-dddddddddddd This example demonstrates how to retrieve the owner of a specific group. -- `-ObjectId` parameter specifies the ID of a group. +- `-GroupId` parameter specifies the ID of a group. ### Example 2: Gets all group owners ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupOwner -ObjectId 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' -All +Get-EntraBetaGroupOwner -GroupId 'ffffffff-5555-6666-7777-aaaaaaaaaaaa' -All ``` ```Output @@ -80,13 +80,13 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example demonstrates how to retrieve the all owner of a specific group. -- `-ObjectId` parameter specifies the ID of a group. +- `-GroupId` parameter specifies the ID of a group. ### Example 3: Gets two group owners ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupOwner -ObjectId 'bbbbbbbb-7777-8888-9999-cccccccccccc' -Top 2 +Get-EntraBetaGroupOwner -GroupId 'bbbbbbbb-7777-8888-9999-cccccccccccc' -Top 2 ``` ```Output @@ -98,7 +98,7 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example demonstrates how to retrieve the top two owners of a specific group. -- `-ObjectId` parameter specifies the ID of a group. +- `-GroupId` parameter specifies the ID of a group. ## Parameters @@ -118,14 +118,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaGroupAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaGroupAppRoleAssignment.md index 4dd29e877..fbbbfdae0 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaGroupAppRoleAssignment.md @@ -28,8 +28,8 @@ Assign a group of users to an application role. ```powershell New-EntraBetaGroupAppRoleAssignment -ResourceId - -Id - -ObjectId + -AppRoleId + -GroupId -PrincipalId [] ``` @@ -47,7 +47,7 @@ Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' $appname = 'Box' $spo = Get-EntraBetaServicePrincipal -Filter "Displayname eq '$appname'" $group = Get-EntraBetaGroup -SearchString 'Contoso Team' -New-EntraBetaGroupAppRoleAssignment -ObjectId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -Id $spo.Approles[1].id +New-EntraBetaGroupAppRoleAssignment -GroupId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -AppRoleId $spo.Approles[1].id ``` ```Output @@ -59,21 +59,21 @@ DeletedDateTime Id AppRoleId This example demonstrates how to assign a group of users to an application role in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a group to which you're assigning the app role. +- `-GroupId` parameter specifies the ID of a group to which you're assigning the app role. - `-PrincipalId` parameter specifies the ID of a group to which you're assigning the app role. - `-ResourceId` parameter specifies the ID of a resource service Principal, which has defined the app role. -- `-Id` parameter specifies the ID of a appRole (defined on the resource service principal) to assign to the group. +- `-AppRoleId` parameter specifies the ID of a appRole (defined on the resource service principal) to assign to the group. ## Parameters -### -Id +### -AppRoleId Specifies the ID of the app role (defined on the resource service principal) to assign. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named @@ -82,14 +82,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId -Specifies the ID of a group in Microsoft Entra ID. +Specifies the ID of a user (as a UserPrincipalName or GroupId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnit.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnit.md index 64e65d9be..2fdf8f8c1 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnit.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnit.md @@ -25,13 +25,13 @@ Removes an administrative unit. ```powershell Remove-EntraBetaAdministrativeUnit - -ObjectId + -AdministrativeUnitId [] ``` ## Description -The `Remove-EntraBetaAdministrativeUnit` cmdlet removes an administrative unit from Microsoft Entra ID. Specify `ObjectId` parameter to delete an administrative unit. +The `Remove-EntraBetaAdministrativeUnit` cmdlet removes an administrative unit from Microsoft Entra ID. Specify `AdministrativeUnitId` parameter to delete an administrative unit. To delete an administrative unit, the calling principal must have at least the Privileged Role Administrator role in Microsoft Entra. @@ -42,23 +42,23 @@ To delete an administrative unit, the calling principal must have at least the P ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Remove-EntraBetaAdministrativeUnit -ObjectId $AdministrativeUnit.ObjectId +Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId $AdministrativeUnit.ObjectId ``` This command removes the specified administrative unit from Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnitMember.md index d0d4f895f..b4f130ec5 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaAdministrativeUnitMember.md @@ -26,14 +26,14 @@ Removes an administrative unit member. ```powershell Remove-EntraBetaAdministrativeUnitMember - -ObjectId + -AdministrativeUnitId -MemberId [] ``` ## Description -The `Remove-EntraBetaAdministrativeUnitMember` cmdlet removes an administrative unit member in Microsoft Entra ID. Specify `ObjectId` and `MemberId` to remove an administrative unit member. +The `Remove-EntraBetaAdministrativeUnitMember` cmdlet removes an administrative unit member in Microsoft Entra ID. Specify `AdministrativeUnitId` and `MemberId` to remove an administrative unit member. To remove a member from an administrative unit, the calling principal must have at least the Privileged Role Administrator role in Microsoft Entra. @@ -45,7 +45,7 @@ To remove a member from an administrative unit, the calling principal must have Connect-Entra -Scopes 'AdministrativeUnit.Read.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId MemberId = 'eeeeeeee-4444-5555-6666-ffffffffffff' } Remove-EntraBetaAdministrativeUnitMember @params @@ -53,7 +53,7 @@ Remove-EntraBetaAdministrativeUnitMember @params This command removes a specified member (user or group) from a specified administrative unit. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `-MemberId` parameter specifies the ID of the administrative unit member. ## Parameters @@ -74,14 +74,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md index 314f1af51..4ea7391c7 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md @@ -24,7 +24,7 @@ Delete a group application role assignment. ```powershell Remove-EntraBetaGroupAppRoleAssignment - -ObjectId + -GroupId -AppRoleAssignmentId [] ``` @@ -41,7 +41,7 @@ The `Remove-EntraBetaGroupAppRoleAssignment` cmdlet removes a group application Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $params = @{ - ObjectId = $group.ObjectId + GroupId = 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' AppRoleAssignmentId = 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' } Remove-EntraBetaGroupAppRoleAssignment @params @@ -49,7 +49,7 @@ Remove-EntraBetaGroupAppRoleAssignment @params This example demonstrates how to remove the specified group application role assignment. -- `-ObjectId` parameter specifies the object ID of a group. +- `-GroupId` parameter specifies the object ID of a group. - `-AppRoleAssignmentId` parameter specifies the object ID of a group application role assignment. ## Parameters @@ -70,14 +70,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupMember.md index 2ea9d80aa..508782c05 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupMember.md @@ -26,14 +26,14 @@ Removes a member from a group. ```powershell Remove-EntraBetaGroupMember - -ObjectId + -GroupId -MemberId [] ``` ## Description -The `Remove-EntraBetaGroupMember` cmdlet removes a member from a group in Microsoft Entra ID. Specify the `ObjectId` and `MemberId` parameters to remove a member from a group. +The `Remove-EntraBetaGroupMember` cmdlet removes a member from a group in Microsoft Entra ID. Specify the `GroupId` and `MemberId` parameters to remove a member from a group. ## Examples @@ -43,7 +43,7 @@ The `Remove-EntraBetaGroupMember` cmdlet removes a member from a group in Micros Connect-Entra -Scopes 'GroupMember.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $params = @{ - ObjectId = $group.ObjectId + GroupId = $group.ObjectId MemberId = 'zzzzzzzz-6666-8888-9999-pppppppppppp' } @@ -70,14 +70,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md index 1a93536ca..83d497d0e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md @@ -27,13 +27,13 @@ Removes an owner from a group. ```powershell Remove-EntraBetaGroupOwner -OwnerId - -ObjectId + -GroupId [] ``` ## Description -The `Remove-EntraBetaGroupOwner` cmdlet removes an owner from a group in Microsoft Entra ID. Specify the `ObjectId` and `OwnerId` parameters to remove an owner from a group. +The `Remove-EntraBetaGroupOwner` cmdlet removes an owner from a group in Microsoft Entra ID. Specify the `GroupId` and `OwnerId` parameters to remove an owner from a group. ## Examples @@ -43,7 +43,7 @@ The `Remove-EntraBetaGroupOwner` cmdlet removes an owner from a group in Microso Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $params = @{ - ObjectId = $group.ObjectId + GroupId = 'qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh' OwnerId = 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' } @@ -52,20 +52,20 @@ Remove-EntraBetaGroupOwner @params This example demonstrates how to remove an owner from a group in Microsoft Entra ID. -- `ObjectId` specifies the ID of a group in Microsoft Entra ID. +- `GroupId` specifies the ID of a group in Microsoft Entra ID. - `OwnerId` specifies the ID of an owner. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md index 0ba291dff..b33b39725 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md @@ -27,14 +27,14 @@ Removes a scoped role membership. ```powershell Remove-EntraBetaScopedRoleMembership - -ObjectId + -AdministrativeUnitId -ScopedRoleMembershipId [] ``` ## Description -The `Remove-EntraBetaScopedRoleMembership` cmdlet removes a scoped role membership from Microsoft Entra ID. Specify `ObjectId` and `ScopedRoleMembershipId` parameter to remove a scoped role membership. +The `Remove-EntraBetaScopedRoleMembership` cmdlet removes a scoped role membership from Microsoft Entra ID. Specify `AdministrativeUnitId` and `ScopedRoleMembershipId` parameter to remove a scoped role membership. ## Examples @@ -44,7 +44,7 @@ The `Remove-EntraBetaScopedRoleMembership` cmdlet removes a scoped role membersh Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId ScopedRoleMembershipId = 'dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc' } Remove-EntraBetaScopedRoleMembership @params @@ -52,12 +52,12 @@ Remove-EntraBetaScopedRoleMembership @params This cmdlet removes a specific scoped role membership from Microsoft Entra ID. You can use the command `Get-EntraBetaAdministrativeUnit` to get administrative unit Id. -- `-ObjectId` parameter specifies the ID of an administrative unit. -- `-ScopedRoleMembershipId` parameter specifies the ID of the scoped role membership to remove. To obtain the details of a scoped role membership, you can use the `Get-EntraBetaScopedRoleMembership` command. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. +- `-ScopedRoleMembershipId` parameter specifies the ID of the scoped role membership to remove. To obtain the details of a scoped role membership, you can use the `Get-EntraScopedRoleMembership` command. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit object. @@ -80,7 +80,7 @@ Specifies the ID of the scoped role membership to remove. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAdministrativeUnit.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAdministrativeUnit.md index 02614eed9..9e60ac84f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAdministrativeUnit.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAdministrativeUnit.md @@ -25,7 +25,7 @@ Updates an administrative unit. ```powershell Set-EntraBetaAdministrativeUnit - -Id + -AdministrativeUnitId [-IsMemberManagementRestricted ] [-Description ] [-DisplayName ] @@ -34,7 +34,7 @@ Set-EntraBetaAdministrativeUnit ## Description -The `Set-EntraBetaAdministrativeUnit` cmdlet updates an administrative unit in Microsoft Entra ID. Specify `Id` parameter to update a specific administrative unit. +The `Set-EntraBetaAdministrativeUnit` cmdlet updates an administrative unit in Microsoft Entra ID. Specify `AdministrativeUnitId` parameter to update a specific administrative unit. In delegated scenarios, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with the `microsoft.directory/administrativeUnits/allProperties/allTasks` permission. @@ -48,7 +48,7 @@ The Privileged Role Administrator is the least privileged role required for this Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - Id = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId DisplayName = 'UpdatedAU' } Set-EntraBetaAdministrativeUnit @params @@ -56,7 +56,7 @@ Set-EntraBetaAdministrativeUnit @params This Command update DisplayName of specific administrative unit. -- `-Id` parameter specifies the Id of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the Id of an administrative unit. - `-DisplayName` parameter specifies the display name for the administrative unit. ### Example 2: Update Description @@ -65,7 +65,7 @@ This Command update DisplayName of specific administrative unit. Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - Id = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId Description = 'Updated AU Description' } Set-EntraBetaAdministrativeUnit @params @@ -73,7 +73,7 @@ Set-EntraBetaAdministrativeUnit @params This example shows how to update the description of a specific administrative unit. -- `-Id` parameter specifies the Id of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the Id of an administrative unit. - `-Description` parameter specifies the description for the administrative unit. ### Example 3: Update IsMemberManagementRestricted @@ -82,7 +82,7 @@ This example shows how to update the description of a specific administrative un Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - Id = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId IsMemberManagementRestricted = $true } Set-EntraBetaAdministrativeUnit @params @@ -90,7 +90,7 @@ Set-EntraBetaAdministrativeUnit @params This example shows how to update the `IsMemberManagementRestricted` setting for a specific administrative unit. -- `-Id` parameter specifies the Id of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the Id of an administrative unit. - `-IsMemberManagementRestricted` parameter specifies the management rights on resources in the administrative units should be restricted to ONLY the administrators scoped on the administrative unit object. ## Parameters @@ -143,14 +143,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -AdministrativeUnitId Specifies the Id of an administrative unit in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md index 501f92b0e..12c5e366a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md @@ -25,7 +25,7 @@ Updates a user. ```powershell Set-EntraBetaUser - -ObjectId + -UserId [-PostalCode ] [-MailNickName ] [-ShowInAddressList ] @@ -60,7 +60,7 @@ Set-EntraBetaUser ## Description -The `Set-EntraBetaUser` cmdlet updates a user in Microsoft Entra ID. Specify the `ObjectId` parameter to update a user in Microsoft Entra ID. +The `Set-EntraBetaUser` cmdlet updates a user in Microsoft Entra ID. Specify the `UserId` parameter to update a user in Microsoft Entra ID. ## Examples @@ -70,7 +70,7 @@ The `Set-EntraBetaUser` cmdlet updates a user in Microsoft Entra ID. Specify the Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' $user = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' $params = @{ - ObjectId = $user.ObjectId + UserId = $user.ObjectId DisplayName = 'Updated user Name' } Set-EntraBetaUser @params @@ -78,14 +78,14 @@ Set-EntraBetaUser @params This example updates the specified user's Display name parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. ### Example 2: Set the specified user's AccountEnabled parameter ```powershell Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' $params = @{ - ObjectId = 'SawyerM@contoso.com' + UserId = 'SawyerM@contoso.com' AccountEnabled = $true } Set-EntraBetaUser @params @@ -93,7 +93,7 @@ Set-EntraBetaUser @params This example updates the specified user's AccountEnabled parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-AccountEnabled` Specifies whether the account is enabled. ### Example 3: Set all but specified users as minors with parental consent @@ -101,12 +101,12 @@ This example updates the specified user's AccountEnabled parameter. ```powershell Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' Get-EntraBetaUser -All | Where-Object -FilterScript { $_.DisplayName -notmatch '(George|James|Education)' } | -ForEach-Object { Set-EntraBetaUser -ObjectId $($_.ObjectId) -AgeGroup 'minor' -ConsentProvidedForMinor 'granted' } +ForEach-Object { Set-EntraBetaUser -UserId $($_.ObjectId) -AgeGroup 'minor' -ConsentProvidedForMinor 'granted' } ``` This example updates the specified user's as minors with parental consent. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-ConsentProvidedForMinor` Sets whether consent has to obtained for minors. Allowed values: null, granted, denied, and notRequired. ### Example 4: Set the specified user's property @@ -114,7 +114,7 @@ This example updates the specified user's as minors with parental consent. ```powershell Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' $params = @{ - ObjectId = 'SawyerM@contoso.com' + UserId = 'SawyerM@contoso.com' City = 'Add city name' CompanyName = 'Microsoft' Country = 'Add country name' @@ -135,7 +135,7 @@ Set-EntraBetaUser @params This example updates the specified user's property. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-UserType` classify user types in your directory, such as "Member" and "Guest." - `-PasswordPolicies` Specifies password policies for the user. - `-OtherMails` Specifies other email addresses for the user @@ -145,7 +145,7 @@ This example updates the specified user's property. ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $params= @{ -ObjectId = 'SawyerM@contoso.com' +UserId = $user.UserId PasswordProfile = @{ Password= '*****' ForceChangePasswordNextLogin = $true @@ -157,7 +157,7 @@ Set-EntraBetaUser @params This example updates the specified user's PasswordProfile parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-PasswordProfile` specifies the user's password profile. ## Parameters @@ -359,14 +359,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principle Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principle Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupMember.md index a32949ea9..257709330 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupMember.md @@ -26,7 +26,7 @@ Adds a member to a group. ```powershell Add-EntraGroupMember - -ObjectId + -GroupId -RefObjectId [] ``` @@ -42,7 +42,7 @@ The Add-EntraGroupMember cmdlet adds a member to a group. ```powershell Connect-Entra -Scopes 'GroupMember.ReadWrite.All' $params = @{ - ObjectId = 'dddddddd-2222-3333-5555-rrrrrrrrrrrr' + GroupId = 'dddddddd-2222-3333-5555-rrrrrrrrrrrr' RefObjectId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } @@ -53,14 +53,14 @@ This example demonstrates how to add a member to a group. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md index 36f30669f..597beff6f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md @@ -26,16 +26,16 @@ Adds an owner to a group. ```powershell Add-EntraGroupOwner - -ObjectId + -GroupId -RefObjectId [] ``` ## Description -The `Add-EntraGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group. Specify the `ObjectId` and `RefObjectId` parameters to add an owner to a group. +The `Add-EntraGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group. Specify the `GroupId` and `RefObjectId` parameters to add an owner to a group. -`-ObjectId` - specifies the unique identifier (Object ID) of the group to which you want to add an owner. +`-GroupId` - specifies the unique identifier (Object ID) of the group to which you want to add an owner. `-RefObjectId` - specifies the unique identifier (Object ID) of the owner to be added to the group. @@ -48,7 +48,7 @@ Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $user = Get-EntraUser -ObjectId 'SawyerM@contoso.com' $params = @{ - ObjectId = $group.ObjectId + GroupId = $group.ObjectId RefObjectId = $user.ObjectId } @@ -59,14 +59,14 @@ This example demonstrates how to add an owner to a group. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md index e9e008fae..4ac745867 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md @@ -49,7 +49,7 @@ Get-EntraDeletedGroup ```powershell Get-EntraDeletedGroup - -Id + -DirectoryObjectId [-All] [-Property ] [] @@ -89,7 +89,7 @@ test23 cccccccc-2222-3333-4444-dddddddddddd test23 desc3 {Unifi test24 dddddddd-3333-4444-5555-eeeeeeeeeeee test24 desc4 {Unified, DynamicMembership} ``` -This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra ID. +This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra DirectoryObjectId. ### Example 2: Get deleted groups in the directory using All parameter @@ -158,11 +158,11 @@ test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unifi This cmdlet retrieves deleted groups in the directory, having the specified display name. -### Example 6: Get deleted group by Id +### Example 6: Get deleted group by DirectoryObjectId ```powershell Connect-Entra -Scopes 'Group.Read.All' -Get-EntraDeletedGroup -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraDeletedGroup -DirectoryObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -171,9 +171,9 @@ DisplayName Id MailNickname Description GroupT test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unified, DynamicMembership} ``` -This cmdlet retrieves the deleted group specified by Id. +This cmdlet retrieves the deleted group specified by DirectoryObjectId. -- `-Id` parameter specifies the deleted group ID. +- `-DirectoryObjectId` parameter specifies the deleted group DirectoryObjectId. ## Parameters @@ -210,14 +210,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -Id +### -DirectoryObjectId -The Id of the deleted group to be retrieved. +The DirectoryObjectId of the deleted group to be retrieved. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroup.md index 23882b928..62d509e6c 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroup.md @@ -49,7 +49,7 @@ Get-EntraGroup ```powershell Get-EntraGroup - -ObjectId + -GroupId [-All] [-Property ] [] @@ -80,11 +80,11 @@ SimpleGroup eeeeeeee-4444-5555-6666-ffffff This example demonstrates how to get all groups from Microsoft Entra ID. -### Example 2: Get a specific group by using an ObjectId +### Example 2: Get a specific group by using an GroupId ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroup -ObjectId 'pppppppp-4444-0000-8888-yyyyyyyyyyyy' +Get-EntraGroup -GroupId 'pppppppp-4444-0000-8888-yyyyyyyyyyyy' ``` ```Output @@ -226,14 +226,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId -The unique identifier of a group in Microsoft Entra ID. (ObjectId). +The unique identifier of a group in Microsoft Entra ID (GroupId) ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md index 98e011c4b..8591248ca 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md @@ -26,7 +26,7 @@ Gets a group application role assignment. ```powershell Get-EntraGroupAppRoleAssignment - -ObjectId + -GroupId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraGroupAppRoleAssignment` cmdlet gets a group application role assig ```powershell Connect-Entra -Scopes 'Directory.Read.All' $GroupId = (Get-EntraGroup -Top 1).ObjectId -Get-EntraGroupAppRoleAssignment -ObjectId $GroupId +Get-EntraGroupAppRoleAssignment -GroupId $GroupId ``` ```Output @@ -63,7 +63,7 @@ This example retrieves the application role assignments of a group. ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraGroupAppRoleAssignment -ObjectId 'ffffffffff-7777-9999-7777-vvvvvvvvvvv' -All +Get-EntraGroupAppRoleAssignment -GroupId 'ffffffffff-7777-9999-7777-vvvvvvvvvvv' -All ``` ```Output @@ -82,7 +82,7 @@ This example retrieves all application role assignments of the specified group. ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraGroupAppRoleAssignment -ObjectId 'ffffffffff-7777-9999-7777-vvvvvvvvvvv' -Top 2 +Get-EntraGroupAppRoleAssignment -GroupId 'ffffffffff-7777-9999-7777-vvvvvvvvvvv' -Top 2 ``` ```Output @@ -114,15 +114,15 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: - +Aliases: ObjectId + Required: True Position: Named Default value: None diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md index 874046c61..7fd9b7adb 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md @@ -27,9 +27,9 @@ Assign a group of users to an application role. ```powershell New-EntraGroupAppRoleAssignment - -ObjectId - -PrincipalId - -Id + -GroupId + -PrincipalId + -AppRoleId -ResourceId [] ``` @@ -47,7 +47,7 @@ Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' $appname = 'Box' $spo = Get-EntraServicePrincipal -Filter "Displayname eq '$appname'" $group = Get-EntraGroup -SearchString 'Contoso Team' -New-EntraGroupAppRoleAssignment -ObjectId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -Id $spo.Approles[1].id +New-EntraGroupAppRoleAssignment -GroupId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -Id $spo.Approles[1].id ``` ```Output @@ -59,21 +59,24 @@ DeletedDateTime Id AppRoleId This example demonstrates how to assign a group of users to an application role in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a group to which you're assigning the app role. -- `-PrincipalId` parameter specifies the ID of a group to which you're assigning the app role. -- `-ResourceId` parameter specifies the ID of a resource service Principal, which has defined the app role. -- `-Id` parameter specifies the ID of a appRole (defined on the resource service principal) to assign to the group. +- `GroupId`: The ID of the group to which you're assigning the app role. + +- `PrincipalId`: The ID of the group to which you're assigning the app role. + +- `ResourceId`: The ID of the resource service Principal, which has defined the app role. + +- `AppRoleId`: The ID of the appRole (defined on the resource service principal) to assign to the group. ## Parameters -### -Id +### -AppRoleId Specifies the ID of the app role (defined on the resource service principal) to assign. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named @@ -82,14 +85,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md index 3e5dab8e6..5e5079156 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md @@ -25,9 +25,9 @@ Delete a group application role assignment. ```powershell Remove-EntraGroupAppRoleAssignment - -AppRoleAssignmentId - -ObjectId - [] + -AppRoleAssignmentId + -GroupId +[] ``` ## Description @@ -40,18 +40,12 @@ The `Remove-EntraGroupAppRoleAssignment` cmdlet removes a group application role ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$params = @{ - ObjectId = $group.ObjectId - AppRoleAssignmentId = 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' -} -Remove-EntraGroupAppRoleAssignment @params +Remove-AzureADGroupAppRoleAssignment -GroupId 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' -AppRoleAssignmentId 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' ``` This example demonstrates how to remove the specified group application role assignment. - -- `-ObjectId` parameter specifies the object ID of a group. -- `-AppRoleAssignmentId` parameter specifies the object ID of a group application role assignment. +GroupId - Specifies the object ID of a group. +AppRoleAssignmentId - Specifies the object ID of the group application role assignment. ## Parameters @@ -71,14 +65,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md index 339cfe5b1..a0b915c88 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md @@ -26,7 +26,7 @@ Removes a member from a group. ```powershell Remove-EntraGroupMember - -ObjectId + -GroupId -MemberId [] ``` @@ -41,16 +41,14 @@ The `Remove-EntraGroupMember` cmdlet removes a member from a group in Microsoft ```powershell Connect-Entra -Scopes 'GroupMember.ReadWrite.All' -$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$params = @{ - ObjectId = $group.ObjectId - MemberId = 'zzzzzzzz-6666-8888-9999-pppppppppppp' -} - -Remove-EntraGroupMember @params +Remove-EntraGroupMember -GroupId 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' -MemberId 'zzzzzzzz-6666-8888-9999-pppppppppppp' ``` -This example demonstrates how to remove a member from a group in Microsoft Entra ID. +This command removes the specified member from the specified group. + +GroupId - Specifies the object ID of a group in Microsoft Entra ID. + +MemberId - Specifies the ID of the member to remove. ## Parameters @@ -70,14 +68,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the object ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md index 8eab50ba3..3452e25b5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md @@ -26,13 +26,13 @@ Removes an owner from a group. ```powershell Remove-EntraGroupOwner -OwnerId - -ObjectId + -GroupId [] ``` ## Description -The `Remove-EntraGroupOwner` cmdlet removes an owner from a group in Microsoft Entra ID. Specify the `ObjectId` and `OwnerId` parameters to remove an owner from a group. +The `Remove-EntraGroupOwner` cmdlet removes an owner from a group in Microsoft Entra ID. Specify the `GroupId` and `OwnerId` parameters to remove an owner from a group. ## Examples @@ -40,31 +40,25 @@ The `Remove-EntraGroupOwner` cmdlet removes an owner from a group in Microsoft E ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$params = @{ - ObjectId = $group.ObjectId - OwnerId = 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' -} - -Remove-EntraGroupOwner @params +Remove-EntraGroupOwner -GroupId 'qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh' -OwnerId 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' ``` This example demonstrates how to remove an owner from a group in Microsoft Entra ID. -- `ObjectId` specifies the ID of a group in Microsoft Entra ID. +GroupId - Specifies the ID of a group in Microsoft Entra ID. - `OwnerId` specifies the ID of an owner. ## Parameters -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md index 760174419..b3140db1e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md @@ -25,7 +25,7 @@ Updates a user. ```powershell Set-EntraUser - -ObjectId + -UserId [-PostalCode ] [-CompanyName ] [-GivenName ] @@ -67,13 +67,9 @@ The `Set-EntraUser` cmdlet updates a user in Microsoft Entra ID. Specify the `Ob ### Example 1: Update a user ```powershell -Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' -$user = Get-EntraUser -ObjectId 'SawyerM@contoso.com' -$params = @{ - ObjectId = $user.ObjectId - DisplayName = 'Updated user Name' -} -Set-EntraUser @params +PS C:\> $user = Get-EntraUser -UserId TestUser@example.com +PS C:\> $user.DisplayName = 'YetAnotherTestUser' +PS C:\> Set-EntraUser -UserId TestUser@example.com -Displayname $user.Displayname ``` This example updates the specified user's Display name parameter. @@ -83,12 +79,7 @@ This example updates the specified user's Display name parameter. ### Example 2: Set the specified user's AccountEnabled parameter ```powershell -Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' -$params = @{ - ObjectId = 'SawyerM@contoso.com' - AccountEnabled = $true -} -Set-EntraUser @params +PS C:\> Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -AccountEnabled $true ``` This example updates the specified user's AccountEnabled parameter. @@ -99,9 +90,9 @@ This example updates the specified user's AccountEnabled parameter. ### Example 3: Set all but specified users as minors with parental consent ```powershell -Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' -Get-EntraUser -All | Where-Object -FilterScript { $_.DisplayName -notmatch '(George|James|Education)' } | -ForEach-Object { Set-EntraUser -ObjectId $($_.ObjectId) -AgeGroup 'minor' -ConsentProvidedForMinor 'granted' } +PS C:\>Get-EntraUser -All | +Where-Object -FilterScript { $_.DisplayName -notmatch '(George|James|Education)' } | +ForEach-Object { Set-EntraUser -UserId $($_.ObjectId) -AgeGroup 'minor' -ConsentProvidedForMinor 'granted' } ``` This example updates the specified user's as minors with parental consent. @@ -112,25 +103,7 @@ This example updates the specified user's as minors with parental consent. ### Example 4: Set the specified user's property ```powershell -Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' -$params = @{ - ObjectId = 'SawyerM@contoso.com' - City = 'Add city name' - CompanyName = 'Microsoft' - Country = 'Add country name' - Department = 'Add department name' - GivenName = 'Mircosoft' - ImmutableId = '#1' - JobTitle = 'Manager' - MailNickName = 'Add mailnickname' - Mobile = '9984534564' - OtherMails = 'test12@M365x99297270.OnMicrosoft.com' - PasswordPolicies = 'DisableStrongPassword' - State = 'UP' - StreetAddress = 'Add address' - UserType = 'Member' -} -Set-EntraUser @params +PS C:\>Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -City "Add city name" -CompanyName "Microsoft" -ConsentProvidedForMinor Granted -Country 'Add country name' -Department "Add department name" -GivenName "Mircosoft" -ImmutableId "#1" -JobTitle "Manager" -MailNickName "Add mailnickname" -Mobile "9984534564" -OtherMails "test12@M365x99297270.OnMicrosoft.com" -PasswordPolicies "DisableStrongPassword" -State "UP" -StreetAddress "Add address" -UserType "Member" ``` This example updates the specified user's property. @@ -151,8 +124,7 @@ PasswordProfile = @{ ForceChangePasswordNextLogin = $true EnforceChangePasswordPolicy = $false } -} -Set-EntraUser @params +PS C:\> Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -PasswordProfile $a ``` This example updates the specified user's PasswordProfile parameter. @@ -359,14 +331,13 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId - -Specifies the ID of a user (as a User Principle Name or ObjectId) in Microsoft Entra ID. +### -UserId +Specifies the ID of a user (as a UPN or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Add-EntraGroupMember.Tests.ps1 b/test/module/Entra/Add-EntraGroupMember.Tests.ps1 index 5e5f3f705..2d4960058 100644 --- a/test/module/Entra/Add-EntraGroupMember.Tests.ps1 +++ b/test/module/Entra/Add-EntraGroupMember.Tests.ps1 @@ -13,32 +13,32 @@ BeforeAll { Describe "Add-EntraGroupMember" { Context "Test for Add-EntraGroupMember" { It "Should add an member to a group" { - $result = Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgGroupMember -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraGroupMember -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when GroupId is empty" { + { Add-EntraGroupMember -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'GroupId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraGroupMember -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Add-EntraGroupMember -GroupId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName New-MgGroupMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaaaaaa-1111-2222-3333-cccccccccccc" } @@ -46,7 +46,7 @@ Describe "Add-EntraGroupMember" { It "Should contain DirectoryObjectId in parameters when passed RefObjectId to it" { Mock -CommandName New-MgGroupMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -54,7 +54,7 @@ Describe "Add-EntraGroupMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraGroupMember" - Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraGroupMember" @@ -70,7 +70,7 @@ Describe "Add-EntraGroupMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraGroupMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraGroupMember -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Add-EntraGroupOwner.Tests.ps1 b/test/module/Entra/Add-EntraGroupOwner.Tests.ps1 index edd984555..92b037b01 100644 --- a/test/module/Entra/Add-EntraGroupOwner.Tests.ps1 +++ b/test/module/Entra/Add-EntraGroupOwner.Tests.ps1 @@ -13,39 +13,39 @@ BeforeAll { Describe "Add-EntraGroupOwner" { Context "Test for Add-EntraGroupOwner" { It "Should add an owner to a group" { - $result = Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgGroupOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraGroupOwner -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when GroupId is empty" { + { Add-EntraGroupOwner -GroupId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'GroupId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraGroupOwner -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Add-EntraGroupOwner -GroupId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName New-MgGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaaaaaa-1111-2222-3333-cccccccccccc" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraGroupOwner" - Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraGroupOwner" Should -Invoke -CommandName New-MgGroupOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -59,7 +59,7 @@ Describe "Add-EntraGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraGroupOwner -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraGroupOwner -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 b/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 index e5b9d4f4c..0b6fea711 100644 --- a/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 @@ -31,6 +31,15 @@ BeforeAll { Describe "Get-EntraDeletedGroup" { Context "Test for Get-EntraDeletedGroup" { It "Should return specific Deleted Group" { + $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-App" + $result.GroupTypes | Should -Be "Unified" + + Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific Deleted Group with alias" { $result = Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" @@ -39,11 +48,11 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraDeletedGroup -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when DirectoryObjectId is empty" { + { Get-EntraDeletedGroup -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" } - It "Should fail when Id is invalid" { - { Get-EntraDeletedGroup -Id ""} | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when DirectoryObjectId is invalid" { + { Get-EntraDeletedGroup -DirectoryObjectId ""} | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId' because it is an empty string." } It "Should return All deleted groups" { $result = Get-EntraDeletedGroup -All @@ -52,7 +61,7 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 deleted group" { $result = Get-EntraDeletedGroup -Top 1 @@ -64,10 +73,10 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return specific deleted group by filter" { $result = Get-EntraDeletedGroup -Filter "DisplayName eq 'Mock-App'" @@ -94,17 +103,17 @@ Context "Test for Get-EntraDeletedGroup" { { Get-EntraDeletedGroup -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" } It "Property parameter should work" { - $result = Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain DirectoryObjectId in parameters when passed Id to it" { - $result = Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.DirectoryObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -115,7 +124,7 @@ Context "Test for Get-EntraDeletedGroup" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedGroup" - $result = Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedGroup" Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -130,7 +139,7 @@ Context "Test for Get-EntraDeletedGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraGroup.Tests.ps1 b/test/module/Entra/Get-EntraGroup.Tests.ps1 index 47ba25693..1f72a6435 100644 --- a/test/module/Entra/Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Get-EntraGroup.Tests.ps1 @@ -28,14 +28,26 @@ BeforeAll { Describe "Get-EntraGroup" { Context "Test for Get-EntraGroup" { It "Should return specific group" { - $result = Get-EntraGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccccc' Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when GroupId is empty" { + { Get-EntraGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is empty" { - { Get-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when searchstring is empty" { + { Get-EntraGroup -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" + } + It "Should fail when filter is empty" { + { Get-EntraGroup -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" + } + It "Should fail when Top is empty" { + { Get-EntraGroup -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when Top is invalid" { + { Get-EntraGroup -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return all group" { $result = Get-EntraGroup -All @@ -67,11 +79,11 @@ Describe "Get-EntraGroup" { Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Result should Contain ObjectId" { - $result = Get-EntraGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } - It "Should contain GroupId in parameters when passed ObjectId to it" { - $result = Get-EntraGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should contain GroupId in parameters when passed GroupId to it" { + $result = Get-EntraGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -82,7 +94,7 @@ Describe "Get-EntraGroup" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" - $result = Get-EntraGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { diff --git a/test/module/Entra/Get-EntraGroupAppRoleAssignment.Tests.ps1 b/test/module/Entra/Get-EntraGroupAppRoleAssignment.Tests.ps1 index e15af2094..8bd49fd7b 100644 --- a/test/module/Entra/Get-EntraGroupAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Get-EntraGroupAppRoleAssignment.Tests.ps1 @@ -28,10 +28,21 @@ BeforeAll { Mock -CommandName Get-MgGroupAppRoleAssignment -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } -Describe "New-EntraGroupAppRoleAssignment" { -Context "Test for New-EntraGroupAppRoleAssignment" { +Describe "Get-EntraGroupAppRoleAssignment" { +Context "Test for Get-EntraGroupAppRoleAssignment" { It "Should return specific Group AppRole Assignment" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + + + Should -Invoke -CommandName Get-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific Group AppRole Assignment with alias" { + $result = Get-EntraGroupAppRoleAssignment -objectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" @@ -42,13 +53,13 @@ Context "Test for New-EntraGroupAppRoleAssignment" { Should -Invoke -CommandName Get-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ObjectlId is empty" { - { Get-EntraGroupAppRoleAssignment -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraGroupAppRoleAssignment -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } It "Should fail when ObjectlId is invalid" { - { Get-EntraGroupAppRoleAssignment -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraGroupAppRoleAssignment -GroupId ""} | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should return All Group AppRole Assignment" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" @@ -59,10 +70,10 @@ Context "Test for New-EntraGroupAppRoleAssignment" { Should -Invoke -CommandName Get-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 Group AppRole Assignment" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" @@ -73,34 +84,34 @@ Context "Test for New-EntraGroupAppRoleAssignment" { Should -Invoke -CommandName Get-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Property parameter should work" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.PrincipalDisplayName | Should -Be 'Mock-Group' Should -Invoke -CommandName Get-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Result should Contain GroupId" { + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" } It "Should contain GroupId in parameters when passed Id to it" { - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupAppRoleAssignment" - $result = Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroupAppRoleAssignment" @@ -117,7 +128,7 @@ Context "Test for New-EntraGroupAppRoleAssignment" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/New-EntraGroupAppRoleAssignment.Tests.ps1 b/test/module/Entra/New-EntraGroupAppRoleAssignment.Tests.ps1 index 89e9cd0b1..38eb00af3 100644 --- a/test/module/Entra/New-EntraGroupAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/New-EntraGroupAppRoleAssignment.Tests.ps1 @@ -31,6 +31,17 @@ BeforeAll { Describe "New-EntraGroupAppRoleAssignment" { Context "Test for New-EntraGroupAppRoleAssignment" { It "Should return created Group AppRole Assignment" { + $result = New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.ResourceId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + + Should -Invoke -CommandName New-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return created Group AppRole Assignment with alias" { $result = New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" @@ -42,42 +53,42 @@ Context "Test for New-EntraGroupAppRoleAssignment" { Should -Invoke -CommandName New-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ObjectlId is empty" { - { New-EntraGroupAppRoleAssignment -ObjectId -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { New-EntraGroupAppRoleAssignment -GroupId -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } It "Should fail when ObjectlId is invalid" { - { New-EntraGroupAppRoleAssignment -ObjectId "" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { New-EntraGroupAppRoleAssignment -GroupId "" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when PrincipalId is empty" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'PrincipalId'*" + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'PrincipalId'*" } It "Should fail when PrincipalId is invalid" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'PrincipalId' because it is an empty string." + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'PrincipalId' because it is an empty string." } It "Should fail when ResourceId is empty" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ResourceId'*" + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ResourceId'*" } It "Should fail when ResourceId is invalid" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ResourceId' because it is an empty string." + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ResourceId' because it is an empty string." } It "Should fail when Id is empty" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -AppRoleId } | Should -Throw "Missing an argument for parameter 'AppRoleId'*" } It "Should fail when Id is invalid" { - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -AppRoleId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleId' because it is an empty string." } - It "Result should Contain ObjectId" { - $result = New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Result should Contain GroupId" { + $result = New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" } It "Should contain AppRoleId in parameters when passed Id to it" { - $result = New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.AppRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraGroupAppRoleAssignment" - $result = New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraGroupAppRoleAssignment" @@ -94,7 +105,7 @@ Context "Test for New-EntraGroupAppRoleAssignment" { try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { New-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraGroupAppRoleAssignment.Tests.ps1 b/test/module/Entra/Remove-EntraGroupAppRoleAssignment.Tests.ps1 index 61d0d4b05..ae40a78f5 100644 --- a/test/module/Entra/Remove-EntraGroupAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroupAppRoleAssignment.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Remove-EntraGroupAppRoleAssignment" { Context "Test for Remove-EntraGroupAppRoleAssignment" { It "Should return empty object" { + $result = Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with Alias" { $result = Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraGroupAppRoleAssignment -ObjectId -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraGroupAppRoleAssignment -GroupId -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraGroupAppRoleAssignment -ObjectId "" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraGroupAppRoleAssignment -GroupId "" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when AppRoleAssignmentId is empty" { - { Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId } | Should -Throw "Missing an argument for parameter 'AppRoleAssignmentId'*" + { Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId } | Should -Throw "Missing an argument for parameter 'AppRoleAssignmentId'*" } It "Should fail when AppRoleAssignmentId is invalid" { - { Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleAssignmentId' because it is an empty string." + { Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleAssignmentId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgGroupAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result = Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupAppRoleAssignment" - Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupAppRoleAssignment" @@ -56,7 +62,7 @@ Describe "Remove-EntraGroupAppRoleAssignment" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" -Debug } | Should -Not -Throw + { Remove-EntraGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraGroupMember.Tests.ps1 b/test/module/Entra/Remove-EntraGroupMember.Tests.ps1 index 2be0d8174..302d7fbc6 100644 --- a/test/module/Entra/Remove-EntraGroupMember.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroupMember.Tests.ps1 @@ -13,32 +13,32 @@ BeforeAll { Describe "Remove-EntraGroupMember" { Context "Test for Remove-EntraGroupMember" { It "Should reemove a member" { - $result = Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroupMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraGroupMember -ObjectId -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraGroupMember -GroupId -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraGroupMember -ObjectId "" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraGroupMember -GroupId "" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when MemberId is empty" { - { Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" + { Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" } It "Should fail when MemberId is invalid" { - { Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." + { Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgGroupMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" $params = Get-Parameters -data $result $params.GroupId | Should -Be "11112222-bbbb-3333-cccc-4444dddd5555" } @@ -46,7 +46,7 @@ Describe "Remove-EntraGroupMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupMember" - Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" + Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupMember" @@ -62,7 +62,7 @@ Describe "Remove-EntraGroupMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraGroupMember -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw + { Remove-EntraGroupMember -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -MemberId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraGroupOwner.Tests.ps1 b/test/module/Entra/Remove-EntraGroupOwner.Tests.ps1 index d6d9bb65c..4663a3927 100644 --- a/test/module/Entra/Remove-EntraGroupOwner.Tests.ps1 +++ b/test/module/Entra/Remove-EntraGroupOwner.Tests.ps1 @@ -13,32 +13,32 @@ BeforeAll { Describe "Remove-EntraGroupOwner" { Context "Test for Remove-EntraGroupOwner" { It "Should remove an owner" { - $result = Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgGroupOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraGroupOwner -ObjectId -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraGroupOwner -GroupId -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraGroupOwner -ObjectId "" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraGroupOwner -GroupId "" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when OwnerId is empty" { - { Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'*" + { Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'*" } It "Should fail when OwnerId is invalid" { - { Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "" } | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." + { Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "" } | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" $params = Get-Parameters -data $result $params.GroupId | Should -Be "11112222-bbbb-3333-cccc-4444dddd5555" } @@ -46,7 +46,7 @@ Describe "Remove-EntraGroupOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupOwner" - Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" + Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroupOwner" @@ -62,7 +62,7 @@ Describe "Remove-EntraGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraGroupOwner -ObjectId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw + { Remove-EntraGroupOwner -GroupId "11112222-bbbb-3333-cccc-4444dddd5555" -OwnerId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraUser.Tests.ps1 b/test/module/Entra/Set-EntraUser.Tests.ps1 index ac7f7eaa5..7c694bfeb 100644 --- a/test/module/Entra/Set-EntraUser.Tests.ps1 +++ b/test/module/Entra/Set-EntraUser.Tests.ps1 @@ -14,23 +14,23 @@ BeforeAll { Describe "Set-EntraUser" { Context "Test for Set-EntraUser" { It "Should return empty object" { - $result = Set-EntraUser -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo002" -UserPrincipalName "demo001@M365x99297270.OnMicrosoft.com" -AccountEnabled $true -MailNickName "demo002NickName" -AgeGroup "adult" -PostalCode "10001" + $result = Set-EntraUser -UserId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "demo002" -UserPrincipalName "demo001@M365x99297270.OnMicrosoft.com" -AccountEnabled $true -MailNickName "demo002NickName" -AgeGroup "adult" -PostalCode "10001" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgUser -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty" { + { Set-EntraUser -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is no value" { - { Set-EntraUser -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is no value" { + { Set-EntraUser -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should contain userId in parameters when passed ObjectId to it" { + It "Should contain userId in parameters when passed UserId to it" { Mock -CommandName Update-MgUser -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Set-EntraUser -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" + $result = Set-EntraUser -UserId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" $params = Get-Parameters -data $result $params.userId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" $params.MobilePhone | Should -Be "1234567890" @@ -39,7 +39,7 @@ Describe "Set-EntraUser" { It "Should contain MobilePhone in parameters when passed Mobile to it" { Mock -CommandName Update-MgUser -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Set-EntraUser -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" + $result = Set-EntraUser -UserId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" $params = Get-Parameters -data $result $params.MobilePhone | Should -Be "1234567890" } @@ -47,7 +47,7 @@ Describe "Set-EntraUser" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUser" - Set-EntraUser -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" + Set-EntraUser -UserId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUser" @@ -63,7 +63,7 @@ Describe "Set-EntraUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraUser -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" -Debug } | Should -Not -Throw + { Set-EntraUser -UserId bbbbbbbb-1111-2222-3333-cccccccccccc -Mobile "1234567890" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference @@ -75,7 +75,7 @@ Describe "Set-EntraUser" { # format like "yyyy-MM-dd HH:mm:ss" $userStateChangedOn = [System.DateTime]::Parse("2015-12-08 15:15:19") - $result = Set-EntraUser -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" ` + $result = Set-EntraUser -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" ` -UserState "PendingAcceptance" ` -UserStateChangedOn $userStateChangedOn ` -ImmutableId "djkjsajsa-e32j2-2i32" ` diff --git a/test/module/EntraBeta/Add-EntraBetaGroupMember.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaGroupMember.Tests.ps1 index d920fa782..e2dae53d5 100644 --- a/test/module/EntraBeta/Add-EntraBetaGroupMember.Tests.ps1 +++ b/test/module/EntraBeta/Add-EntraBetaGroupMember.Tests.ps1 @@ -14,32 +14,32 @@ BeforeAll { Describe "Add-EntraBetaGroupMember" { Context "Test for Add-EntraBetaGroupMember" { It "Should return empty object" { - $result = Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraBetaGroupMember -ObjectId -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when GroupId is empty" { + { Add-EntraBetaGroupMember -GroupId -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'GroupId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraBetaGroupMember -ObjectId "" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Add-EntraBetaGroupMember -GroupId "" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName New-MgBetaGroupMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } @@ -47,14 +47,14 @@ Describe "Add-EntraBetaGroupMember" { It "Should contain DirectoryObjectId in parameters when passed RefObjectId to it" { Mock -CommandName New-MgBetaGroupMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaGroupMember" - Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaGroupMember" Should -Invoke -CommandName New-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -70,7 +70,7 @@ Describe "Add-EntraBetaGroupMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw + { Add-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Add-EntraBetaGroupOwner.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaGroupOwner.Tests.ps1 index 8ba96dcb8..f908faff9 100644 --- a/test/module/EntraBeta/Add-EntraBetaGroupOwner.Tests.ps1 +++ b/test/module/EntraBeta/Add-EntraBetaGroupOwner.Tests.ps1 @@ -14,38 +14,38 @@ BeforeAll { Describe "Add-EntraBetaGroupOwner" { Context "Test for Add-EntraBetaGroupOwner" { It "Should return empty object" { - $result = Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgBetaGroupOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraBetaGroupOwner -ObjectId -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when GroupId is empty" { + { Add-EntraBetaGroupOwner -GroupId -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'GroupId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraBetaGroupOwner -ObjectId "" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Add-EntraBetaGroupOwner -GroupId "" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName New-MgBetaGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } It "Should contain BodyParameter in parameters when passed RefObjectId to it" { Mock -CommandName New-MgBetaGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $value = @{ "@odata.id" = "https://graph.microsoft.com/beta/users/bbbbcccc-1111-dddd-2222-eeee3333ffff"} Should -Invoke -CommandName New-MgBetaGroupOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -58,7 +58,7 @@ Describe "Add-EntraBetaGroupOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaGroupOwner" - Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaGroupOwner" Should -Invoke -CommandName New-MgBetaGroupOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -74,7 +74,7 @@ Describe "Add-EntraBetaGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug} | Should -Not -Throw + { Add-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug} | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaAdministrativeUnit.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaAdministrativeUnit.Tests.ps1 index 02c033584..369473dee 100644 --- a/test/module/EntraBeta/Get-EntraBetaAdministrativeUnit.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaAdministrativeUnit.Tests.ps1 @@ -30,6 +30,15 @@ BeforeAll { Describe "Get-EntraBetaAdministrativeUnit" { Context "Test for Get-EntraBetaAdministrativeUnit" { It "Should return specific administrative unit" { + $result = Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-Administrative-unit" + $result.Description | Should -Be "NewAdministrativeUnit" + + Should -Invoke -CommandName Get-MgBetaAdministrativeUnit -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific administrative unit with alias" { $result = Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" @@ -38,11 +47,11 @@ Describe "Get-EntraBetaAdministrativeUnit" { Should -Invoke -CommandName Get-MgBetaAdministrativeUnit -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaAdministrativeUnit -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraBetaAdministrativeUnit -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaAdministrativeUnit -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should return all administrative units" { $result = Get-EntraBetaAdministrativeUnit -All @@ -75,18 +84,18 @@ Describe "Get-EntraBetaAdministrativeUnit" { It "Should fail when filter is empty" { { Get-EntraBetaAdministrativeUnit -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" } - It "Result should contain ObjectId"{ - $result = Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + It "Result should contain AdministrativeUnitId"{ + $result = Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.ObjectId | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { - $result = Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-Administrative-unit' @@ -98,7 +107,7 @@ Describe "Get-EntraBetaAdministrativeUnit" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAdministrativeUnit" - $result = Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAdministrativeUnit" @@ -115,7 +124,7 @@ Describe "Get-EntraBetaAdministrativeUnit" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaAdministrativeUnitMember.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaAdministrativeUnitMember.Tests.ps1 index 83e8f56b9..da180e305 100644 --- a/test/module/EntraBeta/Get-EntraBetaAdministrativeUnitMember.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaAdministrativeUnitMember.Tests.ps1 @@ -32,6 +32,15 @@ BeforeAll { Describe "Get-EntraBetaAdministrativeUnitMember" { Context "Test for Get-EntraBetaAdministrativeUnitMember" { It "Should return specific administrative unit member" { + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result.AdditionalProperties.DisplayName | Should -Be "Mock-UnitMember" + $result.AdditionalProperties."@odata.type" | Should -Be "#microsoft.graph.user" + + Should -Invoke -CommandName Get-MgBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific administrative unit member with alias" { $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" @@ -40,58 +49,58 @@ Describe "Get-EntraBetaAdministrativeUnitMember" { Should -Invoke -CommandName Get-MgBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should return all administrative unit members" { - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -All + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All is invalid" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" } It "Should return top 1 administrative unit member" { - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top 1 + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" Should -Invoke -CommandName Get-MgBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top is empty" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" + It "Result should Contain AdministrativeUnitId" { + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "pppppppp-1111-1111-1111-aaaaaaaaaaaa" } It "Property parameter should work" { - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Property ID + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Property ID $result | Should -Not -BeNullOrEmpty $result.ID | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" Should -Invoke -CommandName Get-MgBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAdministrativeUnitMember" - $result = Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" + $result = Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAdministrativeUnitMember" @@ -108,7 +117,7 @@ Describe "Get-EntraBetaAdministrativeUnitMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaAdministrativeUnitMember -ObjectId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Debug } | Should -Not -Throw + { Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "pppppppp-1111-1111-1111-aaaaaaaaaaaa" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaGroup.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaGroup.Tests.ps1 index 567d1de85..d247540be 100644 --- a/test/module/EntraBeta/Get-EntraBetaGroup.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaGroup.Tests.ps1 @@ -27,19 +27,19 @@ BeforeAll { Describe "Get-EntraBetaGroup" { Context "Test for Get-EntraBetaGroup" { It "Should return specific group" { - $result = Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" + $result = Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccc55' Should -Invoke -CommandName Get-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaGroup -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraBetaGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraBetaGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should return all group" { @@ -91,13 +91,13 @@ Describe "Get-EntraBetaGroup" { { Get-EntraBetaGroup -Top y } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Result should Contain ObjectId" { - $result = Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" + It "Result should Contain GroupId" { + $result = Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccc55" } - It "Should contain GroupId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" + It "Should contain GroupId in parameters when passed GroupId to it" { + $result = Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc55" } @@ -108,29 +108,29 @@ Describe "Get-EntraBetaGroup" { $params.Filter | Should -Match "demo" } It "Property parameter should work" { - $result = Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property DisplayName + $result = Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'demo' Should -Invoke -CommandName Get-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Property parameter should work" { - $result = Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property DisplayName + $result = Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'demo' Should -Invoke -CommandName Get-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroup" - $result= Get-EntraBetaGroup -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc55" + $result= Get-EntraBetaGroup -GroupId "bbbbbbbb-1111-2222-3333-cccccccccc55" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroup" Should -Invoke -CommandName Get-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { diff --git a/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnit.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnit.Tests.ps1 index 2a130cfac..8f5d6cfb1 100644 --- a/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnit.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnit.Tests.ps1 @@ -14,28 +14,34 @@ BeforeAll { Describe "Remove-EntraBetaAdministrativeUnit" { Context "Test for Remove-EntraBetaAdministrativeUnit" { It "Should return empty object" { + $result = Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaAdministrativeUnit -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaAdministrativeUnit -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaAdministrativeUnit -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaAdministrativeUnit -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { Mock -CommandName Remove-MgBetaAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.AdministrativeUnitId | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaAdministrativeUnit" - Remove-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaAdministrativeUnit" @@ -51,7 +57,7 @@ Describe "Remove-EntraBetaAdministrativeUnit" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Remove-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnitMember.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnitMember.Tests.ps1 index 2c4e8031a..4f2eaed76 100644 --- a/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnitMember.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaAdministrativeUnitMember.Tests.ps1 @@ -14,27 +14,33 @@ BeforeAll { Describe "Remove-EntraBetaAdministrativeUnitMember" { Context "Test for Remove-EntraBetaAdministrativeUnitMember" { It "Should return empty object" { + $result = Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDirectoryAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaDirectoryAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaAdministrativeUnitMember -ObjectId -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaAdministrativeUnitMember -ObjectId "" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee"} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee"} | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when MemberId is empty" { - { Remove-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" + { Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" } It "Should fail when MemberId is invalid" { - { Remove-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId ""} | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." + { Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId ""} | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaAdministrativeUnitMember" - Remove-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" + Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaAdministrativeUnitMember" @@ -50,7 +56,7 @@ Describe "Remove-EntraBetaAdministrativeUnitMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" -Debug } | Should -Not -Throw + { Remove-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "dddddddd-9999-0000-1111-eeeeeeeeeeee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaGroupMember.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaGroupMember.Tests.ps1 index 339294eea..feed05675 100644 --- a/test/module/EntraBeta/Remove-EntraBetaGroupMember.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaGroupMember.Tests.ps1 @@ -14,39 +14,39 @@ BeforeAll { Describe "Remove-EntraBetaGroupMember" { Context "Test for Remove-EntraBetaGroupMember" { It "Should return empty object" { - $result = Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaGroupMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaGroupMember -ObjectId -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraBetaGroupMember -GroupId -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaGroupMember -ObjectId "" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraBetaGroupMember -GroupId "" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when MemberId is empty" { - { Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" + { Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" } It "Should fail when MemberId is invalid" { - { Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." + { Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgBetaGroupMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupMember" - $result = Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupMember" Should -Invoke -CommandName Remove-MgBetaGroupMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -62,7 +62,7 @@ Describe "Remove-EntraBetaGroupMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaGroupMember -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw + { Remove-EntraBetaGroupMember -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -MemberId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaGroupOwner.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaGroupOwner.Tests.ps1 index d85057516..37e1ebe5e 100644 --- a/test/module/EntraBeta/Remove-EntraBetaGroupOwner.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaGroupOwner.Tests.ps1 @@ -14,32 +14,32 @@ BeforeAll { Describe "Remove-EntraBetaGroupOwner" { Context "Test for Remove-EntraBetaGroupOwner" { It "Should return empty object" { - $result = Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaGroupOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaGroupOwner -ObjectId -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraBetaGroupOwner -GroupId -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaGroupOwner -ObjectId "" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraBetaGroupOwner -GroupId "" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should fail when OwnerId is empty" { - { Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'*" + { Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId } | Should -Throw "Missing an argument for parameter 'OwnerId'*" } It "Should fail when OwnerId is invalid" { - { Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId ""} | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." + { Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId ""} | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgBetaGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } @@ -47,14 +47,14 @@ Describe "Remove-EntraBetaGroupOwner" { It "Should contain DirectoryObjectId in parameters when passed OwnerId to it" { Mock -CommandName Remove-MgBetaGroupOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupOwner" - $result = Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupOwner" Should -Invoke -CommandName Remove-MgBetaGroupOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -70,7 +70,7 @@ Describe "Remove-EntraBetaGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaGroupOwner -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw + { Remove-EntraBetaGroupOwner -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -OwnerId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaScopedRoleMembership.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaScopedRoleMembership.Tests.ps1 index 0dcffd74a..8ba287d0a 100644 --- a/test/module/EntraBeta/Remove-EntraBetaScopedRoleMembership.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaScopedRoleMembership.Tests.ps1 @@ -13,35 +13,41 @@ BeforeAll { Describe "Remove-EntraBetaScopedRoleMembership" { Context "Test for Remove-EntraBetaScopedRoleMembership" { + It "Should return empty object" { + $result = Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } It "Should return empty object" { $result = Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaScopedRoleMembership -ObjectId -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaScopedRoleMembership -ObjectId "" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU"} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU"} | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when ScopedRoleMembershipId is empty" { - { Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" + { Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" } It "Should fail when ScopedRoleMembershipId is invalid" { - { Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId ""} | Should -Throw "Cannot bind argument to parameter 'ScopedRoleMembershipId' because it is an empty string." + { Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId ""} | Should -Throw "Cannot bind argument to parameter 'ScopedRoleMembershipId' because it is an empty string." } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { Mock -CommandName Remove-MgBetaDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result = Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $params = Get-Parameters -data $result $params.AdministrativeUnitId | Should -Be "dddddddd-1111-2222-3333-eeeeeeeeeeee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaScopedRoleMembership" - Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaScopedRoleMembership" @@ -57,7 +63,7 @@ Describe "Remove-EntraBetaScopedRoleMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Debug } | Should -Not -Throw + { Remove-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaAdministrativeUnit.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaAdministrativeUnit.Tests.ps1 index ef718b9af..9cc3e6786 100644 --- a/test/module/EntraBeta/Set-EntraBetaAdministrativeUnit.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaAdministrativeUnit.Tests.ps1 @@ -14,40 +14,40 @@ BeforeAll { Describe "Set-EntraBetaAdministrativeUnit" { Context "Test for Set-EntraBetaAdministrativeUnit" { It "Should return empty object" { - $result = Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted $true + $result = Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted $true $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgBetaAdministrativeUnit -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Id is empty" { - { Set-EntraBetaAdministrativeUnit -Id -DisplayName "Mock-Admin-Unit" } | Should -Throw "Missing an argument for parameter 'Id'*" + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId -DisplayName "Mock-Admin-Unit" } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when Id is invalid" { - { Set-EntraBetaAdministrativeUnit -Id "" -Description "NewAdministrativeUnit" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "" -Description "NewAdministrativeUnit" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when DisplayName is empty" { - { Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'*" + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'*" } It "Should fail when Description is empty" { - { Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description } | Should -Throw "Missing an argument for parameter 'Description'*" + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description } | Should -Throw "Missing an argument for parameter 'Description'*" } It "Should fail when IsMemberManagementRestricted is empty" { - { Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" --DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted } | Should -Throw "Missing an argument for parameter 'IsMemberManagementRestricted'*" + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" --DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted } | Should -Throw "Missing an argument for parameter 'IsMemberManagementRestricted'*" } It "Should fail when IsMemberManagementRestricted is invalid" { - { Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted "" } | Should -Throw "Cannot process argument transformation on parameter 'IsMemberManagementRestricted'.*" + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -IsMemberManagementRestricted "" } | Should -Throw "Cannot process argument transformation on parameter 'IsMemberManagementRestricted'.*" } It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { Mock -CommandName Update-MgBetaAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" + $result = Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" $params = Get-Parameters -data $result $params.AdministrativeUnitId | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaAdministrativeUnit" - Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" + Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaAdministrativeUnit" @@ -63,7 +63,7 @@ Describe "Set-EntraBetaAdministrativeUnit" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaAdministrativeUnit -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -Debug } | Should -Not -Throw + { Set-EntraBetaAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-Unit" -Description "NewAdministrativeUnit" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaUser.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaUser.Tests.ps1 index bfec77910..7cc5f64fb 100644 --- a/test/module/EntraBeta/Set-EntraBetaUser.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaUser.Tests.ps1 @@ -13,12 +13,17 @@ BeforeAll { Describe "Set-EntraBetaUser"{ Context "Test for Set-EntraBetaUser" { It "Should return empty object"{ + $result = Set-EntraBetaUser -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with alias"{ $result = Set-EntraBetaUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -DisplayName "Mock-App" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when ObjectId is empty" { - { Set-EntraBetaUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Set-EntraBetaUser -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should fail when invalid parameter is passed" { { Set-EntraBetaUser -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" @@ -26,38 +31,13 @@ Describe "Set-EntraBetaUser"{ It "Should contain UserId in parameters when passed ObjectId to it" { Mock -CommandName Update-MgBetaUser -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + $result = Set-EntraBetaUser -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' $params = Get-Parameters -data $result $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" - } - It "Should contain ExternalUserState, OnPremisesImmutableId, ExternalUserStateChangeDateTime, BusinessPhones, " { - Mock -CommandName Update-MgBetaUser -MockWith { $args } -ModuleName Microsoft.Graph.Entra.Beta - - # format like "yyyy-MM-dd HH:mm:ss" - $userStateChangedOn = [System.DateTime]::Parse("2015-12-08 15:15:19") - - $result = Set-EntraBetaUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" ` - -UserState "PendingAcceptance" ` - -UserStateChangedOn $userStateChangedOn ` - -ImmutableId "djkjsajsa-e32j2-2i32" ` - -Mobile "123111221" ` - -TelephoneNumber "1234567890" - - $params = Get-Parameters -data $result - - $params.BusinessPhones[0] | Should -Be "1234567890" - - $params.MobilePhone | Should -Be "123111221" - - $params.ExternalUserState | Should -Be "PendingAcceptance" - - $params.OnPremisesImmutableId | Should -Be "djkjsajsa-e32j2-2i32" - - $params.ExternalUserStateChangeDateTime | Should -Be $userStateChangedOn - } + } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaUser" - $result = Set-EntraBetaUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + $result = Set-EntraBetaUser -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaUser" Should -Invoke -CommandName Update-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -72,7 +52,7 @@ Describe "Set-EntraBetaUser"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb'-Debug } | Should -Not -Throw + { Set-EntraBetaUser -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb'-Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From bdc0353f9d3c18355d133e9a447f96ce1eb9c373 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 25 Sep 2024 23:16:22 +0530 Subject: [PATCH 30/64] fixed UT --- src/CompatibilityAdapterBuilder.ps1 | 1 - .../Get-EntraBetaApplication.Tests.ps1 | 29 ++++++---- ...ntraBetaAdministrativeUnitMember.Tests.ps1 | 55 ++++++++++--------- .../Remove-EntraBetaApplication.Tests.ps1 | 17 ++++-- .../EntraBeta/Remove-EntraBetaGroup.Tests.ps1 | 23 +++++--- ...ve-EntraBetaGroupLifecyclePolicy.Tests.ps1 | 23 +++++--- .../EntraBeta/Remove-EntraBetaUser.Tests.ps1 | 17 ++++-- .../Set-EntraBetaApplication.Tests.ps1 | 17 ++++-- .../EntraBeta/Set-EntraBetaGroup.Tests.ps1 | 35 +++++++----- 9 files changed, 131 insertions(+), 86 deletions(-) diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index cd6636581..4e4d52027 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -139,7 +139,6 @@ class CompatibilityAdapterBuilder { 'Select-EntraBetaGroupIdsUserIsMemberOf', 'Set-EntraBetaNamedLocationPolicy', 'New-EntraBetaNamedLocationPolicy', - 'Remove-EntraBetaApplication', 'Restore-EntraBetaDeletedApplication', 'Remove-EntraBetaPermissionGrantConditionSet' diff --git a/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 index 3f8356ec9..47dab27af 100644 --- a/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 @@ -38,13 +38,18 @@ BeforeAll { Describe "Get-EntraBetaApplication" { Context "Test for Get-EntraBetaApplication" { It "Should return specific application" { - $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('aaaaaaaa-1111-1111-1111-000000000000') Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should execute successfully with Alias" { + $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ApplicationId is empty" { + { Get-EntraBetaApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } It "Should return all applications" { $result = Get-EntraBetaApplication -All @@ -74,12 +79,12 @@ Describe "Get-EntraBetaApplication" { $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Result should Contain ObjectId" { - $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + It "Result should Contain ApplicationId" { + $result = Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $result.ObjectId | should -Be "aaaaaaaa-1111-1111-1111-000000000000" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "aaaaaaaa-1111-1111-1111-000000000000" } @@ -90,7 +95,7 @@ Describe "Get-EntraBetaApplication" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplication" - $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplication" Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -99,7 +104,7 @@ Describe "Get-EntraBetaApplication" { } } It "Property parameter should work" { - $result = Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -Property DisplayName + $result = Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' @@ -107,7 +112,7 @@ Describe "Get-EntraBetaApplication" { } It "Should fail when Property is empty" { - { Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error " { # Disable confirmation prompts @@ -116,7 +121,7 @@ Describe "Get-EntraBetaApplication" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw + { Get-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference @@ -144,7 +149,7 @@ Describe "Get-EntraBetaApplication" { It 'Should have Get parameterSet' { $GetAzureADApplication = Get-Command Get-EntraBetaApplication $GetParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetById" - $GetParameterSet.Parameters.Name | Should -Contain ObjectId + $GetParameterSet.Parameters.Name | Should -Contain ApplicationId } It 'Should have GetViaIdentity parameterSet' { $GetAzureADApplication = Get-Command Get-EntraBetaApplication diff --git a/test/module/EntraBeta/New-EntraBetaAdministrativeUnitMember.Tests.ps1 b/test/module/EntraBeta/New-EntraBetaAdministrativeUnitMember.Tests.ps1 index 5166c43af..00e76cdfb 100644 --- a/test/module/EntraBeta/New-EntraBetaAdministrativeUnitMember.Tests.ps1 +++ b/test/module/EntraBeta/New-EntraBetaAdministrativeUnitMember.Tests.ps1 @@ -43,7 +43,7 @@ BeforeAll { Describe "New-EntraBetaAdministrativeUnitMember" { Context "Test for New-EntraBetaAdministrativeUnitMember" { It "Should return created administrative unit member" { - $result = New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False + $result = New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.AdditionalProperties.DisplayName | Should -Be "Mock-Admin-UnitMember" @@ -51,65 +51,70 @@ Describe "New-EntraBetaAdministrativeUnitMember" { Should -Invoke -CommandName New-MGBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when Id is empty" { - {New-EntraBetaAdministrativeUnitMember -Id -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should execute successfully with Alias" { + $result = New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName New-MGBetaAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when AdministrativeUnitId is empty" { + {New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when Id is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False} | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False} | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when DisplayName is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'DisplayName'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'DisplayName'*" } It "Should fail when DisplayName is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." } It "Should fail when Description is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'Description'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'Description'*" } It "Should fail when MailNickname is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MailNickname'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MailNickname'*" } It "Should fail when MailNickname is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "" -SecurityEnabled $False } | Should -Throw "Cannot bind argument to parameter 'MailNickname' because it is an empty string." + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "" -SecurityEnabled $False } | Should -Throw "Cannot bind argument to parameter 'MailNickname' because it is an empty string." } It "Should fail when MailEnabled is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MailEnabled'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MailEnabled'*" } It "Should fail when MailEnabled is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled xy -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Cannot process argument transformation on parameter 'MailEnabled'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled xy -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Cannot process argument transformation on parameter 'MailEnabled'*" } It "Should fail when SecurityEnabled is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled } | Should -Throw "Missing an argument for parameter 'SecurityEnabled'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled } | Should -Throw "Missing an argument for parameter 'SecurityEnabled'*" } It "Should fail when SecurityEnabled is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled xy } | Should -Throw "Cannot process argument transformation on parameter 'SecurityEnabled'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled xy } | Should -Throw "Cannot process argument transformation on parameter 'SecurityEnabled'*" } It "Should fail when OdataType is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'OdataType'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'OdataType'*" } It "Should fail when GroupTypes is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -GroupTypes -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'GroupTypes'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -GroupTypes -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'GroupTypes'*" } It "Should fail when MembershipRule is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -MembershipRule -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MembershipRule'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -MembershipRule -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MembershipRule'*" } It "Should fail when MembershipRuleProcessingState is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -MembershipRuleProcessingState -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MembershipRuleProcessingState'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -MembershipRuleProcessingState -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'MembershipRuleProcessingState'*" } It "Should fail when AssignedLabels is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -AssignedLabels -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'AssignedLabels'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -AssignedLabels -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'AssignedLabels'*" } It "Should fail when ProxyAddresses is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -ProxyAddresses -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'ProxyAddresses'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -ProxyAddresses -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False } | Should -Throw "Missing an argument for parameter 'ProxyAddresses'*" } It "Should fail when IsAssignableToRole is empty" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -IsAssignableToRole } | Should -Throw "Missing an argument for parameter 'IsAssignableToRole'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -IsAssignableToRole } | Should -Throw "Missing an argument for parameter 'IsAssignableToRole'*" } It "Should fail when IsAssignableToRole is invalid" { - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -IsAssignableToRole xy } | Should -Throw "Cannot process argument transformation on parameter 'IsAssignableToRole'*" + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -IsAssignableToRole xy } | Should -Throw "Cannot process argument transformation on parameter 'IsAssignableToRole'*" } It "Should contain @odata.type in parameters when passed OdataType to it" { - $result = New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False + $result = New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False $jsonArray = $result.Parameters $hashTable = @{} @@ -128,7 +133,7 @@ Describe "New-EntraBetaAdministrativeUnitMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaAdministrativeUnitMember" - $result = New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False + $result = New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaAdministrativeUnitMember" @@ -144,7 +149,7 @@ Describe "New-EntraBetaAdministrativeUnitMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False -Debug } | Should -Not -Throw + { New-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" -OdataType "Microsoft.Graph.Group" -DisplayName "Mock-Admin-UnitMember" -Description "NewAdministrativeUnitMember" -MailEnabled $True -MailNickname "Mock-Admin-UnitMember" -SecurityEnabled $False -GroupTypes @("Unified","DynamicMembership") -MembershipRule "(user.department -contains 'Marketing')" -MembershipRuleProcessingState "On" -IsAssignableToRole $False -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 index 8a33f6c32..10b047a94 100644 --- a/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 @@ -13,25 +13,30 @@ BeforeAll { Describe "Remove-EntraBetaApplication" { Context "Test for Remove-EntraBetaApplication" { It "Should return empty object" { + $result = Remove-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + It "Should fail when ApplicationId is empty" { + { Remove-EntraBetaApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter*" } It "Should fail when invalid parameter is passed" { { Remove-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Remove-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Remove-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-1111-1111-1111-000000000000" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaApplication" - $result = Remove-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Remove-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaApplication" Should -Invoke -CommandName Remove-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -46,7 +51,7 @@ Describe "Remove-EntraBetaApplication" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw + { Remove-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaGroup.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaGroup.Tests.ps1 index f95401c2a..ec5c72645 100644 --- a/test/module/EntraBeta/Remove-EntraBetaGroup.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaGroup.Tests.ps1 @@ -14,24 +14,31 @@ BeforeAll { Describe "Remove-EntraBetaGroup" { Context "Test for Remove-EntraBetaGroup" { It "Should return empty Id" { + $result = Remove-EntraBetaGroup -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should execute successfully with Alias" { $result = Remove-EntraBetaGroup -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaGroup -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Remove-EntraBetaGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Remove-EntraBetaGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Remove-MgBetaGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaGroup -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraBetaGroup -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $params = Get-Parameters -data $result $params.GroupId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } @@ -39,7 +46,7 @@ Describe "Remove-EntraBetaGroup" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroup" - $result = Remove-EntraBetaGroup -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraBetaGroup -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroup" @@ -57,7 +64,7 @@ Describe "Remove-EntraBetaGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaGroup -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw + { Remove-EntraBetaGroup -GroupId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaGroupLifecyclePolicy.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaGroupLifecyclePolicy.Tests.ps1 index 16e14fd08..49733f2c4 100644 --- a/test/module/EntraBeta/Remove-EntraBetaGroupLifecyclePolicy.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaGroupLifecyclePolicy.Tests.ps1 @@ -14,31 +14,38 @@ BeforeAll { Describe "Remove-EntraBetaGroupLifecyclePolicy" { Context "Test for Remove-EntraBetaGroupLifecyclePolicy" { It "Should return empty Id" { + $result = Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should execute successfully with Alias" { $result = Remove-EntraBetaGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when Id is empty" { - { Remove-EntraBetaGroupLifecyclePolicy -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupLifecyclePolicyId is empty" { + { Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraBetaGroupLifecyclePolicy -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string." } - It "Should contain GroupLifecyclePolicyId in parameters when passed Id to it" { + It "Should contain GroupLifecyclePolicyId in parameters when passed GroupLifecyclePolicyId to it" { Mock -CommandName Remove-MgBetaGroupLifecyclePolicy -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $params = Get-Parameters -data $result $params.GroupLifecyclePolicyId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupLifecyclePolicy" - $result = Remove-EntraBetaGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" + $result = Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupLifecyclePolicy" Should -Invoke -CommandName Remove-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -54,7 +61,7 @@ Describe "Remove-EntraBetaGroupLifecyclePolicy" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaGroupLifecyclePolicy -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw + { Remove-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaUser.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaUser.Tests.ps1 index fde360383..ea63ef91b 100644 --- a/test/module/EntraBeta/Remove-EntraBetaUser.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaUser.Tests.ps1 @@ -13,26 +13,31 @@ BeforeAll { Describe "Remove-EntraBetaUser" { Context "Test for Remove-EntraBetaUser" { It "Should return empty object" { + $result = Remove-EntraBetaUser -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { $result = Remove-EntraBetaUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaUser -ObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + It "Should fail when UserId is empty" { + { Remove-EntraBetaUser -UserId "" } | Should -Throw "Cannot bind argument to parameter*" } It "Should fail when invalid parameter is passed" { { Remove-EntraBetaUser -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { Mock -CommandName Remove-MgBetaUser -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Remove-EntraBetaUser -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaUser" - $result = Remove-EntraBetaUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Remove-EntraBetaUser -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaUser" Should -Invoke -CommandName Remove-MgBetaUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -47,7 +52,7 @@ Describe "Remove-EntraBetaUser" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Remove-EntraBetaUser -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 index c63a7f373..9d9d2ddb7 100644 --- a/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 @@ -13,25 +13,30 @@ BeforeAll { Describe "Set-EntraBetaApplication"{ Context "Test for Set-EntraBetaApplication" { It "Should return empty object"{ + $result = Set-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { $result = Set-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -DisplayName "Mock-App" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is empty" { + { Set-EntraBetaApplication -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } It "Should fail when invalid parameter is passed" { { Set-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Update-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Set-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-1111-1111-1111-000000000000" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaApplication" - $result = Set-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" + $result = Set-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaApplication" Should -Invoke -CommandName Update-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -46,7 +51,7 @@ Describe "Set-EntraBetaApplication"{ try { # Act & Assert: Ensure the function doesn't throw an exception - {Set-EntraBetaApplication -ObjectId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw + {Set-EntraBetaApplication -ApplicationId "aaaaaaaa-1111-1111-1111-000000000000" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaGroup.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaGroup.Tests.ps1 index 138d01c2d..85e4c5e51 100644 --- a/test/module/EntraBeta/Set-EntraBetaGroup.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaGroup.Tests.ps1 @@ -14,55 +14,62 @@ BeforeAll { Describe "Set-EntraBetaGroup" { Context "Test for Set-EntraBetaGroup" { It "Should return empty object" { + $result = Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description "Update Group" -DisplayName "Update My Test san" -MailEnabled $false -MailNickname "Update nickname" -SecurityEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should execute successfully with Alias" { $result = Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description "Update Group" -DisplayName "Update My Test san" -MailEnabled $false -MailNickname "Update nickname" -SecurityEnabled $true $result | Should -BeNullOrEmpty Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraBetaGroup -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupId is empty" { + { Set-EntraBetaGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Set-EntraBetaGroup -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string.*" + It "Should fail when GroupId is invalid" { + { Set-EntraBetaGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string.*" } It "Should fail when Description is empty" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description } | Should -Throw "Missing an argument for parameter 'Description'.*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Description } | Should -Throw "Missing an argument for parameter 'Description'.*" } It "Should fail when DisplayName is empty" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'.*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'.*" } It "Should fail when MailEnabled is empty" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailEnabled } | Should -Throw "Missing an argument for parameter*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailEnabled } | Should -Throw "Missing an argument for parameter*" } It "Should fail when MailEnabled is invalid" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailEnabled ""} | Should -Throw "Cannot process argument transformation on parameter 'MailEnabled'.*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailEnabled ""} | Should -Throw "Cannot process argument transformation on parameter 'MailEnabled'.*" } It "Should fail when MailNickname is empty" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailNickname } | Should -Throw "Missing an argument for parameter*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -MailNickname } | Should -Throw "Missing an argument for parameter*" } It "Should fail when SecurityEnabled is empty" { - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -SecurityEnabled } | Should -Throw "Missing an argument for parameter*" + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -SecurityEnabled } | Should -Throw "Missing an argument for parameter*" } - It "Should contain GroupId in parameters when passed ObjectId to it" { + It "Should contain GroupId in parameters when passed GroupId to it" { Mock -CommandName Update-MgBetaGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result $params.GroupId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaGroup" - $result = Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaGroup" Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -78,7 +85,7 @@ Describe "Set-EntraBetaGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Set-EntraBetaGroup -GroupId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 9e40df7af2f364723ce8d195361d5aed51548532 Mon Sep 17 00:00:00 2001 From: v-uansari <143997438+v-uansari@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:21:12 +0530 Subject: [PATCH 31/64] Name changes (#1092) * Name changes * parameter name changes * alice added * alice change * Alias change * alias added * alias UT changes * alias changes * doc fix * alias added * alias changes * Ut chagnes --------- Co-authored-by: v-varshamane <142500640+v-varshamane@users.noreply.github.com> --- .../Add-EntraBetaAdministrativeUnitMember.ps1 | 12 +++++- .../Add-EntraBetaScopedRoleMembership.ps1 | 16 ++++++- .../Get-EntraBetaApplicationLogo.ps1 | 16 ++++++- .../Get-EntraBetaApplicationOwner.ps1 | 16 ++++++- .../customizations/Get-EntraBetaContact.ps1 | 20 +++++++-- .../Get-EntraBetaDeviceRegisteredOwner.ps1 | 16 ++++++- .../Get-EntraBetaDeviceRegisteredUser.ps1 | 17 +++++++- .../Get-EntraBetaDirectoryRoleDefinition.ps1 | 16 +++++++ .../Get-EntraBetaDirectoryRoleMember.ps1 | 12 +++++- .../Get-EntraBetaGroupMember.ps1 | 16 ++++++- .../Get-EntraBetaGroupOwner.ps1 | 18 ++++++-- .../Get-EntraBetaScopedRoleMembership.ps1 | 14 +++++- .../Get-EntraBetaSubscribedSku.ps1 | 13 +++++- .../Get-EntraBetaUserCreatedObject.ps1 | 16 ++++++- .../Get-EntraBetaUserDirectReport.ps1 | 18 ++++++-- .../Get-EntraBetaUserManager.ps1 | 12 +++++- .../Get-EntraBetaUserOwnedDevice.ps1 | 16 ++++++- .../Get-EntraBetaUserOwnedObject.ps1 | 16 ++++++- .../Get-EntraBetaUserRegisteredDevice.ps1 | 16 ++++++- ...EntraBetaApplicationPasswordCredential.ps1 | 18 +++++++- .../Set-EntraBetaApplicationLogo.ps1 | 21 +++++++-- .../Set-EntraBetaIdentityProvider.ps1 | 18 +++++++- .../Add-EntraBetaScopedRoleMembership.md | 12 +++--- .../Get-EntraBetaApplicationLogo.md | 12 +++--- .../Get-EntraBetaApplicationOwner.md | 18 ++++---- .../Get-EntraBetaDeviceRegisteredOwner.md | 24 +++++------ .../Get-EntraBetaDeviceRegisteredUser.md | 18 ++++---- .../Get-EntraBetaDirectoryRoleDefinition.md | 14 +++--- .../Get-EntraBetaDirectoryRoleMember.md | 12 +++--- .../Get-EntraBetaGroupMember.md | 26 +++++------ .../Get-EntraBetaGroupOwner.md | 2 +- .../Get-EntraBetaScopedRoleMembership.md | 20 ++++----- .../Get-EntraBetaSubscribedSku.md | 14 +++--- .../Get-EntraBetaUserCreatedObject.md | 20 ++++----- .../Get-EntraBetaUserDirectReport.md | 20 ++++----- .../Get-EntraBetaUserManager.md | 14 +++--- .../Get-EntraBetaUserOwnedDevice.md | 14 +++--- .../Get-EntraBetaUserOwnedObject.md | 22 +++++----- .../Get-EntraBetaUserRegisteredDevice.md | 14 +++--- ...-EntraBetaApplicationPasswordCredential.md | 22 +++++----- .../Set-EntraBetaApplicationLogo.md | 23 ++++------ .../Set-EntraBetaIdentityProvider.md | 18 ++++---- .../Get-EntraDirectoryRoleDefinition.md | 14 +++--- .../Get-EntraAdministrativeUnit.Tests.ps1 | 9 +--- .../Set-EntraAdministrativeUnit.Tests.ps1 | 2 +- ...ntraBetaAdministrativeUnitMember.Tests.ps1 | 28 +++++++----- ...dd-EntraBetaScopedRoleMembership.Tests.ps1 | 43 ++++++++++++------- .../Get-EntraBetaApplicationLogo.Tests.ps1 | 14 +++--- .../Get-EntraBetaGroupOwner.Tests.ps1 | 40 ++++++++++------- ...et-EntraBetaScopedRoleMembership.Tests.ps1 | 33 ++++++++------ .../Get-EntraBetaUserManager.Tests.ps1 | 22 ++++++---- .../Get-EntraBetaUserOwnedDevice.Tests.ps1 | 26 +++++------ ...et-EntraBetaUserRegisteredDevice.Tests.ps1 | 26 +++++------ .../Set-EntraBetaApplicationLogo.Tests.ps1 | 16 +++---- 54 files changed, 629 insertions(+), 336 deletions(-) diff --git a/module/EntraBeta/customizations/Add-EntraBetaAdministrativeUnitMember.ps1 b/module/EntraBeta/customizations/Add-EntraBetaAdministrativeUnitMember.ps1 index 6c8682061..61032285a 100644 --- a/module/EntraBeta/customizations/Add-EntraBetaAdministrativeUnitMember.ps1 +++ b/module/EntraBeta/customizations/Add-EntraBetaAdministrativeUnitMember.ps1 @@ -7,6 +7,14 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $RefObjectId, + [Alias('Id')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +23,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($null -ne $PSBoundParameters["RefObjectId"]) { diff --git a/module/EntraBeta/customizations/Add-EntraBetaScopedRoleMembership.ps1 b/module/EntraBeta/customizations/Add-EntraBetaScopedRoleMembership.ps1 index bf5305540..dfce8f5dd 100644 --- a/module/EntraBeta/customizations/Add-EntraBetaScopedRoleMembership.ps1 +++ b/module/EntraBeta/customizations/Add-EntraBetaScopedRoleMembership.ps1 @@ -7,6 +7,18 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $RoleObjectId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $AdministrativeUnitObjectId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [Microsoft.Open.AzureAD.Model.RoleMemberInfo] $RoleMemberInfo, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -47,9 +59,9 @@ { $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($null -ne $PSBoundParameters["OutBuffer"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationLogo.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationLogo.ps1 index 9baa551a4..6c9c1229e 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationLogo.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationLogo.ps1 @@ -7,14 +7,26 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FilePath, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FileName, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Boolean] $View, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/beta/applications' $Method = "GET" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $URI = "$baseUri/$($params.ApplicationId)" } if($null -ne $PSBoundParameters["FilePath"]){ diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 index 1f9648ebf..d16e64913 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 @@ -7,6 +7,18 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +27,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 b/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 index 46811af95..000b5c8d1 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 @@ -7,13 +7,27 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Alias('ObjectId')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $OrgContactId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - $keysChanged = @{ObjectId = "Id"} - if($null -ne $PSBoundParameters["ObjectId"]) + $keysChanged = @{OrgContactId = "Id"} + if($null -ne $PSBoundParameters["OrgContactId"]) { - $params["OrgContactId"] = $PSBoundParameters["ObjectId"] + $params["OrgContactId"] = $PSBoundParameters["OrgContactId"] } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 index 27d6af012..9c0efda07 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +27,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DeviceId"]) { - $params["DeviceId"] = $PSBoundParameters["ObjectId"] + $params["DeviceId"] = $PSBoundParameters["DeviceId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 index 71cc56403..e2fabda03 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 @@ -7,6 +7,19 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DeviceId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +28,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DeviceId"]) { - $params["DeviceId"] = $PSBoundParameters["ObjectId"] + $params["DeviceId"] = $PSBoundParameters["DeviceId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 index 5fdc1cbcc..25b307ba5 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 @@ -7,6 +7,22 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Alias('Id')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UnifiedRoleDefinitionId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand diff --git a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleMember.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleMember.ps1 index 468508732..4b553ece4 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleMember.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleMember.ps1 @@ -7,6 +7,14 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $DirectoryRoleId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +23,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["DirectoryRoleId"]) { - $params["DirectoryRoleId"] = $PSBoundParameters["ObjectId"] + $params["DirectoryRoleId"] = $PSBoundParameters["DirectoryRoleId"] } if($PSBoundParameters.ContainsKey("Debug")) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 index 348c08ac3..bb5fa6d52 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 @@ -7,13 +7,25 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["GroupId"]) { - $params["GroupId"] = $PSBoundParameters["ObjectId"] + $params["GroupId"] = $PSBoundParameters["GroupId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 index 33f20023c..51839b03d 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 @@ -6,7 +6,19 @@ TargetName = $null Parameters = $null outputs = $null - CustomScript = @' + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -21,9 +33,9 @@ $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["GroupId"]) { - $params["GroupId"] = $PSBoundParameters["ObjectId"] + $params["GroupId"] = $PSBoundParameters["GroupId"] $URI = "$baseUri/$($params.GroupId)/owners?$properties" } diff --git a/module/EntraBeta/customizations/Get-EntraBetaScopedRoleMembership.ps1 b/module/EntraBeta/customizations/Get-EntraBetaScopedRoleMembership.ps1 index ba6178f63..1b8d917a2 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaScopedRoleMembership.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaScopedRoleMembership.ps1 @@ -7,6 +7,16 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ScopedRoleMembershipId, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AdministrativeUnitId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +25,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["AdministrativeUnitId"]) { - $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] + $params["AdministrativeUnitId"] = $PSBoundParameters["AdministrativeUnitId"] } if($PSBoundParameters.ContainsKey("Debug")) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaSubscribedSku.ps1 b/module/EntraBeta/customizations/Get-EntraBetaSubscribedSku.ps1 index 25f08a7e1..af22bce16 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaSubscribedSku.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaSubscribedSku.ps1 @@ -7,6 +7,15 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Alias('ObjectId')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SubscribedSkuId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +24,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["SubscribedSkuId"]) { - $params["SubscribedSkuId"] = $PSBoundParameters["ObjectId"] + $params["SubscribedSkuId"] = $PSBoundParameters["SubscribedSkuId"] } if($PSBoundParameters.ContainsKey("Debug")) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 index ad46a4fcf..fbc72647d 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -14,9 +26,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 index feb2cced4..ac21c406e 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 @@ -6,7 +6,19 @@ TargetName = $null Parameters = $null outputs = $null - CustomScript = @' + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -21,9 +33,9 @@ $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] $URI = "$baseUri/$($params.UserId)/directReports?$properties" } diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserManager.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserManager.ps1 index ab840b5e4..5be69e9f4 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserManager.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserManager.ps1 @@ -7,6 +7,14 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [ALias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +23,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($PSBoundParameters.ContainsKey("Debug")) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 index fe07f1670..8877bc656 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +27,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 index b3f2ee308..41a3e9edb 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 @@ -7,12 +7,24 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $Method = "GET" $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - if ($null -ne $PSBoundParameters["ObjectId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + if ($null -ne $PSBoundParameters["UserId"]) { + $params["UserId"] = $PSBoundParameters["UserId"] } $URI = "/beta/users/$($params.UserId)/ownedObjects/?" diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 index 2177b0bcc..5a813dc68 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 @@ -7,6 +7,18 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $UserId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -15,9 +27,9 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["UserId"]) { - $params["UserId"] = $PSBoundParameters["ObjectId"] + $params["UserId"] = $PSBoundParameters["UserId"] } if($null -ne $PSBoundParameters["All"]) { diff --git a/module/EntraBeta/customizations/New-EntraBetaApplicationPasswordCredential.ps1 b/module/EntraBeta/customizations/New-EntraBetaApplicationPasswordCredential.ps1 index d9d739b70..006415a6e 100644 --- a/module/EntraBeta/customizations/New-EntraBetaApplicationPasswordCredential.ps1 +++ b/module/EntraBeta/customizations/New-EntraBetaApplicationPasswordCredential.ps1 @@ -7,6 +7,20 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $EndDate, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $CustomKeyIdentifier, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $StartDate, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $ApplicationId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Value + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand @@ -25,9 +39,9 @@ { $body["displayName"] = $PSBoundParameters["CustomKeyIdentifier"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] } if($PSBoundParameters.ContainsKey("Verbose")) { diff --git a/module/EntraBeta/customizations/Set-EntraBetaApplicationLogo.ps1 b/module/EntraBeta/customizations/Set-EntraBetaApplicationLogo.ps1 index 3b9626b8b..9b9e52f3e 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaApplicationLogo.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaApplicationLogo.ps1 @@ -6,7 +6,22 @@ TargetName = $null Parameters = $null outputs = $null - CustomScript = @' + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'File')] + param ( + [Parameter(ParameterSetName = "File", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $FilePath, + [Alias('ObjectId')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = "Stream")] + [Parameter(ParameterSetName = "File")] + [Parameter(ParameterSetName = "ByteArray")] + [System.String] $ApplicationId, + [Parameter(ParameterSetName = "ByteArray", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Byte[]] $ImageByteArray, + [Parameter(ParameterSetName = "Stream", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.IO.Stream] $FileStream + ) PROCESS { try{ $params = @{} @@ -14,9 +29,9 @@ $baseUri = 'https://graph.microsoft.com/beta/applications' $Method = "PUT" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $params["ApplicationId"] = $PSBoundParameters["ObjectId"] + $params["ApplicationId"] = $PSBoundParameters["ApplicationId"] $URI = "$baseUri/$($params.ApplicationId)/logo" } if($null -ne $PSBoundParameters["FilePath"]){ diff --git a/module/EntraBeta/customizations/Set-EntraBetaIdentityProvider.ps1 b/module/EntraBeta/customizations/Set-EntraBetaIdentityProvider.ps1 index 6b20673be..8b5f1c1fa 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaIdentityProvider.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaIdentityProvider.ps1 @@ -7,13 +7,27 @@ Parameters = $null outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Type, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ClientSecret, + [Alias('Id')] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $IdentityProviderBaseId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $ClientId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Name + ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $body = @{} - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["IdentityProviderBaseId"]) { - $params["IdentityProviderBaseId"] = $PSBoundParameters["Id"] + $params["IdentityProviderBaseId"] = $PSBoundParameters["IdentityProviderBaseId"] } if($null -ne $PSBoundParameters["Type"]) { diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaScopedRoleMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaScopedRoleMembership.md index b763305a7..5176d54d6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaScopedRoleMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaScopedRoleMembership.md @@ -27,7 +27,7 @@ Assign a Microsoft Entra role with an administrative unit scope. ```powershell Add-EntraBetaScopedRoleMembership - -ObjectId + -AdministrativeUnitId [-RoleMemberInfo ] [-RoleObjectId ] [] @@ -35,7 +35,7 @@ Add-EntraBetaScopedRoleMembership ## Description -The `Add-EntraBetaScopedRoleMembership` cmdlet adds a scoped role membership to an administrative unit. Specify `ObjectId` parameter to add a scoped role membership. +The `Add-EntraBetaScopedRoleMembership` cmdlet adds a scoped role membership to an administrative unit. Specify `AdministrativeUnitId` parameter to add a scoped role membership. For delegated scenarios, the calling user needs at least the Privileged Role Administrator Microsoft Entra role. @@ -51,7 +51,7 @@ $Unit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ' + -ApplicationId [-FileName ] [-FilePath ] [-View ] @@ -36,7 +36,7 @@ Get-EntraBetaApplicationLogo ## Description -The `Get-EntraBetaApplicationLogo` cmdlet retrieves the logo that is set for an application. Specify the `ObjectId` parameter to get a specific application logo for an application. +The `Get-EntraBetaApplicationLogo` cmdlet retrieves the logo that is set for an application. Specify the `ApplicationId` parameter to get a specific application logo for an application. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraBetaApplicationLogo` cmdlet retrieves the logo that is set for an ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraBetaApplicationLogo -ObjectId 'bbbbbbbb-1111-1111-1111-cccccccccccc' -FilePath 'D:\outfile1.jpg' +Get-EntraBetaApplicationLogo -ApplicationId 'bbbbbbbb-1111-1111-1111-cccccccccccc' -FilePath 'D:\outfile1.jpg' ``` This example shows how to retrieve the application logo for an application that is specified through the Object ID parameter. @@ -83,14 +83,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId -The ObjectID of the application for which the logo is to be retrieved. +The ApplicationId of the application for which the logo is to be retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationOwner.md index 31920fdee..b218c9424 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationOwner.md @@ -26,7 +26,7 @@ Gets the owner of an application. ```powershell Get-EntraBetaApplicationOwner - -ObjectId + -ApplicationId [-Top ] [-All] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraBetaApplicationOwner` cmdlet get an owner of an Microsoft Entra ID ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' -Get-EntraBetaApplicationOwner -ObjectId $Application.ObjectId +Get-EntraBetaApplicationOwner -ApplicationId $Application.ObjectId ``` ```Output @@ -58,7 +58,7 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example demonstrates how to get the owners of an application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ### Example 2: Get the details about the owner of an application @@ -93,7 +93,7 @@ This example demonstrates how to get the owners of an application in Microsoft E ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' -Get-EntraBetaApplicationOwner -ObjectId $Application.ObjectId -All +Get-EntraBetaApplicationOwner -ApplicationId $Application.ObjectId -All ``` ```Output @@ -107,14 +107,14 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example demonstrates how to get the all owners of a specified application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ### Example 4: Get top two owners of an application ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' -Get-EntraBetaApplicationOwner -ObjectId $Application.ObjectId -Top 2 +Get-EntraBetaApplicationOwner -ApplicationId $Application.ObjectId -Top 2 ``` ```Output @@ -126,7 +126,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example demonstrates how to get the two owners of a specified application in Microsoft Entra ID. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. ## Parameters @@ -146,14 +146,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredOwner.md index ffef44c2e..393ec542f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredOwner.md @@ -27,7 +27,7 @@ Gets the registered owner of a device. ```powershell Get-EntraBetaDeviceRegisteredOwner - -ObjectId + -DeviceId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraBetaDeviceRegisteredOwner ## Description -The `Get-EntraBetaDeviceRegisteredOwner` cmdlet gets the registered owner of a device in Microsoft Entra ID. Specify `ObjectId` parameter gets the registered owner of a device. +The `Get-EntraBetaDeviceRegisteredOwner` cmdlet gets the registered owner of a device in Microsoft Entra ID. Specify `DeviceId` parameter gets the registered owner of a device. ## Examples @@ -45,7 +45,7 @@ The `Get-EntraBetaDeviceRegisteredOwner` cmdlet gets the registered owner of a d ```powershell Connect-Entra -Scopes 'Device.Read.All' $DevId = (Get-EntraDevice -Top 1).ObjectId -Get-EntraBetaDeviceRegisteredOwner -ObjectId $DevId +Get-EntraBetaDeviceRegisteredOwner -DeviceId $DevId ``` ```Output @@ -56,13 +56,13 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Maria Sullivan maria@contoso.com M This example shows how to find the registered owner of a device.. -- `-ObjectId` parameter specifies the device's ID +- `-DeviceId` parameter specifies the device's ID ### Example 2: Retrieve the registered owner of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDeviceRegisteredOwner -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc +Get-EntraBetaDeviceRegisteredOwner -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc ``` ```Output @@ -74,13 +74,13 @@ cccccccc-2222-3333-4444-dddddddddddd Parker McLean parker@contoso.com Mem This command gets the registered owner of a device. -- `-ObjectId` parameter specifies the device's ID +- `-DeviceId` parameter specifies the device's ID ### Example 3: Retrieve all the registered owners of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDeviceRegisteredOwner -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -All +Get-EntraBetaDeviceRegisteredOwner -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc -All ``` ```Output @@ -92,13 +92,13 @@ cccccccc-2222-3333-4444-dddddddddddd Parker McLean parker@contoso.com Mem This command retrieves all the registered owners of a device. -- `-ObjectId` parameter specifies the device's ID. +- `-DeviceId` parameter specifies the device's ID. ### Example 4: Retrieve top one registered owner of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDeviceRegisteredOwner -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Top 1 +Get-EntraBetaDeviceRegisteredOwner -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc -Top 1 ``` ```Output @@ -109,7 +109,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Maria Sullivan maria@contoso.com Mem This command retrieves all the registered owners of a device. -- `-ObjectId` parameter specifies the device's ID. +- `-DeviceId` parameter specifies the device's ID. ## Parameters @@ -129,14 +129,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredUser.md index 8fbcbfbe4..72c34dc82 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeviceRegisteredUser.md @@ -27,7 +27,7 @@ Retrieve a list of users that are registered users of the device. ```powershell Get-EntraBetaDeviceRegisteredUser - -ObjectId + -DeviceId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraBetaDeviceRegisteredUser ## Description -The `Get-EntraBetaDeviceRegisteredUser` cmdlet gets a registered user for a Microsoft Entra ID device. Specify `ObjectId` parameter to get a registered user for a Microsoft Entra ID device. +The `Get-EntraBetaDeviceRegisteredUser` cmdlet gets a registered user for a Microsoft Entra ID device. Specify `DeviceId` parameter to get a registered user for a Microsoft Entra ID device. ## Examples @@ -45,7 +45,7 @@ The `Get-EntraBetaDeviceRegisteredUser` cmdlet gets a registered user for a Micr ```powershell Connect-Entra -Scopes 'Device.Read.All' $DevId = (Get-EntraDevice -Top 1).ObjectId -Get-EntraBetaDeviceRegisteredUser -ObjectId $DevId +Get-EntraBetaDeviceRegisteredUser -DeviceId $DevId ``` ```Output @@ -63,7 +63,7 @@ This example demonstrates how to retrieve registered user for a specific Microso ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDeviceRegisteredUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -All +Get-EntraBetaDeviceRegisteredUser -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -All ``` ```Output @@ -77,13 +77,13 @@ ffffffff-4444-5555-6666-gggggggggggg This example demonstrates how to retrieve all registered users for a specified device. -- `-ObjectId` parameter specifies an object ID of a device, which you want to retrieve. +- `-DeviceId` parameter specifies an object ID of a device, which you want to retrieve. ### Example 3: Get top two registered users of a device ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDeviceRegisteredUser -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 2 +Get-EntraBetaDeviceRegisteredUser -DeviceId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 2 ``` ```Output @@ -95,7 +95,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example demonstrates how to retrieve top two registered users for the specified device. -- `-ObjectId` parameter specifies an object ID of a device, which you want to retrieve. +- `-DeviceId` parameter specifies an object ID of a device, which you want to retrieve. ## Parameters @@ -115,14 +115,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies an object ID of a device. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleDefinition.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleDefinition.md index 0554e5f58..c7542f8ba 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleDefinition.md @@ -49,7 +49,7 @@ Get-EntraBetaDirectoryRoleDefinition ```powershell Get-EntraBetaDirectoryRoleDefinition - -Id + -UnifiedRoleDefinitionId [-All] [-Property ] [] @@ -57,7 +57,7 @@ Get-EntraBetaDirectoryRoleDefinition ## Description -The `Get-EntraBetaDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `Id` parameter. Specify the SearchString or Filter parameter to find particular role definition. +The `Get-EntraBetaDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `UnifiedRoleDefinitionId` parameter. Specify the SearchString or Filter parameter to find particular role definition. In delegated scenarios with work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: @@ -90,11 +90,11 @@ Guest Inviter 44ee44ee-ff55-aa66-bb77 This command returns all the role definitions present. -### Example 2: Get a role definition by ID +### Example 2: Get a role definition by UnifiedRoleDefinitionId ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory','EntitlementManagement.Read.All' -Get-EntraBetaDirectoryRoleDefinition -Id '1a327991-10cb-4266-877a-998fb4df78ec' +Get-EntraBetaDirectoryRoleDefinition -UnifiedRoleDefinitionId '1a327991-10cb-4266-877a-998fb4df78ec' ``` ```Output @@ -105,7 +105,7 @@ Restricted Guest User 2af84b1e-32c8-42b7-82bc-daa8240402 This command returns a specified role definition. -- `-Id` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. ### Example 3: Filter role definitions by display name @@ -155,14 +155,14 @@ This command return all the role definitions containing the specified display na ## Parameters -### -Id +### -UnifiedRoleDefinitionId Specifies the ID of the role definition. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleMember.md index e76c70957..f496561ac 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDirectoryRoleMember.md @@ -27,14 +27,14 @@ Gets members of a directory role. ```powershell Get-EntraBetaDirectoryRoleMember - -ObjectId + -DirectoryRoleId [-Property ] [] ``` ## Description -The `Get-EntraBetaDirectoryRoleMember` cmdlet retrieves the members of a directory role in Microsoft Entra ID. To obtain the members of a specific directory role, specify the `ObjectId`. Use the `Get-EntraBetaDirectoryRole` cmdlet to get the `ObjectId` value. +The `Get-EntraBetaDirectoryRoleMember` cmdlet retrieves the members of a directory role in Microsoft Entra ID. To obtain the members of a specific directory role, specify the `DirectoryRoleId`. Use the `Get-EntraBetaDirectoryRole` cmdlet to get the `DirectoryRoleId` value. ## Examples @@ -42,7 +42,7 @@ The `Get-EntraBetaDirectoryRoleMember` cmdlet retrieves the members of a directo ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory' -Get-EntraBetaDirectoryRoleMember -ObjectId '1708c380-4b8a-4977-a46e-6031676f6b41' +Get-EntraBetaDirectoryRoleMember -DirectoryRoleId '1708c380-4b8a-4977-a46e-6031676f6b41' ``` ```Output @@ -53,18 +53,18 @@ bbbbbbbb-7777-8888-9999-cccccccccccc This example retrieves the members of the specified role. -- `-ObjectId` parameter specifies directory role ID. +- `-DirectoryRoleId` parameter specifies directory role ID. ## Parameters -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md index 761661f95..03a5b8652 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md @@ -25,7 +25,7 @@ Gets a member of a group. ```powershell Get-EntraBetaGroupMember - -ObjectId + -GroupId [-Top ] [-All] [-Property ] @@ -34,7 +34,7 @@ Get-EntraBetaGroupMember ## Description -The `Get-EntraBetaGroupMember` cmdlet gets a member of a group in Microsoft Entra ID. Specify the `ObjectId` parameter to get a member of a group. +The `Get-EntraBetaGroupMember` cmdlet gets a member of a group in Microsoft Entra ID. Specify the `GroupId` parameter to get a member of a group. In delegated scenarios, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: `microsoft.directory/groups/members/read`, `microsoft.directory/groups/members/limitedRead`, or `microsoft.directory/groups/hiddenMembers/read` (for hidden members). The following least privileged roles support this operation: @@ -59,7 +59,7 @@ To list members of a hidden group, the `Member.Read.Hidden` permission is also r ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupMember -ObjectId 'eeeeeeee-4444-5555-6666-ffffffffffff' +Get-EntraBetaGroupMember -GroupId 'eeeeeeee-4444-5555-6666-ffffffffffff' ``` ```Output @@ -70,13 +70,13 @@ bbbbbbbb-7777-8888-9999-cccccccccccc This example demonstrates how to retrieve group member by ID. -- `-ObjectId` Specifies the ID of a group. +- `-GroupId` Specifies the ID of a group. ### Example 2: Get two group member ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupMember -ObjectId 'bbbbbbbb-7777-8888-9999-cccccccccccc' -Top 2 +Get-EntraBetaGroupMember -GroupId 'bbbbbbbb-7777-8888-9999-cccccccccccc' -Top 2 ``` ```Output @@ -88,13 +88,13 @@ dddddddd-9999-0000-1111-eeeeeeeeeeee This example demonstrates how to retrieve top two groups from Microsoft Entra ID. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ### Example 3: Get all members within a group by group ID ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraBetaGroupMember -ObjectId 'dddddddd-9999-0000-1111-eeeeeeeeeeee' -All +Get-EntraBetaGroupMember -GroupId 'dddddddd-9999-0000-1111-eeeeeeeeeeee' -All ``` ```Output @@ -109,13 +109,13 @@ cccccccc-8888-9999-0000-dddddddddddd This example retrieves all members within a group by group ID. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ### Example 4: Retrieve and Select Group Member Properties ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -ObjectId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' +Get-EntraGroupMember -GroupId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' ``` ```Output @@ -127,9 +127,9 @@ test2 #microsoft.graph.servicePrincipal test3 #microsoft.graph.servicePrincipal ``` -This example retrieves the members of a specified group by its `ObjectId` and selects only the `DisplayName` and `@odata.type` properties for each member. +This example retrieves the members of a specified group by its `GroupId` and selects only the `DisplayName` and `@odata.type` properties for each member. -- `-ObjectId` specifies the ID of a group. +- `-GroupId` specifies the ID of a group. ## Parameters @@ -149,14 +149,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md index 6ebe9d48b..6ec3ae132 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupOwner.md @@ -34,7 +34,7 @@ Get-EntraBetaGroupOwner ## Description -The `Get-EntraBetaGroupOwner` cmdlet gets an owner of a group in Microsoft Entra ID. Specify `ObjectId` parameter gets an owner of a group. +The `Get-EntraBetaGroupOwner` cmdlet gets an owner of a group in Microsoft Entra ID. Specify `GroupId` parameter gets an owner of a group. In delegated scenarios, the signed-in user must have a supported Microsoft Entra role or a custom role with the `microsoft.directory/groups/owners/read` permission. The following least privileged roles support this operation: diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaScopedRoleMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaScopedRoleMembership.md index 5c04bc0b8..c2b3f6896 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaScopedRoleMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaScopedRoleMembership.md @@ -27,7 +27,7 @@ List Microsoft Entra role assignments with administrative unit scope. ```powershell Get-EntraBetaScopedRoleMembership - -ObjectId + -AdministrativeUnitId [-ScopedRoleMembershipId ] [-Property ] [] @@ -35,7 +35,7 @@ Get-EntraBetaScopedRoleMembership ## Description -The `Get-EntraBetaScopedRoleMembership` cmdlet lists Microsoft Entra role assignments with an administrative unit scope. Use the `ObjectId` parameter to retrieve a specific scoped role membership. +The `Get-EntraBetaScopedRoleMembership` cmdlet lists Microsoft Entra role assignments with an administrative unit scope. Use the `AdministrativeUnitId` parameter to retrieve a specific scoped role membership. ## Examples @@ -45,7 +45,7 @@ The `Get-EntraBetaScopedRoleMembership` cmdlet lists Microsoft Entra role assign Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - ObjectId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.ObjectId ScopedRoleMembershipId = 'dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc' } Get-EntraBetaScopedRoleMembership @params @@ -59,15 +59,15 @@ dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc aaaaaaaa-bbbb-aaaa-bbbb-cccccccccccc bb This example gets scoped role administrator. You cane use the command `Get-EntraBetaAdministrativeUnit` to get administrative unit Id. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. - `-ScopedRoleMembershipId` parameter specifies the scoped role membership Id. -### Example 2: List scoped administrators for administrative unit by ObjectId +### Example 2: List scoped administrators for administrative unit by AdministrativeUnitId ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaScopedRoleMembership -ObjectId $AdministrativeUnit.ObjectId +Get-EntraBetaScopedRoleMembership -AdministrativeUnitId $AdministrativeUnit.ObjectId ``` ```Output @@ -76,20 +76,20 @@ Id Administrative dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc aaaaaaaa-bbbb-aaaa-bbbb-cccccccccccc bbbbbbbb-1111-2222-3333-cccccccccccc ``` -This example list scoped administrators with objectId. +This example list scoped administrators with AdministrativeUnitId. -- `-ObjectId` parameter specifies the ID of an administrative unit. +- `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. ## Parameters -### -ObjectId +### -AdministrativeUnitId Specifies the ID of an administrative unit object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaSubscribedSku.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaSubscribedSku.md index e181b45d0..aafa315ce 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaSubscribedSku.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaSubscribedSku.md @@ -37,7 +37,7 @@ Get-EntraBetaSubscribedSku ```powershell Get-EntraBetaSubscribedSku - -ObjectId + -SubscribedSkuId [-Property ] [] ``` @@ -65,11 +65,11 @@ cccc2222-dd33-4444-55ee-666666ffffff 2222cccc-33dd-eeee-ff44-aaaaaa555555 M365x9 This example demonstrates how to retrieve subscribed SKUs to Microsoft services. -### Example 2: Get subscribed SKUs by ObjectId +### Example 2: Get subscribed SKUs by SubscribedSkuId ```powershell Connect-Entra -Scopes 'Organization.Read.All' -Get-EntraBetaSubscribedSku -ObjectId 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' +Get-EntraBetaSubscribedSku -SubscribedSkuId 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' ``` ```Output @@ -80,7 +80,7 @@ aaaa0000-bb11-2222-33cc-444444dddddd 0000aaaa-11bb-cccc-dd22-eeeeee333333 M365x9 This example demonstrates how to retrieve specified subscribed SKUs to Microsoft services. -- `-ObjectId` parameter specifies the ID of the SKU (Stock Keeping Unit). +- `-SubscribedSkuId` parameter specifies the ID of the SKU (Stock Keeping Unit). ### Example 3: Get a list of users, their assigned licenses, and licensing source @@ -106,7 +106,7 @@ foreach ($User in $SelectedUsers) { try { # Check if the group display name is already in the hashtable if (-not $GroupDisplayNames.ContainsKey($AssignedByGroup)) { - $Group = Get-EntraBetaGroup -ObjectId $AssignedByGroup + $Group = Get-EntraBetaGroup -GroupId $AssignedByGroup $GroupDisplayNames[$AssignedByGroup] = $Group.DisplayName } @@ -142,14 +142,14 @@ This example shows a list of users, their licenses, and the source of the licens ## Parameters -### -ObjectId +### -SubscribedSkuId The object ID of the SKU (Stock Keeping Unit). ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserCreatedObject.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserCreatedObject.md index f0bf4e47e..3e35c7cb2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserCreatedObject.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserCreatedObject.md @@ -26,7 +26,7 @@ Get objects created by the user. ```powershell Get-EntraBetaUserCreatedObject - -ObjectId + -UserId [-All] [-Top ] [] @@ -42,7 +42,7 @@ The `Get-EntraBetaUserCreatedObject` cmdlet gets objects created by a user in Mi ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserCreatedObject -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserCreatedObject -UserId 'SawyerM@contoso.com' ``` ```Output @@ -56,13 +56,13 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example retrieves an object created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ### Example 2: Get all user-created objects ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserCreatedObject -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserCreatedObject -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -76,13 +76,13 @@ eeeeeeee-4444-5555-6666-ffffffffffff This example retrieves all objects created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ### Example 3: Get a top one user-created object ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserCreatedObject -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraBetaUserCreatedObject -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -93,7 +93,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example retrieves top one object created by the specified user. -- `-ObjectId` parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the object Id of a user(as a UserPrincipalName or UserId). ## Parameters @@ -113,14 +113,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID (as a UserPrincipalName or ObjectId) of a user in Microsoft Entra ID. +Specifies the ID (as a UserPrincipalName or UserId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserDirectReport.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserDirectReport.md index ed7fe5ae3..c392a9b9a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserDirectReport.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserDirectReport.md @@ -26,7 +26,7 @@ Get the user's direct reports. ```powershell Get-EntraBetaUserDirectReport - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraBetaUserDirectReport` cmdlet gets the direct reports for a user in ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserDirectReport -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserDirectReport -UserId 'SawyerM@contoso.com' ``` ```Output @@ -54,13 +54,13 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example demonstrates how to retrieve direct reports for a user in Microsoft Entra ID. -- `-ObjectId` Parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` Parameter specifies the ID of a user (UserPrincipalName or UserId). ### Example 2: Get all direct reports ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserDirectReport -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserDirectReport -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -72,13 +72,13 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example demonstrates how to retrieve all direct reports for a user in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the ID of a user (UserPrincipalName or UserId). ### Example 3: Get a top two direct reports ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserDirectReport -ObjectId 'SawyerM@contoso.com' -Top 2 +Get-EntraBetaUserDirectReport -UserId 'SawyerM@contoso.com' -Top 2 ``` ```Output @@ -90,7 +90,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example demonstrates how to retrieve top five direct reports for a user in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a user (UserPrincipalName or ObjectId). +- `-UserId` parameter specifies the ID of a user (UserPrincipalName or UserId). ## Parameters @@ -110,14 +110,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user's UserPrincipalName or ObjectId in Microsoft Entra ID. +Specifies the ID of a user's UserPrincipalName or UserId in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserManager.md index a7b9cfe0d..f03249a8a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserManager.md @@ -27,7 +27,7 @@ Gets the manager of a user. ```powershell Get-EntraBetaUserManager - -ObjectId + -UserId [-Property ] [] ``` @@ -35,7 +35,7 @@ Get-EntraBetaUserManager ## Description The `Get-EntraBetaUserManager` cmdlet gets the manager of a user in Microsoft Entra ID. Specify -`ObjectId` parameter to get the specific manager of user. +`UserId` parameter to get the specific manager of user. ## Examples @@ -43,7 +43,7 @@ The `Get-EntraBetaUserManager` cmdlet gets the manager of a user in Microsoft En ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserManager -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserManager -UserId 'SawyerM@contoso.com' ``` ```Output @@ -62,18 +62,18 @@ displayName : Sawyer Miller This example demonstrates how to retrieve the manager of a specific user. -- `-ObjectId` Parameter specifies ObjectID or User Principal Name of User. +- `-UserId` Parameter specifies UserId or User Principal Name of User. ## Parameters -### -ObjectId +### -UserId -The unique identifier of a user in Microsoft Entra ID (User Principal Name or ObjectId). +The unique identifier of a user in Microsoft Entra ID (User Principal Name or UserId). ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedDevice.md index 0c2f39fa5..5ec1dd0fc 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedDevice.md @@ -26,7 +26,7 @@ Get registered devices owned by a user. ```powershell Get-EntraBetaUserOwnedDevice - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraBetaUserOwnedDevice` cmdlet gets registered devices owned by the s ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserOwnedDevice -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserOwnedDevice -UserId 'SawyerM@contoso.com' ``` ```Output @@ -59,7 +59,7 @@ This command gets the registered devices owned by the specified user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserOwnedDevice -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserOwnedDevice -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -75,7 +75,7 @@ This command gets all the registered devices owned by the specified user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserOwnedDevice -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraBetaUserOwnedDevice -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -104,14 +104,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedObject.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedObject.md index c16dcd706..4fbb8e049 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedObject.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOwnedObject.md @@ -27,7 +27,7 @@ Get objects owned by a user. ```powershell Get-EntraBetaUserOwnedObject - -ObjectId + -UserId [-Top ] [-All] [-Property ] @@ -36,7 +36,7 @@ Get-EntraBetaUserOwnedObject ## Description -The `Get-EntraBetaUserOwnedObject` cmdlet gets objects owned by a user in Microsoft Entra ID. Specify `ObjectId` parameter to get objects owned by user. +The `Get-EntraBetaUserOwnedObject` cmdlet gets objects owned by a user in Microsoft Entra ID. Specify `UserId` parameter to get objects owned by user. ## Examples @@ -44,7 +44,7 @@ The `Get-EntraBetaUserOwnedObject` cmdlet gets objects owned by a user in Micros ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserOwnedObject -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserOwnedObject -UserId 'SawyerM@contoso.com' ``` ```Output @@ -55,7 +55,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example retrieves objects owned by the specified user. -- `-ObjectId` Parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` Parameter specifies the ID of a user as a UserPrincipalName or UserId. ### Example 2: Get objects owned by a user with additional details @@ -87,7 +87,7 @@ This example retrieves objects owned by the specified user with more lookup deta ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserOwnedObject -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserOwnedObject -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -100,13 +100,13 @@ cccccccc-2222-3333-4444-dddddddddddd This example retrieves all the objects owned by the specified user. -- `-ObjectId` parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` parameter specifies the ID of a user as a UserPrincipalName or UserId. ### Example 4: Get top three objects owned by a user ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserOwnedObject -ObjectId 'SawyerM@contoso.com' -Top 3 +Get-EntraBetaUserOwnedObject -UserId 'SawyerM@contoso.com' -Top 3 ``` ```Output @@ -119,7 +119,7 @@ cccccccc-2222-3333-4444-dddddddddddd This example retrieves the top three objects owned by the specified user. -- `-ObjectId` parameter specifies the ID of a user as a UserPrincipalName or ObjectId. +- `-UserId` parameter specifies the ID of a user as a UserPrincipalName or UserId. ## Parameters @@ -139,14 +139,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserRegisteredDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserRegisteredDevice.md index 44ac74d69..220fc0799 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserRegisteredDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserRegisteredDevice.md @@ -27,7 +27,7 @@ Get devices registered by a user. ```powershell Get-EntraBetaUserRegisteredDevice - -ObjectId + -UserId [-Top ] [-All] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraBetaUserRegisteredDevice` cmdlet gets devices registered by a user ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserRegisteredDevice -UserId 'SawyerM@contoso.com' ``` ```Output @@ -60,7 +60,7 @@ This command gets the devices that are registered to the specified user. ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserRegisteredDevice -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -76,7 +76,7 @@ This command gets all the devices that are registered to the specified user. ```Powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserRegisteredDevice -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraBetaUserRegisteredDevice -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -105,14 +105,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId -Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. +Specifies the ID of a user (as a User Principal Name or UserId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md index c562f5917..189ca0108 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md @@ -26,7 +26,7 @@ Creates a password credential for an application. ```powershell New-EntraBetaApplicationPasswordCredential - -ObjectId + -ApplicationId [-CustomKeyIdentifier ] [-StartDate ] [-EndDate ] @@ -44,7 +44,7 @@ The `New-EntraBetaApplicationPasswordCredential` cmdlet creates a password crede ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraBetaApplication -Filter "displayName eq ''" -New-EntraBetaApplicationPasswordCredential -ObjectId $application.Id +New-EntraBetaApplicationPasswordCredential -ApplicationId $application.Id ``` ```Output @@ -55,7 +55,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. ### Example 2: Create a password credential using CustomKeyIdentifier parameter @@ -63,7 +63,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraBetaApplication -Filter "displayName eq ''" $parameters = @{ - ObjectId = $application.Id + ApplicationId = $application.Id CustomKeyIdentifier = '' } New-EntraBetaApplicationPasswordCredential @parameters @@ -78,7 +78,7 @@ CustomKeyIdentifier DisplayName EndDateTime This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-CustomKeyIdentifier` Speicifies unique binary identifier. ### Example 3: Create a password credential using StartDate parameter @@ -87,7 +87,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraBetaApplication -Filter "displayName eq ''" $parameters = @{ - ObjectId = $application.Id + ApplicationId = $application.Id StartDate = (Get-Date).AddYears(0) CustomKeyIdentifier = '' } @@ -103,7 +103,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-StartDate` Speicifies the date and time at which the password becomes valid. ### Example 4: Create a password credential using EndDate parameter @@ -112,7 +112,7 @@ This command creates new password credential for specified application. Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraBetaApplication -Filter "displayName eq ''" $parameters = @{ - ObjectId = $application.Id + ApplicationId = $application.Id EndDate = (Get-Date).AddYears(2) CustomKeyIdentifier = '' } @@ -128,19 +128,19 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ObjectId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of a user. - `-EndDate` Speicifies The date and time at which the password expires. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md index 5d0a12dca..b837a3a8d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md @@ -28,7 +28,7 @@ Sets the logo for an Application ```powershell Set-EntraBetaApplicationLogo - -ObjectId + -ApplicationId -FilePath [] ``` @@ -37,7 +37,7 @@ Set-EntraBetaApplicationLogo ```powershell Set-EntraBetaApplicationLogo - -ObjectId + -ApplicationId [] ``` @@ -45,7 +45,7 @@ Set-EntraBetaApplicationLogo ```powershell Set-EntraBetaApplicationLogo - -ObjectId + -ApplicationId [] ``` @@ -55,19 +55,14 @@ The `Set-EntraBetaApplicationLogo` cmdlet is used to set the logo for an applica ## Examples -### Example 1: Sets the application logo for the application specified by the ObjectID parameter +### Example 1: Sets the application logo for the application specified by the ApplicationId parameter ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -$application = Get-EntraBetaApplication -Filter "DisplayName eq 'Demo Application'" -$params = @{ - ObjectId = $application.ObjectId - FilePath = 'D:\applogo.jpg' -} -Set-EntraBetaApplicationLogo @params +Set-EntraBetaApplicationLogo -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -FilePath 'D:\applogo.jpg' ``` -This cmdlet sets the application logo for the application specified by the `-ObjectId` parameter to the image specified with the `-FilePath` parameter. +This cmdlet sets the application logo for the application specified by the `-ApplicationId` parameter to the image specified with the `-FilePath` parameter. ## Parameters @@ -87,14 +82,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId -The ObjectID of the Application for which the logo is set. +The ApplicationId of the Application for which the logo is set. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: False Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaIdentityProvider.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaIdentityProvider.md index ce514ef66..9e6ebecd0 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaIdentityProvider.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaIdentityProvider.md @@ -27,7 +27,7 @@ Update the properties of an existing identity provider configured in the directo ```powershell Set-EntraBetaIdentityProvider - -Id + -IdentityProviderBaseId [-Type ] [-Name ] [-ClientId ] @@ -48,7 +48,7 @@ The type of the identity provider can't be modified. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' ClientId = 'NewClientID' } Set-EntraBetaIdentityProvider @params @@ -56,7 +56,7 @@ Set-EntraBetaIdentityProvider @params This example updates the client ID for the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. - `-ClientId` parameter specifies the client identifier for the application, obtained during the application's registration with the identity provider. ### Example 2: Update client secret of an identity provider @@ -64,7 +64,7 @@ This example updates the client ID for the specified identity provider. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' ClientSecret = 'NewClientSecret' } Set-EntraBetadentityProvider @params @@ -72,7 +72,7 @@ Set-EntraBetadentityProvider @params This example updates the client secret for the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. - `-ClientSecret` parameter specifies the client secret for the application, obtained during registration with the identity provider. ### Example 3: Update display name of an identity provider @@ -80,7 +80,7 @@ This example updates the client secret for the specified identity provider. ```powershell Connect-Entra -Scopes 'IdentityProvider.ReadWrite.All' $params = @{ - Id = 'Google-OAuth' + IdentityProviderBaseId = 'Google-OAuth' Name = 'NewGoogleName' } Set-EntraBetaIdentityProvider @params @@ -88,7 +88,7 @@ Set-EntraBetaIdentityProvider @params This example updates the display name for the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. - `-Name` parameter specifies the display name of the identity provider. ## Parameters @@ -125,14 +125,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -IdentityProviderBaseId The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md index 976040d1d..7fcd4cd5a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDirectoryRoleDefinition.md @@ -49,7 +49,7 @@ Get-EntraDirectoryRoleDefinition ```powershell Get-EntraDirectoryRoleDefinition - -DirectoryRoleId + -UnifiedRoleDefinitionId [-All] [-Property ] [] @@ -57,7 +57,7 @@ Get-EntraDirectoryRoleDefinition ## Description -The `Get-EntraDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `DirectoryRoleId` parameter. Specify the `SearchString` or `Filter` parameter to find particular role definition. +The `Get-EntraDirectoryRoleDefinition` cmdlet gets information about role definitions in Microsoft Entra ID. To get a role definition, specify the `UnifiedRoleDefinitionId` parameter. Specify the `SearchString` or `Filter` parameter to find particular role definition. In delegated scenarios with work or school accounts, the signed-in user must have a supported Microsoft Entra role or a custom role with one of the following permissions: @@ -89,11 +89,11 @@ Restricted Guest User 2af84b1e-32c8-42b7-82bc-daa8240402 This command returns all the role definitions present. -### Example 2: Get a role definition by DirectoryRoleId +### Example 2: Get a role definition by UnifiedRoleDefinitionId ```powershell Connect-Entra -Scopes 'RoleManagement.Read.Directory','EntitlementManagement.Read.All' -Get-EntraDirectoryRoleDefinition -DirectoryRoleId '1a327991-10cb-4266-877a-998fb4df78ec' +Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId '1a327991-10cb-4266-877a-998fb4df78ec' ``` ```Output @@ -104,7 +104,7 @@ Restricted Guest User 2af84b1e-32c8-42b7-82bc-daa8240402 This command returns a specified role definition. -- `-DirectoryRoleId` parameter specifies the roleDefinition object ID. +- `-UnifiedRoleDefinitionId` parameter specifies the roleDefinition object ID. ### Example 3: Filter role definitions by display name @@ -154,9 +154,9 @@ This command return all the role definitions containing the specified display na ## Parameters -### -DirectoryRoleId +### -UnifiedRoleDefinitionId -Specifies the ID of the role definition. +Specifies the UnifiedRoleDefinitionId of the role definition. ```yaml Type: System.String diff --git a/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 b/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 index aed997974..25bda7a35 100644 --- a/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Get-EntraAdministrativeUnit.Tests.ps1 @@ -33,12 +33,7 @@ Describe "Tests for Get-EntraAdministrativeUnit"{ $result = Get-EntraAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Result should not be empty objectid"{ - $result = Get-EntraAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" - $result | Should -Not -BeNullOrEmpty - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 - } + } It "Should fail when AdministrativeUnitId is empty" { { Get-EntraAdministrativeUnit -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } @@ -74,7 +69,7 @@ Describe "Tests for Get-EntraAdministrativeUnit"{ } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAdministrativeUnit" - $result = Get-EntraAdministrativeUnit -ObjectId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result = Get-EntraAdministrativeUnit -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraAdministrativeUnit" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { diff --git a/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 b/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 index 0542f54fd..f05c33dbf 100644 --- a/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Set-EntraAdministrativeUnit.Tests.ps1 @@ -45,7 +45,7 @@ Describe "Test for Set-EntraAdministrativeUnit" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraAdministrativeUnit -ObjectId "bbbbbbbb-1111-1111-1111-cccccccccccc" -DisplayName "test" -Description "test" -Debug } | Should -Not -Throw + { Set-EntraAdministrativeUnit -AdministrativeUnitId "bbbbbbbb-1111-1111-1111-cccccccccccc" -DisplayName "test" -Description "test" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Add-EntraBetaAdministrativeUnitMember.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaAdministrativeUnitMember.Tests.ps1 index d199bbec1..4d760cb35 100644 --- a/test/module/EntraBeta/Add-EntraBetaAdministrativeUnitMember.Tests.ps1 +++ b/test/module/EntraBeta/Add-EntraBetaAdministrativeUnitMember.Tests.ps1 @@ -14,33 +14,39 @@ BeforeAll { Describe "Add-EntraBetaAdministrativeUnitMember" { Context "Test for Add-EntraBetaAdministrativeUnitMember" { It "Should return empty object" { - $result = Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" + $result = Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgBetaAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraBetaAdministrativeUnitMember -ObjectId -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should return empty object with alias" { + $result = Add-EntraBetaAdministrativeUnitMember -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when AdministrativeUnitId is empty" { + { Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraBetaAdministrativeUnitMember -ObjectId "" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff"} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff"} | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'*" + { Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId ""} | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId ""} | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { Mock -CommandName New-MgBetaAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" + $result = Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" $params = Get-Parameters -data $result $params.AdministrativeUnitId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaAdministrativeUnitMember" - Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" + Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaAdministrativeUnitMember" @@ -56,7 +62,7 @@ Describe "Add-EntraBetaAdministrativeUnitMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraBetaAdministrativeUnitMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" -Debug } | Should -Not -Throw + { Add-EntraBetaAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "eeeeeeee-4444-5555-6666-ffffffffffff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Add-EntraBetaScopedRoleMembership.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaScopedRoleMembership.Tests.ps1 index 0e7440fe6..f02604332 100644 --- a/test/module/EntraBeta/Add-EntraBetaScopedRoleMembership.Tests.ps1 +++ b/test/module/EntraBeta/Add-EntraBetaScopedRoleMembership.Tests.ps1 @@ -31,6 +31,17 @@ BeforeAll { Describe "Add-EntraBetaScopedRoleMembership" { Context "Test for Add-EntraBetaScopedRoleMembership" { It "Should add a user to the specified role within the specified administrative unit" { + $RoleMember = New-Object -TypeName Microsoft.Open.AzureAD.Model.RoleMemberInfo + $RoleMember.ObjectId = "a23541ee-4fe9-4cf2-b628-102ebaef8f7e" + $result = Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz-5AOA62QHJLgnvAbh9Z0r7uQTWi6U_yTLYoEC66749-U" + $result.RoleId | Should -Be "cccccccc-85c2-4543-b86c-cccccccccccc" + $result.AdministrativeUnitId | Should -Be "dddddddd-7902-4be2-a25b-dddddddddddd" + + Should -Invoke -CommandName New-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should add a user to the specified role within the specified administrative unit with alias" { $RoleMember = New-Object -TypeName Microsoft.Open.AzureAD.Model.RoleMemberInfo $RoleMember.ObjectId = "a23541ee-4fe9-4cf2-b628-102ebaef8f7e" $result = Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember @@ -41,41 +52,41 @@ Describe "Add-EntraBetaScopedRoleMembership" { Should -Invoke -CommandName New-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraBetaScopedRoleMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraBetaScopedRoleMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } - It "Should fail when RoleObjectId is empty" { - { Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId } | Should -Throw "Missing an argument for parameter 'RoleObjectId'*" + It "Should fail when RoleAdministrativeUnitId is empty" { + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId } | Should -Throw "Missing an argument for parameter 'RoleObjectId'*" } It "Should fail when AdministrativeUnitObjectId is empty" { - { Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -AdministrativeUnitObjectId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitObjectId'*" + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -AdministrativeUnitObjectId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitObjectId'*" } It "Should fail when RoleMemberInfo is empty" { - { Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleMemberInfo } | Should -Throw "Missing an argument for parameter 'RoleMemberInfo'*" + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleMemberInfo } | Should -Throw "Missing an argument for parameter 'RoleMemberInfo'*" } It "Should fail when RoleMemberInfo is invalid" { - { Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleMemberInfo "" } | Should -Throw "Cannot process argument transformation on parameter 'RoleMemberInfo'*" + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleMemberInfo "" } | Should -Throw "Cannot process argument transformation on parameter 'RoleMemberInfo'*" } It "Result should contain Alias properties"{ $RoleMember = New-Object -TypeName Microsoft.Open.AzureAD.Model.RoleMemberInfo $RoleMember.ObjectId = "a23541ee-4fe9-4cf2-b628-102ebaef8f7e" - $result = Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember + $result = Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember $result.ObjectId | should -Be "zTVcE8KFQ0W4bI9tvt6kz-5AOA62QHJLgnvAbh9Z0r7uQTWi6U_yTLYoEC66749-U" $result.RoleObjectId | should -Be "cccccccc-85c2-4543-b86c-cccccccccccc" $result.AdministrativeUnitObjectId | should -Be "dddddddd-7902-4be2-a25b-dddddddddddd" } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { - $result = Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" + $result = Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "0e3840ee-40b6-4b72-827b-c06e1f59d2be" } It "Should contain AdministrativeUnitId1 in parameters when passed AdministrativeUnitObjectId to it" { - $result = Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -AdministrativeUnitObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" + $result = Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -AdministrativeUnitObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId1 | Should -Be "0e3840ee-40b6-4b72-827b-c06e1f59d2be" } @@ -83,7 +94,7 @@ Describe "Add-EntraBetaScopedRoleMembership" { $RoleMember = New-Object -TypeName Microsoft.Open.AzureAD.Model.RoleMemberInfo $RoleMember.ObjectId = "a23541ee-4fe9-4cf2-b628-102ebaef8f7e" - $result = Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember + $result = Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember $params = Get-Parameters -data $result.Parameters $params.RoleId | Should -Be "135c35cd-85c2-4543-b86c-8f6dbedea4cf" } @@ -93,7 +104,7 @@ Describe "Add-EntraBetaScopedRoleMembership" { $RoleMember = New-Object -TypeName Microsoft.Open.AzureAD.Model.RoleMemberInfo $RoleMember.ObjectId = "a23541ee-4fe9-4cf2-b628-102ebaef8f7e" - Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember + Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -RoleMemberInfo $RoleMember $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaScopedRoleMembership" @@ -109,7 +120,7 @@ Describe "Add-EntraBetaScopedRoleMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraBetaScopedRoleMembership -ObjectId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -Debug } | Should -Not -Throw + { Add-EntraBetaScopedRoleMembership -AdministrativeUnitId "0e3840ee-40b6-4b72-827b-c06e1f59d2be" -RoleObjectId "135c35cd-85c2-4543-b86c-8f6dbedea4cf" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaApplicationLogo.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaApplicationLogo.Tests.ps1 index 2c648a7b8..9f6e42da9 100644 --- a/test/module/EntraBeta/Get-EntraBetaApplicationLogo.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaApplicationLogo.Tests.ps1 @@ -23,19 +23,19 @@ BeforeAll { Describe "Get-EntraBetaApplicationLogo" { It "Should return empty" { - $result = Get-EntraBetaApplicationLogo -ObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" + $result = Get-EntraBetaApplicationLogo -ApplicationId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaApplicationLogo -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Get-EntraBetaApplicationLogo -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Get-EntraBetaApplicationLogo -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Get-EntraBetaApplicationLogo -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationLogo" - $result = Get-EntraBetaApplicationLogo -ObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" + $result = Get-EntraBetaApplicationLogo -ApplicationId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationLogo" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -50,7 +50,7 @@ Describe "Get-EntraBetaApplicationLogo" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaApplicationLogo -ObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" -Debug } | Should -Not -Throw + { Get-EntraBetaApplicationLogo -ApplicationId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -FilePath "D:\image.jpg" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaGroupOwner.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaGroupOwner.Tests.ps1 index 7527319c6..d73471c9e 100644 --- a/test/module/EntraBeta/Get-EntraBetaGroupOwner.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaGroupOwner.Tests.ps1 @@ -35,6 +35,15 @@ BeforeAll { Describe "Get-EntraBetaGroupOwner" { Context "Test for Get-EntraBetaGroupOwner" { It "Get a group owner by Id" { + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + $result.DeletedDateTime | should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Get a group owner by alias" { $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' @@ -43,16 +52,16 @@ Describe "Get-EntraBetaGroupOwner" { Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaGroupOwner -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraBetaGroupOwner -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaGroupOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraBetaGroupOwner -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Gets all group owners" { - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 @@ -63,27 +72,27 @@ Describe "Get-EntraBetaGroupOwner" { } It "Gets two group owners" { - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 2 + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 2 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when top is empty" { - { Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY} | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY} | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain ObjectId" { - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } - It "Should contain GroupId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain GroupId in parameters when passed GroupId to it" { + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $groupId= $params | ConvertTo-json | ConvertFrom-Json $groupId.Uri -match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" | Should -BeTrue @@ -92,7 +101,8 @@ Describe "Get-EntraBetaGroupOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroupOwner" - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroupOwner" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -101,7 +111,7 @@ Describe "Get-EntraBetaGroupOwner" { } } It "Property parameter should work" { - $result = Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' @@ -109,7 +119,7 @@ Describe "Get-EntraBetaGroupOwner" { } It "Should fail when Property is empty" { - { Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" + { Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" } It "Should execute successfully without throwing an error " { @@ -119,7 +129,7 @@ Describe "Get-EntraBetaGroupOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaGroupOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaGroupOwner -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaScopedRoleMembership.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaScopedRoleMembership.Tests.ps1 index 0b96535cf..057d9df07 100644 --- a/test/module/EntraBeta/Get-EntraBetaScopedRoleMembership.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaScopedRoleMembership.Tests.ps1 @@ -31,6 +31,15 @@ BeforeAll { Describe "Get-EntraBetaScopedRoleMembership" { Context "Test for Get-EntraBetaScopedRoleMembership" { It "Should return specific scoped role membership" { + $result = Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result.RoleId | Should -Be "cccccccc-85c2-4543-b86c-cccccccccccc" + $result.AdministrativeUnitId | Should -Be "dddddddd-7902-4be2-a25b-dddddddddddd" + + Should -Invoke -CommandName Get-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific scoped role membership with alias" { $result = Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" @@ -39,38 +48,38 @@ Describe "Get-EntraBetaScopedRoleMembership" { Should -Invoke -CommandName Get-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaScopedRoleMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty" { + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaScopedRoleMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when AdministrativeUnitId is invalid" { + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId' because it is an empty string." } It "Should fail when ScopedRoleMembershipId is empty" { - { Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId } | Should -Throw "Missing an argument for parameter 'ScopedRoleMembershipId'*" } It "Should fail when ScopedRoleMembershipId is invalid" { - { Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter 'ScopedRoleMembershipId' because it is an empty string." + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter 'ScopedRoleMembershipId' because it is an empty string." } - It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + It "Should contain AdministrativeUnitId in parameters when passed AdministrativeUnitId to it" { - $result = Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result = Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "dddddddd-1111-2222-3333-eeeeeeeeeeee" } It "Property parameter should work" { - $result = Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Property RoleId + $result = Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Property RoleId $result | Should -Not -BeNullOrEmpty $result.RoleId | Should -Be 'cccccccc-85c2-4543-b86c-cccccccccccc' Should -Invoke -CommandName Get-MgBetaDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaScopedRoleMembership" - $result = Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" + $result = Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaScopedRoleMembership" @@ -87,7 +96,7 @@ Describe "Get-EntraBetaScopedRoleMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaScopedRoleMembership -ObjectId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Debug } | Should -Not -Throw + { Get-EntraBetaScopedRoleMembership -AdministrativeUnitId "dddddddd-1111-2222-3333-eeeeeeeeeeee" -ScopedRoleMembershipId "zTVcE8KFQ0W4bI9tvt6kz9Es_cQCeeJLolvVzF_5NRdnAVb9H_8aR410OwBwq86hU" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 index 1decca415..898e29c6f 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 @@ -88,8 +88,14 @@ BeforeAll { Describe "Get-EntraBetaUserManager" { Context "Test for Get-EntraBetaUserManager" { It "Should return specific user manager" { - $result = Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" - $result | Should -Not -BeNullOrEmpty + $result = Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + + $result | Should -Not -BeNullOrEmpty + $result.ageGroup | Should -BeNullOrEmpty + $result.onPremisesLastSyncDateTime | Should -BeNullOrEmpty + $result.creationType | Should -BeNullOrEmpty + $result.imAddresses | Should -Be @("miriamg@contoso.com") + $result.preferredLanguage | Should -BeNullOrEmpty $result.mail | Should -Be "MiriamG@contoso.com" $result.securityIdentifier | Should -Be "S-1-12-1-649798363-1255893902-1277583799-1163042182" $result.identities | Should -HaveCount 1 @@ -101,7 +107,7 @@ Describe "Get-EntraBetaUserManager" { } It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserManager -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraBetaUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should fail when invalid parameter is passed" { @@ -109,12 +115,12 @@ Describe "Get-EntraBetaUserManager" { } It "Result should Contain ObjectId" { - $result = Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.Id | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -122,14 +128,14 @@ Describe "Get-EntraBetaUserManager" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserManager" - $result = Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.Headers."User-Agent" | Should -Be $userAgentHeaderValue } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserManager" - $result = Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserManager" Should -Invoke -CommandName Get-MgBetaUserManager -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -144,7 +150,7 @@ Describe "Get-EntraBetaUserManager" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 index 388aeb1d7..9592314f8 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 @@ -38,7 +38,7 @@ BeforeAll { Describe "Get-EntraBetaUserOwnedDevice" { Context "Test for Get-EntraBetaUserOwnedDevice" { It "Should return specific user registered device" { - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" @@ -47,22 +47,22 @@ Describe "Get-EntraBetaUserOwnedDevice" { Should -Invoke -CommandName Get-MgBetaUserOwnedDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserOwnedDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraBetaUserOwnedDevice -UserId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" } It "Should fail when ObjectId is invalid" { - { Get-EntraBetaUserOwnedDevice -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraBetaUserOwnedDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should return All user registered devices" { - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaUserOwnedDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All is invalid" { - { Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 user registered device" { - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" @@ -71,30 +71,30 @@ Describe "Get-EntraBetaUserOwnedDevice" { Should -Invoke -CommandName Get-MgBetaUserOwnedDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top is empty" { - { Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Property parameter should work" { - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb' Should -Invoke -CommandName Get-MgBetaUserOwnedDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserOwnedDevice" - $result = Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserOwnedDevice" @@ -110,7 +110,7 @@ Describe "Get-EntraBetaUserOwnedDevice" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUserOwnedDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 index c9b037d32..4e6a5be26 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 @@ -38,7 +38,7 @@ BeforeAll { Describe "Get-EntraBetaUserRegisteredDevice" { Context "Test for Get-EntraBetaUserRegisteredDevice" { It "Should return specific user registered device" { - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" @@ -47,22 +47,22 @@ Describe "Get-EntraBetaUserRegisteredDevice" { Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when ObjectlId is empty" { - { Get-EntraBetaUserRegisteredDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + { Get-EntraBetaUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" } It "Should fail when ObjectlId is invalid" { - { Get-EntraBetaUserRegisteredDevice -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraBetaUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should return All user registered devices" { - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All is invalid" { - { Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 user registered device" { - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" $result.AdditionalProperties.deviceId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" @@ -71,30 +71,30 @@ Describe "Get-EntraBetaUserRegisteredDevice" { Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top is empty" { - { Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Property parameter should work" { - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb' Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserRegisteredDevice" - $result = Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserRegisteredDevice" @@ -110,7 +110,7 @@ Describe "Get-EntraBetaUserRegisteredDevice" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUserRegisteredDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaApplicationLogo.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaApplicationLogo.Tests.ps1 index a582d707e..3df9232f7 100644 --- a/test/module/EntraBeta/Set-EntraBetaApplicationLogo.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaApplicationLogo.Tests.ps1 @@ -14,22 +14,22 @@ BeforeAll { Describe "Set-EntraBetaApplicationLogo"{ Context "Test for Set-EntraBetaApplicationLogo" { It "Should return empty object"{ - $result = Set-EntraBetaApplicationLogo -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" + $result = Set-EntraBetaApplicationLogo -ApplicationId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraBetaApplicationLogo -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Set-EntraBetaApplicationLogo -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Set-EntraBetaApplicationLogo -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Set-EntraBetaApplicationLogo -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when filepath invalid"{ - { Set-EntraBetaApplicationLogo -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "sdd" } | Should -Throw "FilePath is invalid" + { Set-EntraBetaApplicationLogo -ApplicationId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "sdd" } | Should -Throw "FilePath is invalid" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaApplicationLogo" - $result = Set-EntraBetaApplicationLogo -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" + $result = Set-EntraBetaApplicationLogo -ApplicationId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaApplicationLogo" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -44,7 +44,7 @@ Describe "Set-EntraBetaApplicationLogo"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaApplicationLogo -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" -Debug } | Should -Not -Throw + { Set-EntraBetaApplicationLogo -ApplicationId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -FilePath "https://th.bing.com/th?q=Perennial+Garden+Ideas&w=138&h=138&c=7&o=5&dpr=1.3&pid=1.7&mkt=en-IN&cc=IN&setlang=en&adlt=moderate" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From bbad2294989a37fa25f573b49fd8898f5361908a Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Wed, 25 Sep 2024 23:51:13 +0530 Subject: [PATCH 32/64] parameter updates (#1068) * parameter updates * updates * updates * updates * updates * updated test cases --- .../Add-EntraBetaDirectoryRoleMember.md | 10 +++--- .../Get-EntraBetaIdentityProvider.md | 10 +++--- .../Get-EntraBetaUserExtension.md | 10 +++--- .../Get-EntraBetaUserLicenseDetail.md | 8 ++--- .../Remove-EntraBetaDirectoryRoleMember.md | 10 +++--- .../Add-EntraDirectoryRoleMember.md | 10 +++--- .../Get-EntraIdentityProvider.md | 10 +++--- .../Get-EntraUserExtension.md | 10 +++--- .../Get-EntraUserLicenseDetail.md | 8 ++--- .../Remove-EntraDirectoryRoleMember.md | 15 ++++----- .../Add-EntraDirectoryRoleMember.Tests.ps1 | 26 ++++++++++------ .../Entra/Get-EntraIdentityProvider.Tests.ps1 | 29 +++++++++++------ .../Get-EntraUserLicenseDetail.Tests.ps1 | 31 +++++++++++++------ .../Remove-EntraDirectoryRoleMember.Tests.ps1 | 26 ++++++++++------ .../Get-EntraBetaUserLicenseDetail.Tests.ps1 | 28 ++++++++++++----- 15 files changed, 143 insertions(+), 98 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDirectoryRoleMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDirectoryRoleMember.md index fdca40138..abb8fda01 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDirectoryRoleMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDirectoryRoleMember.md @@ -26,7 +26,7 @@ Adds a member to a directory role. ```powershell Add-EntraBetaDirectoryRoleMember - -ObjectId + -DirectoryRoleId -RefObjectId [] ``` @@ -42,7 +42,7 @@ The `Add-EntraBetaDirectoryRoleMember` cmdlet adds a member to a Microsoft Entra ```powershell Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' $params = @{ - ObjectId = '019ea7a2-1613-47c9-81cb-20ba35b1ae48' + DirectoryRoleId = '019ea7a2-1613-47c9-81cb-20ba35b1ae48' RefObjectId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Add-EntraBetaDirectoryRoleMember @params @@ -50,19 +50,19 @@ Add-EntraBetaDirectoryRoleMember @params This example adds a member to a directory role. -- `ObjectId` parameter specifies the ID of the directory role to which the member will be added. Use the `Get-EntraBetaDirectoryRole` command to retrieve the details of the directory role. +- `DirectoryRoleId` parameter specifies the ID of the directory role to which the member will be added. Use the `Get-EntraBetaDirectoryRole` command to retrieve the details of the directory role. - `RefObjectId` parameter specifies the ID of Microsoft Entra ID object to assign as owner/manager/member. ## Parameters -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaIdentityProvider.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaIdentityProvider.md index bcd762cae..291932b8f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaIdentityProvider.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaIdentityProvider.md @@ -36,7 +36,7 @@ Get-EntraBetaIdentityProvider ```powershell Get-EntraBetaIdentityProvider - -Id + -IdentityProviderBaseId [-Property ] [] ``` @@ -76,7 +76,7 @@ This example retrieves the list of all configured identity providers and their p ```powershell Connect-Entra -Scopes 'IdentityProvider.Read.All' -Get-EntraBetaIdentityProvider -Id 'Google-OAUTH' +Get-EntraBetaIdentityProvider -IdentityProviderBaseId 'Google-OAUTH' ``` ```Output @@ -87,18 +87,18 @@ Google-OAUTH GoogleName This example retrieves the properties for the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. ## Parameters -### -Id +### -IdentityProviderBaseId The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md index cb3b8e3d8..c9a0b0cbb 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md @@ -26,7 +26,7 @@ Gets a user extension. ```powershell Get-EntraBetaUserExtension - -ObjectId + -UserId [-Property ] [] ``` @@ -42,7 +42,7 @@ The `Get-EntraBetaUserExtension` cmdlet gets a user extension in Microsoft Entra ```powershell Connect-Entra -Scopes 'User.Read' $UserId = (Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com').ObjectId -Get-EntraBetaUserExtension -ObjectId $UserId +Get-EntraBetaUserExtension -UserId $UserId ``` ```Output @@ -53,18 +53,18 @@ com.contoso.roamingSettings This example shows how to retrieve the extension attributes for a specified user. You can use the command `Get-EntraBetaUser` to get user object Id. -- `-ObjectId` parameter specifies the user object Id. +- `-UserId` parameter specifies the user object Id. ## Parameters -### -ObjectId +### -UserId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserLicenseDetail.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserLicenseDetail.md index ad2e47f90..41e037b00 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserLicenseDetail.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserLicenseDetail.md @@ -26,7 +26,7 @@ Retrieves license details for a user. ```powershell Get-EntraBetaUserLicenseDetail - -ObjectId + -UserId [-Property ] [] ``` @@ -41,7 +41,7 @@ This cmdlet retrieves license details for a user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraBetaUserLicenseDetail -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserLicenseDetail -UserId 'SawyerM@contoso.com' ``` ```Output @@ -56,14 +56,14 @@ This example demonstrates how to retrieve license details for a user from Micros ## Parameters -### -ObjectId +### -UserId The object ID of the user for which the license details are retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleMember.md index db4ef9f9d..6140527e0 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleMember.md @@ -26,7 +26,7 @@ Removes a member of a directory role. ```powershell Remove-EntraBetaDirectoryRoleMember - -ObjectId + -DirectoryRoleId -MemberId [] ``` @@ -42,7 +42,7 @@ The `Remove-EntraBetaDirectoryRoleMember` cmdlet removes a member from a directo ```powershell Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + DirectoryRoleId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' MemberId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Remove-EntraBetaDirectoryRoleMember @params @@ -50,7 +50,7 @@ Remove-EntraBetaDirectoryRoleMember @params This example removes the specified member from the specified role. -- `-ObjectId` parameter specifies the object ID of the directory role. +- `-DirectoryRoleId` parameter specifies the object ID of the directory role. - `-MemberId` parameter specifies the object ID of the role member to removed. ## Parameters @@ -71,14 +71,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DirectoryRoleId Specifies the object ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDirectoryRoleMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDirectoryRoleMember.md index aea54004f..6e540769a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDirectoryRoleMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDirectoryRoleMember.md @@ -26,7 +26,7 @@ Adds a member to a directory role. ```powershell Add-EntraDirectoryRoleMember - -ObjectId + -DirectoryRoleId -RefObjectId [] ``` @@ -42,7 +42,7 @@ The `Add-EntraDirectoryRoleMember` cmdlet adds a member to a Microsoft Entra ID ```powershell Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' $params = @{ - ObjectId = '019ea7a2-1613-47c9-81cb-20ba35b1ae48' + DirectoryRoleId = '019ea7a2-1613-47c9-81cb-20ba35b1ae48' RefObjectId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Add-EntraDirectoryRoleMember @params @@ -50,19 +50,19 @@ Add-EntraDirectoryRoleMember @params This example adds a member to a directory role. -- `ObjectId` parameter specifies the ID of the directory role to which the member is added. Use the Get-EntraDirectoryRole command to retrieve the details of the directory role. +- `DirectoryRoleId` parameter specifies the ID of the directory role to which the member is added. Use the Get-EntraDirectoryRole command to retrieve the details of the directory role. - `RefObjectId` parameter specifies the ID of Microsoft Entra ID object to assign as owner/manager/member. ## Parameters -### -ObjectId +### -DirectoryRoleId Specifies the ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraIdentityProvider.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraIdentityProvider.md index eb83109bb..358563649 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraIdentityProvider.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraIdentityProvider.md @@ -36,7 +36,7 @@ Get-EntraIdentityProvider ```powershell Get-EntraIdentityProvider - -Id + -IdentityProviderBaseId [-Property ] [] ``` @@ -76,7 +76,7 @@ This example retrieves the list of all configured identity providers and their p ```powershell Connect-Entra -Scopes 'IdentityProvider.Read.All' -Get-EntraIdentityProvider -Id Google-OAUTH +Get-EntraIdentityProvider -IdentityProviderBaseId Google-OAUTH ``` ```Output @@ -87,18 +87,18 @@ Google-OAUTH GoogleName This example retrieves the properties for the specified identity provider. -- `-Id` parameter specifies the unique identifier of the identity provider. +- `-IdentityProviderBaseId` parameter specifies the unique identifier of the identity provider. ## Parameters -### -Id +### -IdentityProviderBaseId The unique identifier for an identity provider. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md index 6a9d5ebba..7456df898 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md @@ -26,7 +26,7 @@ Gets a user extension. ```powershell Get-EntraUserExtension - -ObjectId + -UserId [-Property ] [] ``` @@ -42,7 +42,7 @@ The Get-EntraUserExtension cmdlet gets a user extension in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'User.Read' $UserId = (Get-EntraUser -ObjectId 'SawyerM@contoso.com').ObjectId -Get-EntraUserExtension -ObjectId $UserId +Get-EntraUserExtension -UserId $UserId ``` ```Output @@ -53,18 +53,18 @@ com.contoso.roamingSettings This example shows how to retrieve the extension attributes for a specified user. You can use the command `Get-EntraUser` to get user object Id. -- `-ObjectId` parameter specifies the user object Id. +- `-UserId` parameter specifies the user object Id. ## Parameters -### -ObjectId +### -UserId Specifies the ID of an object. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserLicenseDetail.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserLicenseDetail.md index cd8b1c77d..6dbad4066 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserLicenseDetail.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserLicenseDetail.md @@ -26,7 +26,7 @@ Retrieves license details for a user. ```powershell Get-EntraUserLicenseDetail - -ObjectId + -UserId [-Property ] [] ``` @@ -41,7 +41,7 @@ This cmdlet retrieves license details for a user. ```powershell Connect-Entra -Scopes 'User.Read.All' -Get-EntraUserLicenseDetail -ObjectId 'SawyerM@contoso.com' +Get-EntraUserLicenseDetail -UserId 'SawyerM@contoso.com' ``` ```Output @@ -56,14 +56,14 @@ This example demonstrates how to retrieve license details for a user from Micros ## Parameters -### -ObjectId +### -UserId The object ID of the user for which the license details are retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleMember.md index e2ef513a2..7d0f7f9ff 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleMember.md @@ -26,8 +26,8 @@ Removes a member of a directory role. ```powershell Remove-EntraDirectoryRoleMember - -ObjectId - -MemberId + -DirectoryRoleId + -MemberId [] ``` @@ -42,7 +42,7 @@ The `Remove-EntraDirectoryRoleMember` cmdlet removes a member from a directory r ```powershell Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' $params = @{ - ObjectId = 'aaaabbbb-0000-cccc-1111-dddd2222eeee' + DirectoryRoleId = 'aaaabbbb-0000-cccc-1111-dddd2222eeee' MemberId = '11bb11bb-cc22-dd33-ee44-55ff55ff55ff' } @@ -51,8 +51,9 @@ Remove-EntraDirectoryRoleMember @params This example removes the specified member from the specified role. -- `-ObjectId` parameter specifies the object ID of the directory role. -- `-MemberId` parameter specifies the object ID of the role member to removed. +- `-DirectoryRoleId` - specifies the unique identifier (ObjectId) of the directory role from which the member will be removed. + +- `-MemberId` - specifies the unique identifier (MemberId) of the member (user, group, or service principal) that is to be removed from the specified directory role. ## Parameters @@ -72,14 +73,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DirectoryRoleId Specifies the object ID of a directory role in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Add-EntraDirectoryRoleMember.Tests.ps1 b/test/module/Entra/Add-EntraDirectoryRoleMember.Tests.ps1 index 1ed7cd0e7..cc0dde31d 100644 --- a/test/module/Entra/Add-EntraDirectoryRoleMember.Tests.ps1 +++ b/test/module/Entra/Add-EntraDirectoryRoleMember.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Add-EntraDirectoryRoleMember" { Context "Test for Add-EntraDirectoryRoleMember" { It "Should return empty object" { + $result = Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgDirectoryRoleMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias" { $result = Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgDirectoryRoleMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraDirectoryRoleMember -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should fail when DirectoryRoleId is empty" { + { Add-EntraDirectoryRoleMember -DirectoryRoleId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraDirectoryRoleMember -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DirectoryRoleId is invalid" { + { Add-EntraDirectoryRoleMember -DirectoryRoleId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { Mock -CommandName New-MgDirectoryRoleMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryRoleId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain OdataId in parameters when passed RefObjectId to it" { Mock -CommandName New-MgDirectoryRoleMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $value="https://graph.microsoft.com/v1.0/directoryObjects/" $params.OdataId | Should -Be $value"bbbbbbbb-1111-2222-3333-cccccccccccc" @@ -48,7 +54,7 @@ Describe "Add-EntraDirectoryRoleMember" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDirectoryRoleMember" - Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDirectoryRoleMember" @@ -64,7 +70,7 @@ Describe "Add-EntraDirectoryRoleMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Add-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraIdentityProvider.Tests.ps1 b/test/module/Entra/Get-EntraIdentityProvider.Tests.ps1 index b6f3c3b0e..b583838b5 100644 --- a/test/module/Entra/Get-EntraIdentityProvider.Tests.ps1 +++ b/test/module/Entra/Get-EntraIdentityProvider.Tests.ps1 @@ -13,7 +13,7 @@ BeforeAll { "Id" = "Google-OAUTH" "DisplayName" = "Mock-App" "AdditionalProperties" = @{ - "@odata.context" = "https://graph.microsoft.com/v1.0/$metadata#identity/identityProviders/$entity" + "@odata.context" = 'https://graph.microsoft.com/v1.0/$metadata#identity/identityProviders/$entity' "@odata.type" = "#microsoft.graph.socialIdentityProvider" "clientId" = "Google123" "clientSecret" = "******" @@ -30,7 +30,16 @@ BeforeAll { Describe "Get-EntraIdentityProvider" { Context "Test for Get-EntraIdentityProvider" { It "Should return specific identity provider" { - $result = Get-EntraIdentityProvider -Id "Google-OAUTH" + $result = Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "Google-OAUTH" + $result.DisplayName | Should -Be "Mock-App" + $result.identityProviderType | Should -Be "Google" + + Should -Invoke -CommandName Get-MgIdentityProvider -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific identity provider with alias" { + $result = Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "Google-OAUTH" $result.DisplayName | Should -Be "Mock-App" @@ -39,37 +48,37 @@ Context "Test for Get-EntraIdentityProvider" { Should -Invoke -CommandName Get-MgIdentityProvider -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Id is empty" { - { Get-EntraIdentityProvider -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + { Get-EntraIdentityProvider -IdentityProviderBaseId } | Should -Throw "Missing an argument for parameter 'IdentityProviderBaseId'*" } It "Should fail when Id is invalid" { - { Get-EntraIdentityProvider -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + { Get-EntraIdentityProvider -IdentityProviderBaseId "" } | Should -Throw "Cannot bind argument to parameter 'IdentityProviderBaseId' because it is an empty string." } It "Result should Contain Alias properties" { - $result = Get-EntraIdentityProvider -Id "Google-OAUTH" + $result = Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $result.ObjectId | should -Be "Google-OAUTH" $result.Name | should -Be "Mock-App" $result.Type | should -Be "Google" } It "Should contain IdentityProviderBaseId in parameters when passed Id to it" { - $result = Get-EntraIdentityProvider -Id "Google-OAUTH" + $result = Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $params = Get-Parameters -data $result.Parameters $params.IdentityProviderBaseId | Should -Be "Google-OAUTH" } It "Property parameter should work" { - $result = Get-EntraIdentityProvider -Id "Google-OAUTH" -Property DisplayName + $result = Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgIdentityProvider -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraIdentityProvider -Id "Google-OAUTH" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraIdentityProvider" - Get-EntraIdentityProvider -Id "Google-OAUTH" + Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraIdentityProvider" @@ -85,7 +94,7 @@ Context "Test for Get-EntraIdentityProvider" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraIdentityProvider -Id "Google-OAUTH" -Debug } | Should -Not -Throw + { Get-EntraIdentityProvider -IdentityProviderBaseId "Google-OAUTH" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserLicenseDetail.Tests.ps1 b/test/module/Entra/Get-EntraUserLicenseDetail.Tests.ps1 index 9684f9994..1841ca5ef 100644 --- a/test/module/Entra/Get-EntraUserLicenseDetail.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserLicenseDetail.Tests.ps1 @@ -28,6 +28,17 @@ BeforeAll { Describe "Get-EntraUserLicenseDetail" { Context "Test for Get-EntraUserLicenseDetail" { It "Should return specific User" { + $result = Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "X8Wu1RItQkSNL8zKldQ5DmAn38eBLPdOtXhbU5K1cd8" + $result.ServicePlans | Should -Be @("COMMON_DEFENDER_PLATFORM_FOR_OFFICE", "Bing_Chat_Enterprise", "MESH_IMMERSIVE_FOR_TEAMS", "PURVIEW_DISCOVERY") + $result.SkuId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.SkuPartNumber | Should -Be "ENTERPRISEPREMIUM" + $result.AdditionalProperties | Should -BeOfType [System.Collections.Hashtable] + + should -Invoke -CommandName Get-MgUserLicenseDetail -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific User with alias" { $result = Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "X8Wu1RItQkSNL8zKldQ5DmAn38eBLPdOtXhbU5K1cd8" @@ -39,33 +50,33 @@ Describe "Get-EntraUserLicenseDetail" { should -Invoke -CommandName Get-MgUserLicenseDetail -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string value" { - { Get-EntraUserLicenseDetail -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Get-EntraUserLicenseDetail -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraUserLicenseDetail -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraUserLicenseDetail -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'X8Wu1RItQkSNL8zKldQ5DmAn38eBLPdOtXhbU5K1cd8' Should -Invoke -CommandName Get-MgUserLicenseDetail -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserLicenseDetail" - $result = Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserLicenseDetail" @@ -82,7 +93,7 @@ Describe "Get-EntraUserLicenseDetail" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraDirectoryRoleMember.Tests.ps1 b/test/module/Entra/Remove-EntraDirectoryRoleMember.Tests.ps1 index e33005f57..0c050dc2b 100644 --- a/test/module/Entra/Remove-EntraDirectoryRoleMember.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDirectoryRoleMember.Tests.ps1 @@ -13,41 +13,47 @@ BeforeAll { Describe "Remove-EntraDirectoryRoleMember" { Context "Test for Remove-EntraDirectoryRoleMember" { It "Should return empty object" { + $result = Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDirectoryRoleMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgDirectoryRoleMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraDirectoryRoleMember -ObjectId -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when DirectoryRoleId is empty" { + { Remove-EntraDirectoryRoleMember -DirectoryRoleId -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'*" } - It "Should fail when ObjectId is invalid" { - { Remove-EntraDirectoryRoleMember -ObjectId "" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DirectoryRoleId is invalid" { + { Remove-EntraDirectoryRoleMember -DirectoryRoleId "" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." } It "Should fail when MemberId is empty" { - { Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" + { Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId } | Should -Throw "Missing an argument for parameter 'MemberId'*" } It "Should fail when MemberId is invalid" { - { Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." + { Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "" } | Should -Throw "Cannot bind argument to parameter 'MemberId' because it is an empty string." } It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { Mock -CommandName Remove-MgDirectoryRoleMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryRoleId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain DirectoryObjectId in parameters when passed RefObjectId to it" { Mock -CommandName Remove-MgDirectoryRoleMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleMember" - Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDirectoryRoleMember" @@ -63,7 +69,7 @@ Describe "Remove-EntraDirectoryRoleMember" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDirectoryRoleMember -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraDirectoryRoleMember -DirectoryRoleId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -MemberId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserLicenseDetail.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserLicenseDetail.Tests.ps1 index e210d8663..0374aca90 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserLicenseDetail.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserLicenseDetail.Tests.ps1 @@ -26,6 +26,18 @@ BeforeAll { Describe "Get-EntraBetaUserLicenseDetail" { Context "Test for Get-EntraBetaUserLicenseDetail" { It "Should return specific User License Detail" { + $result = Get-EntraBetaUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u" + $result.ServicePlans | Should -Be @("COMMON_DEFENDER_PLATFORM_FOR_OFFICE", "Bing_Chat_Enterprise", "MESH_IMMERSIVE_FOR_TEAMS", "PURVIEW_DISCOVERY") + $result.SkuId | Should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" + $result.SkuPartNumber | Should -Be "ENTERPRISEPREMIUM" + $result.AdditionalProperties | Should -BeOfType [System.Collections.Hashtable] + + Should -Invoke -CommandName Get-MgBetaUserLicenseDetail -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific User License Detail alias" { $result = Get-EntraBetaUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty @@ -38,26 +50,26 @@ Describe "Get-EntraBetaUserLicenseDetail" { Should -Invoke -CommandName Get-MgBetaUserLicenseDetail -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty string" { - { Get-EntraBetaUserLicenseDetail -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string" { + { Get-EntraBetaUserLicenseDetail -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserLicenseDetail -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Get-EntraBetaUserLicenseDetail -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should fail when invalid parameter is passed" { { Get-EntraBetaUserLicenseDetail -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraBetaUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserLicenseDetail" - $result = Get-EntraBetaUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserLicenseDetail" Should -Invoke -CommandName Get-MgBetaUserLicenseDetail -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -72,7 +84,7 @@ Describe "Get-EntraBetaUserLicenseDetail" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUserLicenseDetail -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaUserLicenseDetail -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From f729ec9c9f9bbf607adf4833d9998c8ebc370248 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Thu, 26 Sep 2024 11:15:24 +0530 Subject: [PATCH 33/64] updated UT --- module/Entra/customizations/Get-EntraDeletedApplication.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 index 8172f09ef..2b354a2da 100644 --- a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 +++ b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 @@ -109,7 +109,7 @@ 'PublisherDomain','Web','RequiredResourceAccess') foreach ($prop in $propsToConvert) { - $value = $_.$prop | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $value = $_.$prop | ConvertTo-Json -Depth 5 | ConvertFrom-Json $_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force } From 2afbad153f041ca6ffa1be78e9362c9f2236ed0d Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 11:52:11 +0530 Subject: [PATCH 34/64] parameter updates (#1058) * parameter updates * updated EntraDeviceRegisteredOwner doc * updates * updates * updated * updated * updated * fixed UT --------- Co-authored-by: Ashwini Karke Co-authored-by: Snehal Kotwal (Perennial Systems Inc) --- .../Add-EntraBetaDeviceRegisteredOwner.md | 12 ++--- .../Get-EntraBetaDevice.md | 10 ++--- ...et-EntraBetaServicePrincipalOwnedObject.md | 22 +++++----- .../Remove-EntraBetaDeviceRegisteredOwner.md | 8 ++-- .../Add-EntraDeviceRegisteredOwner.md | 12 ++--- .../Microsoft.Graph.Entra/Get-EntraDevice.md | 10 ++--- .../Get-EntraServicePrincipalOwnedObject.md | 22 +++++----- .../Remove-EntraDeviceRegisteredOwner.md | 8 ++-- .../Add-EntraDeviceRegisteredOwner.Tests.ps1 | 28 +++++++----- .../Get-EntraDeletedApplication.Tests.ps1 | 14 +++--- test/module/Entra/Get-EntraDevice.Tests.ps1 | 31 ++++++++++--- ...EntraServicePrincipalOwnedObject.Tests.ps1 | 28 +++++++++--- ...emove-EntraDeviceRegisteredOwner.Tests.ps1 | 28 +++++++----- .../EntraBeta/Get-EntraBetaDevice.Tests.ps1 | 28 +++++++----- ...aBetaServicePrincipalOwnedObject.Tests.ps1 | 44 ++++++++++++------- 15 files changed, 187 insertions(+), 118 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredOwner.md index 50bc6b448..c0081280a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredOwner.md @@ -27,7 +27,7 @@ Adds a registered owner for a device. ```powershell Add-EntraBetaDeviceRegisteredOwner - -ObjectId + -DeviceId -RefObjectId [] ``` @@ -42,10 +42,10 @@ The `Add-EntraBetaDeviceRegisteredOwner` cmdlet adds a registered owner for a Mi ```powershell Connect-Entra -Scopes 'Device.ReadWrite.All' -$User = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +$User = Get-EntraBetaUser -UserId 'SawyerM@contoso.com' $Device = Get-EntraBetaDevice -SearchString '' $params = @{ - ObjectId = $Device.ObjectId + DeviceId = $Device.ObjectId RefObjectId = $User.ObjectId } Add-EntraBetaDeviceRegisteredOwner @params @@ -53,20 +53,20 @@ Add-EntraBetaDeviceRegisteredOwner @params This example shows how to add a registered owner to a device. -`-ObjectId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered owner. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraBetaDevice` to get device Id. +`-DeviceId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered owner. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraBetaDevice` to get device Id. `-RefObjectId` parameter specifies the unique identifier (Object ID) of the user who will be added as a registered owner of the device. The $User.ObjectId variable should contain the Object ID of the user. You can use the command `Get-EntraBetaUser` to get user Id. ## Parameters -### -ObjectId +### -DeviceId Specifies the ID of the device. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDevice.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDevice.md index f25094898..9f4254591 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDevice.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDevice.md @@ -50,7 +50,7 @@ Get-EntraBetaDevice ```powershell Get-EntraBetaDevice - -ObjectId + -DeviceId [-All] [-Property ] [] @@ -58,7 +58,7 @@ Get-EntraBetaDevice ## Description -The `Get-EntraBetaDevice` cmdlet gets a device from Microsoft Entra ID. Specify the `ObjectId` parameter to get a specific device. +The `Get-EntraBetaDevice` cmdlet gets a device from Microsoft Entra ID. Specify the `DeviceId` parameter to get a specific device. ## Examples @@ -66,7 +66,7 @@ The `Get-EntraBetaDevice` cmdlet gets a device from Microsoft Entra ID. Specify ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraBetaDevice -ObjectId 'bbbbbbbb-1111-1111-1111-cccccccccccc' +Get-EntraBetaDevice -DeviceId 'bbbbbbbb-1111-1111-1111-cccccccccccc' ``` ```Output @@ -195,14 +195,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies the ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwnedObject.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwnedObject.md index 36972aba2..c8395664e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwnedObject.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwnedObject.md @@ -26,7 +26,7 @@ Gets an object owned by a service principal. ```powershell Get-EntraBetaServicePrincipalOwnedObject - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -44,7 +44,7 @@ The `Get-EntraBetaServicePrincipalOwnedObject` cmdlet retrieves an object owned ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -55,14 +55,14 @@ bbbbbbbb-1111-2222-3333-cccccccccccc The command retrieves the owned objects of a service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 2: Retrieve the all owned objects of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipalId = (Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''").ObjectId -Get-EntraBetaServicePrincipalOwnedObject -ObjectId $ServicePrincipalId -All +Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipalId -All ``` ```Output @@ -74,14 +74,14 @@ cccccccc-2222-3333-4444-dddddddddddd This example retrieves an object owned by a service principal in Microsoft Entra ID. You can use the command `Get-EntraBetaServicePrincipal` to get service principal Id. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 2: Retrieve all owned objects of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -93,14 +93,14 @@ cccccccc-2222-3333-4444-dddddddddddd The command receives the all owned objects of a service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 3: Retrieve top one owned object of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId -Top 1 +Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId -Top 1 ``` ```Output @@ -111,7 +111,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example retrieves the top one owned object of a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ## Parameters @@ -131,14 +131,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredOwner.md index e13777203..717be523f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredOwner.md @@ -28,7 +28,7 @@ Removes the registered owner of a device. ```powershell Remove-EntraBetaDeviceRegisteredOwner -OwnerId - -ObjectId + -DeviceId [] ``` @@ -44,21 +44,21 @@ The `Remove-EntraBetaDeviceRegisteredOwner` cmdlet removes the registered owner Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraBetaDevice -Top 1 $Owner = Get-EntraBetaDeviceRegisteredOwner -ObjectId $Device.ObjectId -Remove-EntraBetaDeviceRegisteredOwner -ObjectId $Device.ObjectId -OwnerId $Owner.ObjectId +Remove-EntraBetaDeviceRegisteredOwner -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId ``` This examples shows how to remove the owner of a device. ## Parameters -### -ObjectId +### -DeviceId Specifies an object ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredOwner.md index 0a51c37d3..1d97f864d 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredOwner.md @@ -26,7 +26,7 @@ Adds a registered owner for a device. ```powershell Add-EntraDeviceRegisteredOwner - -ObjectId + -DeviceId -RefObjectId [] ``` @@ -41,10 +41,10 @@ The `Add-EntraDeviceRegisteredOwner` cmdlet adds a registered owner for a Micros ```powershell Connect-Entra -Scopes 'Device.ReadWrite.All' -$User = Get-EntraUser -ObjectId 'SawyerM@contoso.com' +$User = Get-EntraUser -UserId 'SawyerM@contoso.com' $Device = Get-EntraDevice -SearchString '' $params = @{ - ObjectId = $Device.ObjectId + DeviceId = $Device.ObjectId RefObjectId = $User.ObjectId } Add-EntraDeviceRegisteredUser @params @@ -52,20 +52,20 @@ Add-EntraDeviceRegisteredUser @params This example shows how to add a registered user to a device. -- `-ObjectId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraDevice` to get device Id. +- `-DeviceId` parameter specifies the unique identifier (Object ID) of the device to which you want to add a registered user. The $Device.ObjectId variable should contain the Object ID of the device. You can use the command `Get-EntraDevice` to get device Id. - `-RefObjectId` parameter specifies the unique identifier (Object ID) of the user who will be added as a registered user of the device. The $User.ObjectId variable should contain the Object ID of the user. You can use the command `Get-EntraUser` to get user Id. ## Parameters -### -ObjectId +### -DeviceId Specifies the object ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDevice.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDevice.md index 0a829474b..5b08479e7 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDevice.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDevice.md @@ -49,7 +49,7 @@ Get-EntraDevice ```powershell Get-EntraDevice - -ObjectId + -DeviceId [-All] [-Property ] [] @@ -57,7 +57,7 @@ Get-EntraDevice ## Description -The `Get-EntraDevice` cmdlet gets a device from Microsoft Entra ID. Specify the `ObjectId` parameter to get a specific device. +The `Get-EntraDevice` cmdlet gets a device from Microsoft Entra ID. Specify the `DeviceId` parameter to get a specific device. ## Examples @@ -65,7 +65,7 @@ The `Get-EntraDevice` cmdlet gets a device from Microsoft Entra ID. Specify the ```powershell Connect-Entra -Scopes 'Device.Read.All' -Get-EntraDevice -ObjectId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraDevice -DeviceId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -188,14 +188,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -DeviceId Specifies the ID of a device in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwnedObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwnedObject.md index 0b2167e3c..890f1d9a6 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwnedObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalOwnedObject.md @@ -28,7 +28,7 @@ Gets an object owned by a service principal. ```powershell Get-EntraServicePrincipalOwnedObject [-All] - -ObjectId + -ServicePrincipalId [-Top ] [-Property ] [] @@ -45,7 +45,7 @@ The `Get-EntraServicePrincipalOwnedObject` cmdlet retrieves an object owned by a ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId +Get-EntraServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -56,14 +56,14 @@ bbbbbbbb-1111-2222-3333-cccccccccccc The command retrieves the owned objects of a service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 2: Retrieve the all owned objects of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipalId = (Get-EntraServicePrincipal -Filter "DisplayName eq ''").ObjectId -Get-EntraServicePrincipalOwnedObject -ObjectId $ServicePrincipalId -All +Get-EntraServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipalId -All ``` ```Output @@ -75,14 +75,14 @@ cccccccc-2222-3333-4444-dddddddddddd This example retrieves an object owned by a service principal in Microsoft Entra ID. You can use the command `Get-EntraServicePrincipal` to get service principal Id. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 2: Retrieve all owned objects of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -94,14 +94,14 @@ cccccccc-2222-3333-4444-dddddddddddd The command receives the all owned objects of a service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 3: Retrieve top one owned object of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" -Get-EntraServicePrincipalOwnedObject -ObjectId $ServicePrincipal.ObjectId -Top 1 +Get-EntraServicePrincipalOwnedObject -ServicePrincipalId $ServicePrincipal.ObjectId -Top 1 ``` ```Output @@ -112,7 +112,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This example retrieves the top one owned object of a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ## Parameters @@ -132,14 +132,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md index 99d0e0cdf..ab1b09767 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md @@ -27,7 +27,7 @@ Removes the registered owner of a device. ```powershell Remove-EntraDeviceRegisteredOwner -OwnerId - -ObjectId + -DeviceId [] ``` @@ -43,21 +43,21 @@ The `Remove-EntraDeviceRegisteredOwner` cmdlet removes the registered owner of a Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraDevice -Top 1 $Owner = Get-EntraDeviceRegisteredOwner -ObjectId $Device.ObjectId -Remove-EntraDeviceRegisteredOwner -ObjectId $Device.ObjectId -OwnerId $Owner.ObjectId +Remove-EntraDeviceRegisteredOwner -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId ``` This examples shows how to remove the owner of a device. ## Parameters -### -ObjectId +### -DeviceId Specifies an object ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Add-EntraDeviceRegisteredOwner.Tests.ps1 b/test/module/Entra/Add-EntraDeviceRegisteredOwner.Tests.ps1 index d944bdbad..94e39f55a 100644 --- a/test/module/Entra/Add-EntraDeviceRegisteredOwner.Tests.ps1 +++ b/test/module/Entra/Add-EntraDeviceRegisteredOwner.Tests.ps1 @@ -13,34 +13,40 @@ BeforeAll { Describe "Add-EntraDeviceRegisteredOwner" { Context "Test for Add-EntraDeviceRegisteredOwner" { It "Should return empty object" { - $result = Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName New-MgDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Add-EntraDeviceRegisteredOwner -ObjectId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + It "Should execute successfully with Alias" { + $result = Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DeviceId is empty" { + { Add-EntraDeviceRegisteredOwner -DeviceId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DeviceId'.*" } - It "Should fail when ObjectId is invalid" { - { Add-EntraDeviceRegisteredOwner -ObjectId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DeviceId is invalid" { + { Add-EntraDeviceRegisteredOwner -DeviceId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." } It "Should fail when RefObjectId is empty" { - { Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + { Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" } It "Should fail when RefObjectId is invalid" { - { Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + { Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." } It "Should contain DeviceId in parameters when passed ObjectId to it" { Mock -CommandName New-MgDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $result = Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" $params = Get-Parameters -data $result $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain BodyParameter in parameters when passed RefObjectId to it" { Mock -CommandName New-MgDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $value = @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbbbbb-1111-2222-3333-cccccccccccc"} Should -Invoke -CommandName New-MgDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -52,7 +58,7 @@ Describe "Add-EntraDeviceRegisteredOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDeviceRegisteredOwner" - Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraDeviceRegisteredOwner" @@ -69,7 +75,7 @@ Describe "Add-EntraDeviceRegisteredOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - {Add-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + {Add-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 b/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 index 36f50b989..8be7ecb45 100644 --- a/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 @@ -54,7 +54,7 @@ BeforeAll { Describe "Get-EntraDeletedApplication" { Context "Test for Get-EntraDeletedApplication" { It "Should return all applications" { - $result = Get-EntraDeletedApplication | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 } @@ -65,31 +65,31 @@ Describe "Get-EntraDeletedApplication" { { Get-EntraDeletedApplication -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" } It "Should return specific application by searchstring" { - $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty $result.DisplayName | should -Be 'Mock-test-App' Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return specific application by filter" { - $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty $result.DisplayName | should -Be 'Mock-test-App' Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should return top application" { - $result = Get-EntraDeletedApplication -Top 1 | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication -Top 1 | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 } It "Result should Contain ObjectId" { - $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain Filter in parameters when passed SearchString to it" { - $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json -Depth 10| ConvertFrom-Json + $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json -Depth 5| ConvertFrom-Json $params = Get-Parameters -data $result.Parameters $params.Filter | Should -Match "Mock-test-App" } @@ -106,7 +106,7 @@ Describe "Get-EntraDeletedApplication" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedApplication" - $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json -Depth 5 | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedApplication" Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { diff --git a/test/module/Entra/Get-EntraDevice.Tests.ps1 b/test/module/Entra/Get-EntraDevice.Tests.ps1 index 4fa142fa3..c2514635f 100644 --- a/test/module/Entra/Get-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Get-EntraDevice.Tests.ps1 @@ -51,14 +51,35 @@ BeforeAll { Describe "Get-EntraDevice" { Context "Test for Get-EntraDevice" { It "Should return specific device" { - $result = Get-EntraDevice -ObjectId "bbbbbbbb-1111-2222-3333-ccccccccccc" + $result = Get-EntraDevice -DeviceId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be @('aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb') Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should return specific device with Alias" { + $result = Get-EntraDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DeviceId is invalid" { + { Get-EntraDevice -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." + } + It "Should fail when DeviceId is empty" { + { Get-EntraDevice -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" + } + It "Should fail when searchstring is empty" { + { Get-EntraDevice -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" + } + It "Should fail when filter is empty" { + { Get-EntraDevice -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" + } + It "Should fail when Top is empty" { + { Get-EntraDevice -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when Top is invalid" { + { Get-EntraDevice -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return all devices" { $result = Get-EntraDevice -All @@ -100,11 +121,11 @@ Describe "Get-EntraDevice" { { Get-EntraDevice -Property DisplayName -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Result should Contain ObjectId" { - $result = Get-EntraDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDevice -DeviceId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain DeviceId in parameters when passed ObjectId to it" { - $result = Get-EntraDevice -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraDevice -DeviceId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.DeviceId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } diff --git a/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 index 4d50f0f48..bee28bca2 100644 --- a/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 +++ b/test/module/Entra/Get-EntraServicePrincipalOwnedObject.Tests.ps1 @@ -11,7 +11,7 @@ BeforeAll { $scriptblock = { return @( [PSCustomObject]@{ - "Id" = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" "DeletedDateTime" = $null "AdditionalProperties" = @{ accountEnabled = $true; @@ -37,7 +37,7 @@ Describe "Get-EntraServicePrincipalOwnedObject" { It "Should return specific ServicePrincipalOwnedObject with Alias" { $result = Get-EntraServicePrincipalOwnedObject -ObjectId "2d028fff-7e65-4340-80ca-89be16dae0b3" $result | Should -Not -BeNullOrEmpty - $result.Id | should -Be @('00aa00aa-bb11-cc22-dd33-44ee44ee44ee') + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ServicePrincipalId is empty" { @@ -66,14 +66,32 @@ Describe "Get-EntraServicePrincipalOwnedObject" { It "Should contain ServicePrincipalId in parameters when passed ServicePrincipalId to it" { $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" $params = Get-Parameters -data $result.Parameters - $params.ServicePrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params.ServicePrincipalId | Should -Be "2d028fff-7e65-4340-80ca-89be16dae0b3" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwnedObject" $result = Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" - $params = Get-Parameters -data $result.Parameters - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + $result | Should -Not -BeNullOrEmpty + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwnedObject" + Should -Invoke -CommandName Get-MgServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraServicePrincipalOwnedObject -ServicePrincipalId "2d028fff-7e65-4340-80ca-89be16dae0b3" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } } } } \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraDeviceRegisteredOwner.Tests.ps1 b/test/module/Entra/Remove-EntraDeviceRegisteredOwner.Tests.ps1 index da71c857e..3e7a53107 100644 --- a/test/module/Entra/Remove-EntraDeviceRegisteredOwner.Tests.ps1 +++ b/test/module/Entra/Remove-EntraDeviceRegisteredOwner.Tests.ps1 @@ -14,34 +14,40 @@ BeforeAll { Describe "Remove-EntraDeviceRegisteredOwner" { Context "Test for Remove-EntraDeviceRegisteredOwner" { It "Should return empty object" { - $result = Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraDeviceRegisteredOwner -ObjectId -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'ObjectId'*" } + It "Should execute successfully with Alias" { + $result = Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DeviceId is empty" { + { Remove-EntraDeviceRegisteredOwner -DeviceId -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'DeviceId'*" } } - It "Should fail when ObjectId is invalid" { - { Remove-EntraDeviceRegisteredOwner -ObjectId "" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string.*" } + It "Should fail when DeviceId is invalid" { + { Remove-EntraDeviceRegisteredOwner -DeviceId "" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } } It "Should fail when OwnerId is empty" { - { Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId | Should -Throw "Missing an argument for parameter 'OwnerId'*" } + { Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId | Should -Throw "Missing an argument for parameter 'OwnerId'*" } } It "Should fail when OwnerId is invalid" { - { Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "" | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string.*" } + { Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "" | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string.*" } } It "Should contain DeviceId in parameters when passed OwnerId to it" { Mock -CommandName Remove-MgDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain DirectoryObjectId in parameters when passed OwnerId to it" { Mock -CommandName Remove-MgDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } @@ -49,7 +55,7 @@ Describe "Remove-EntraDeviceRegisteredOwner" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeviceRegisteredOwner" - $result = Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDeviceRegisteredOwner" @@ -66,7 +72,7 @@ Describe "Remove-EntraDeviceRegisteredOwner" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Remove-EntraDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaDevice.Tests.ps1 index 584200709..69409cd0c 100644 --- a/test/module/EntraBeta/Get-EntraBetaDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaDevice.Tests.ps1 @@ -33,18 +33,24 @@ BeforeAll { Describe "Get-EntraBetaDevice" { Context "Test for Get-EntraBetaDevice" { It "Should return specific device" { - $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.DisplayName | should -Be "Mock-Device" Should -Invoke -CommandName Get-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaDevice -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should return specific device with Alias" { + $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Get-EntraBetaDevice -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when DeviceId is invalid" { + { Get-EntraBetaDevice -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." } It "Should return all applications" { $result = Get-EntraBetaDevice -All @@ -93,7 +99,7 @@ Describe "Get-EntraBetaDevice" { { Get-EntraBetaDevice -Top xy } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain Alias properties" { - $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.DevicePhysicalIds | should -Be "[HWID]:h:6825786449406074" $result.DeviceObjectVersion | should -Be "2" @@ -104,7 +110,7 @@ Describe "Get-EntraBetaDevice" { } It "Should contain DeviceId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -114,19 +120,19 @@ Describe "Get-EntraBetaDevice" { $params.Filter | Should -Match 'Mock-Device' } It "Property parameter should work" { - $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-Device' Should -Invoke -CommandName Get-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDevice" - $result = Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDevice" @@ -143,7 +149,7 @@ Describe "Get-EntraBetaDevice" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaDevice -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaDevice -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaServicePrincipalOwnedObject.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaServicePrincipalOwnedObject.Tests.ps1 index 38e2390d8..95c6df290 100644 --- a/test/module/EntraBeta/Get-EntraBetaServicePrincipalOwnedObject.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaServicePrincipalOwnedObject.Tests.ps1 @@ -93,7 +93,7 @@ BeforeAll { Describe "Get-EntraBetaServicePrincipalOwnedObject" { Context "Test for Get-EntraBetaServicePrincipalOwnedObject" { It "Should retrieve the owned objects of a service principal" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" $result | Should -Not -BeNullOrEmpty $result.AdditionalProperties | Should -Not -BeNullOrEmpty $result.displayName | Should -Be "ToGraph_443democc3c" @@ -105,50 +105,62 @@ Describe "Get-EntraBetaServicePrincipalOwnedObject" { Should -Invoke -CommandName Get-MgBetaServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } + It "Should return specific device with Alias" { + $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" + $result | Should -Not -BeNullOrEmpty + $result.AdditionalProperties | Should -Not -BeNullOrEmpty + $result.displayName | Should -Be "ToGraph_443democc3c" + $result.appDisplayName | Should -Be "ToGraph_443democc3c" + $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc58" + $result.appId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc55" + $result.AdditionalProperties.appDisplayName | Should -Be "ToGraph_443democc3c" + $result.AdditionalProperties.tags | Should -Be @('WindowsAzureActiveDirectoryIntegratedApp') - It "Should fail when ObjectId are empty" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + Should -Invoke -CommandName Get-MgBetaServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ServicePrincipalId are empty" { + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is Invalid" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is Invalid" { + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should return top service principal" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top 1 + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top are empty" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is Invalid" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top XYZ } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Top XYZ } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return all service principal" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -All + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All has an argument" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." } It "Should contain Id in result" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" $result.Id | should -Be "bbbbbbbb-1111-2222-3333-cccccccccc58" Should -Invoke -CommandName Get-MgBetaServicePrincipalOwnedObject -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should contain ServicePrincipalId in parameters when passed Id to it" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc40" } @@ -156,7 +168,7 @@ Describe "Get-EntraBetaServicePrincipalOwnedObject" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaServicePrincipalOwnedObject" - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaServicePrincipalOwnedObject" @@ -167,7 +179,7 @@ Describe "Get-EntraBetaServicePrincipalOwnedObject" { } } It "Property parameter should work" { - $result = Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Property appDisplayName + $result = Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Property appDisplayName $result | Should -Not -BeNullOrEmpty $result.appDisplayName | Should -Be 'ToGraph_443democc3c' @@ -175,7 +187,7 @@ Describe "Get-EntraBetaServicePrincipalOwnedObject" { } It "Should fail when Property is empty" { - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" } It "Should execute successfully without throwing an error " { # Disable confirmation prompts @@ -184,7 +196,7 @@ Describe "Get-EntraBetaServicePrincipalOwnedObject" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaServicePrincipalOwnedObject -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Debug } | Should -Not -Throw + { Get-EntraBetaServicePrincipalOwnedObject -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc40" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 41b30f9a1b6015a219305c2431986b7aab991fad Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 11:54:18 +0530 Subject: [PATCH 35/64] objectId alias change (#1053) * updates * updates * updates --- ...EntraBetaApplicationPasswordCredential.ps1 | 5 +++-- ...Get-EntraBetaApplicationProxyConnector.ps1 | 7 ++++--- ...aApplicationProxyConnectorGroupMembers.ps1 | 7 ++++--- ...aBetaApplicationProxyConnectorMemberOf.ps1 | 7 ++++--- ...licationProxyApplicationConnectorGroup.ps1 | 7 ++++--- ...t-EntraBetaApplicationProxyApplication.ps1 | 7 ++++--- ...licationProxyApplicationConnectorGroup.ps1 | 7 ++++--- ...Set-EntraBetaApplicationProxyConnector.ps1 | 7 ++++--- ...-EntraBetaApplicationPasswordCredential.md | 12 +++++------ .../Get-EntraBetaApplicationProxyConnector.md | 10 +++++----- ...taApplicationProxyConnectorGroupMembers.md | 18 ++++++++--------- ...raBetaApplicationProxyConnectorMemberOf.md | 10 +++++----- ...plicationProxyApplicationConnectorGroup.md | 10 +++++----- ...et-EntraBetaApplicationProxyApplication.md | 20 +++++++++---------- ...plicationProxyApplicationConnectorGroup.md | 12 +++++------ .../Set-EntraBetaApplicationProxyConnector.md | 10 +++++----- ...etaApplicationPasswordCredential.Tests.ps1 | 20 ++++++++++++------- 17 files changed, 95 insertions(+), 81 deletions(-) diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationPasswordCredential.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationPasswordCredential.ps1 index 4558eecfb..e475c8dca 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationPasswordCredential.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationPasswordCredential.ps1 @@ -6,7 +6,8 @@ function Get-EntraBetaApplicationPasswordCredential { [CmdletBinding(DefaultParameterSetName = '')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [Alias("ObjectId")] + [System.String] $ApplicationId, [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [System.String[]] $Property ) @@ -14,7 +15,7 @@ function Get-EntraBetaApplicationPasswordCredential { PROCESS { $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params = @{} - $baseUri = "https://graph.microsoft.com/beta/applications/$ObjectId/passwordCredentials" + $baseUri = "https://graph.microsoft.com/beta/applications/$ApplicationId/passwordCredentials" $params["Method"] = "GET" $params["Uri"] = "$baseUri" diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 index e5155357d..b4d305bd6 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 @@ -10,7 +10,8 @@ function Get-EntraBetaApplicationProxyConnector { [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Int32] $Top, [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id, + [Alias("Id")] + [System.String] $OnPremisesPublishingProfileId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [switch] $All, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -27,9 +28,9 @@ function Get-EntraBetaApplicationProxyConnector { $f = '$' + 'Filter' $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors?$f=machineName eq '$SearchString' OR startswith(machineName,'$SearchString')" } - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["OnPremisesPublishingProfileId"]) { - $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$Id" + $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$OnPremisesPublishingProfileId" } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 index 64d490d34..452f587bf 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 @@ -6,7 +6,8 @@ function Get-EntraBetaApplicationProxyConnectorGroupMembers { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id, + [Alias("Id")] + [System.String] $OnPremisesPublishingProfileId, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.Int32] $Top, [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -19,9 +20,9 @@ function Get-EntraBetaApplicationProxyConnectorGroupMembers { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params["Method"] = "GET" - $Id = $PSBoundParameters["Id"] + $Id = $PSBoundParameters["OnPremisesPublishingProfileId"] $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups/$Id/members" - if($PSBoundParameters.ContainsKey("Id")) + if($PSBoundParameters.ContainsKey("OnPremisesPublishingProfileId")) { $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups/$Id/members" } diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorMemberOf.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorMemberOf.ps1 index f5ab77d91..1b146426f 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorMemberOf.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorMemberOf.ps1 @@ -6,16 +6,17 @@ function Get-EntraBetaApplicationProxyConnectorMemberOf { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id + [Alias("Id")] + [System.String] $OnPremisesPublishingProfileId ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params["Method"] = "GET" - $Id = $PSBoundParameters["Id"] + $Id = $PSBoundParameters["OnPremisesPublishingProfileId"] $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$Id/memberOf" - if($PSBoundParameters.ContainsKey("Id")) + if($PSBoundParameters.ContainsKey("OnPremisesPublishingProfileId")) { $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$Id/memberOf" } diff --git a/module/EntraBeta/AdditionalFunctions/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 b/module/EntraBeta/AdditionalFunctions/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 index d01a13fab..b6d27897a 100644 --- a/module/EntraBeta/AdditionalFunctions/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 @@ -6,16 +6,17 @@ function Remove-EntraBetaApplicationProxyApplicationConnectorGroup { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId + [Alias("ObjectId")] + [System.String] $OnPremisesPublishingProfileId ) PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params["Method"] = "DELETE" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["OnPremisesPublishingProfileId"]) { - $params["Uri"] = "https://graph.microsoft.com/beta/applications/$ObjectId/connectorGroup/"+'$ref' + $params["Uri"] = "https://graph.microsoft.com/beta/applications/$OnPremisesPublishingProfileId/connectorGroup/"+'$ref' } Write-Debug("============================ TRANSFORMATIONS ============================") diff --git a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplication.ps1 b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplication.ps1 index 4b0a0b4ca..1bd685242 100644 --- a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplication.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplication.ps1 @@ -6,7 +6,8 @@ function Set-EntraBetaApplicationProxyApplication { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [Alias("ObjectId")] + [System.String] $ApplicationId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ExternalUrl, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -34,9 +35,9 @@ function Set-EntraBetaApplicationProxyApplication { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $onPremisesPublishing = @{} - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ApplicationId"]) { - $ObjectId = $PSBoundParameters["ObjectId"] + $ApplicationId = $PSBoundParameters["ApplicationId"] } if($null -ne $PSBoundParameters["ExternalUrl"]) { diff --git a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 index 5c403562e..380427dd0 100644 --- a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyApplicationConnectorGroup.ps1 @@ -6,7 +6,8 @@ function Set-EntraBetaApplicationProxyApplicationConnectorGroup { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [Alias("ObjectId")] + [System.String] $OnPremisesPublishingProfileId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ConnectorGroupId ) @@ -16,9 +17,9 @@ function Set-EntraBetaApplicationProxyApplicationConnectorGroup { $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params["Method"] = "PUT" $body = @{} - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["OnPremisesPublishingProfileId"]) { - $params["Uri"] = "https://graph.microsoft.com/beta/applications/$ObjectId/connectorGroup/" + '$ref' + $params["Uri"] = "https://graph.microsoft.com/beta/applications/$OnPremisesPublishingProfileId/connectorGroup/" + '$ref' } if($null -ne $PSBoundParameters["ConnectorGroupId"]) { diff --git a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyConnector.ps1 b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyConnector.ps1 index 17d4858a4..68b629e4a 100644 --- a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyConnector.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaApplicationProxyConnector.ps1 @@ -6,7 +6,8 @@ function Set-EntraBetaApplicationProxyConnector { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Id, + [Alias("Id")] + [System.String] $OnPremisesPublishingProfileId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $ConnectorGroupId ) @@ -16,9 +17,9 @@ function Set-EntraBetaApplicationProxyConnector { $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $params["Method"] = "POST" $body = @{} - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["OnPremisesPublishingProfileId"]) { - $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$Id/memberOf/" + '$ref' + $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/$OnPremisesPublishingProfileId/memberOf/" + '$ref' } if($null -ne $PSBoundParameters["ConnectorGroupId"]) { diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationPasswordCredential.md index e60ff2081..20c21a45d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationPasswordCredential.md @@ -24,14 +24,14 @@ Gets the password credential for an application. ```powershell Get-EntraBetaApplicationPasswordCredential - -ObjectId + -ApplicationId [-Property ] [] ``` ## Description -The `Get-EntraBetaApplicationPasswordCredential` cmdlet receives the password credentials for a Microsoft Entra ID application. Specify `ObjectId` parameter to cmdlet receives the password credentials. +The `Get-EntraBetaApplicationPasswordCredential` cmdlet receives the password credentials for a Microsoft Entra ID application. Specify `ApplicationId` parameter to cmdlet receives the password credentials. ## Examples @@ -40,7 +40,7 @@ The `Get-EntraBetaApplicationPasswordCredential` cmdlet receives the password cr ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraBetaApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraBetaApplicationPasswordCredential -ObjectId $application.ObjectId +Get-EntraBetaApplicationPasswordCredential -ApplicationId $application.ObjectId ``` ```Output @@ -51,18 +51,18 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This example shows how to retrieve the password credential for specified application. -- `-ObjectId` specifies the ID of an application object in Microsoft Entra ID. +- `-ApplicationId` specifies the ID of an application object in Microsoft Entra ID. ## Parameters -### -ObjectId +### -ApplicationId The objectID of the application for which to get the password credential. Use `Get-EntraBetaApplication` for more details. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnector.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnector.md index 34bbb0e4d..5311df863 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnector.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnector.md @@ -48,7 +48,7 @@ Get-EntraBetaApplicationProxyConnector ```powershell Get-EntraBetaApplicationProxyConnector - -Id + -OnPremisesPublishingProfileId [-All] [] ``` @@ -79,7 +79,7 @@ This command Retrieve all connectors. ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Get-EntraBetaApplicationProxyConnector -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaApplicationProxyConnector -OnPremisesPublishingProfileId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -90,7 +90,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb This example demonstrates how to Retrieve information for a specific connector. -- `Id` parameter specifies the connector ID. +- `OnPremisesPublishingProfileId` parameter specifies the connector ID. ### Example 3: Retrieve information for a top one connector @@ -173,7 +173,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -Id +### -OnPremisesPublishingProfileId The ID of the specific connector. You can find this ID by running the command without this parameter to get the desired ID, or by going into the portal and viewing connector details. @@ -181,7 +181,7 @@ You can find this ID by running the command without this parameter to get the de ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorGroupMembers.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorGroupMembers.md index df56b721f..da851a247 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorGroupMembers.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorGroupMembers.md @@ -27,7 +27,7 @@ The `Get-EntraBetaApplicationProxyConnectorGroupMembers` get all the Application ```powershell Get-EntraBetaApplicationProxyConnectorGroupMembers - -Id + -OnPremisesPublishingProfileId [-All] [-Top ] [-Filter ] @@ -43,7 +43,7 @@ The `Get-EntraBetaApplicationProxyConnectorGroupMembers` get all the Application ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Get-EntraBetaApplicationProxyConnectorGroupMembers -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaApplicationProxyConnectorGroupMembers -OnPremisesPublishingProfileId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -55,13 +55,13 @@ bbbbbbbb-1111-2222-3333-cccccccccccc 106.195.6.123 AppProxy Machine active 1.5.3 This example retrieves all the connectors in the group. -- `Id` parameter specifies the connector group ID. +- `OnPremisesPublishingProfileId` parameter specifies the connector group ID. ### Example 2: Gets top one connector in the group ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Get-EntraBetaApplicationProxyConnectorGroupMembers -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 1 +Get-EntraBetaApplicationProxyConnectorGroupMembers -OnPremisesPublishingProfileId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -Top 1 ``` ```Output @@ -72,14 +72,14 @@ bbbbbbbb-1111-2222-3333-cccccccccccc 106.195.6.123 AppProxy Machine active 1.5.3 This example retrieves top one connector in the group. -- `Id` parameter specifies the connector group ID. +- `OnPremisesPublishingProfileId` parameter specifies the connector group ID. ### Example 3: Gets the connectors in the group with filter parameter ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - Id = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + OnPremisesPublishingProfileId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' Filter = "machineName eq 'AppProxy Machine'" } Get-EntraBetaApplicationProxyConnectorGroupMembers @params @@ -94,7 +94,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc 106.195.6.123 AppProxy Machine active 1.5.3 This example retrieves a connector in the group using machineName property. -- `Id` parameter specifies the connector group ID. +- `OnPremisesPublishingProfileId` parameter specifies the connector group ID. ## Parameters @@ -130,14 +130,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -Id +### -OnPremisesPublishingProfileId The ID of the Connector group. This ID can be found by running the `Get-EntraBetaApplicationProxyConnectorGroup` command. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorMemberOf.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorMemberOf.md index 3abfc44b3..13c06d158 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorMemberOf.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationProxyConnectorMemberOf.md @@ -27,7 +27,7 @@ The `Get-EntraBetaApplicationProxyConnectorMemberOf` command gets the ConnectorG ```powershell Get-EntraBetaApplicationProxyConnectorMemberOf - -Id + -OnPremisesPublishingProfileId [] ``` @@ -42,7 +42,7 @@ If no group is assigned to the connector, by default it is in 'Default.' ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Get-EntraBetaApplicationProxyConnectorMemberOf -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaApplicationProxyConnectorMemberOf -OnPremisesPublishingProfileId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -53,18 +53,18 @@ bbbbbbbb-1111-2222-3333-cccccccccccc applicationProxy False Backup Applica This example retrieves the ConnectorGroup With Specified Connector ID. -- `-Id` parameter specifies the connector ID. +- `-OnPremisesPublishingProfileId` parameter specifies the connector ID. ## Parameters -### -Id +### -OnPremisesPublishingProfileId The ID of the connector. You can find ID by running `Get-EntraBetaApplicationProxyConnector`. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.md index 7b4b43539..58e580176 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationProxyApplicationConnectorGroup.md @@ -26,7 +26,7 @@ The `Remove-EntraBetaApplicationProxyApplicationConnectorGroupcmdlet` sets the c ```powershell Remove-EntraBetaApplicationProxyApplicationConnectorGroup - -ObjectId + -OnPremisesPublishingProfileId [] ``` @@ -41,16 +41,16 @@ The application must be configured for Application Proxy in Microsoft Entra ID. ```POWERSHELL Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-EntraBetaApplicationProxyApplicationConnectorGroup -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Remove-EntraBetaApplicationProxyApplicationConnectorGroup -OnPremisesPublishingProfileId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` This example removes the Connector Group associated with an application, setting the group to 'Default.' -- `ObjectId` parameter specifies the application ID. +- `OnPremisesPublishingProfileId` parameter specifies the application ID. ## Parameters -### -ObjectId +### -OnPremisesPublishingProfileId The unique application ID of the application. The application ID can be found using the `Get-EntraBetaApplication` command. @@ -59,7 +59,7 @@ You can also find objectId in the Microsoft Entra Admin Center by navigating to ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplication.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplication.md index fe10fd1f2..9e3b416f8 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplication.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplication.md @@ -26,7 +26,7 @@ The `Set-EntraBetaApplicationProxyApplication` allows you to modify and set conf ```powershell Set-EntraBetaApplicationProxyApplication - -ObjectId + -ApplicationId [-ExternalUrl ] [-InternalUrl ] [-ExternalAuthenticationType ] @@ -42,7 +42,7 @@ Set-EntraBetaApplicationProxyApplication ## Description -The `Set-EntraBetaApplicationProxyApplication` allows you to modify and set other settings for an application in Microsoft Entra ID configured to use ApplicationProxy. Specify `ObjectId` parameter to update application configured for application proxy. +The `Set-EntraBetaApplicationProxyApplication` allows you to modify and set other settings for an application in Microsoft Entra ID configured to use ApplicationProxy. Specify `ApplicationId` parameter to update application configured for application proxy. ## Examples @@ -51,7 +51,7 @@ The `Set-EntraBetaApplicationProxyApplication` allows you to modify and set othe ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + ApplicationId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ExternalUrl = 'https://finance-awcycles.msappproxy.net/' InternalUrl = 'http://finance/' ExternalAuthenticationType = 'AadPreAuthentication' @@ -80,7 +80,7 @@ isPersistentCookieEnabled : False This example update `ExternalUrl`, `InternalUrl`, `ExternalAuthenticationType`, and `IsTranslateHostHeaderEnabled` parameter. -- `-ObjectId` parameter specifies the application ID. +- `-ApplicationId` parameter specifies the application ID. - `-ExternalUrl` parameter specifies the URL that use to access the application from outside user private network. - `-InternalUrl` parameter specifies the URL that use to access the application from inside user private network. - `-ExternalAuthenticationType` parameter specifies the external authentication type. @@ -91,7 +91,7 @@ This example update `ExternalUrl`, `InternalUrl`, `ExternalAuthenticationType`, ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + ApplicationId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ExternalUrl = 'https://finance-awcycles.msappproxy.net/' InternalUrl = 'http://finance/' ExternalAuthenticationType = 'AadPreAuthentication' @@ -123,7 +123,7 @@ isPersistentCookieEnabled : False This example update `IsHttpOnlyCookieEnabled`, `IsSecureCookieEnabled`, and `IsPersistentCookieEnabled` parameter. -- `-ObjectId` parameter specifies the application ID. +- `-ApplicationId` parameter specifies the application ID. - `-ExternalUrl` parameter specifies the URL that use to access the application from outside user private network. - `-InternalUrl` parameter specifies the URL that use to access the application from inside user private network. - `-ExternalAuthenticationType` parameter specifies the external authentication type. @@ -137,7 +137,7 @@ This example update `IsHttpOnlyCookieEnabled`, `IsSecureCookieEnabled`, and `IsP ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + ApplicationId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ExternalUrl = 'https://finance-awcycles.msappproxy.net/' InternalUrl = 'http://finance/' ExternalAuthenticationType = 'AadPreAuthentication' @@ -168,7 +168,7 @@ isPersistentCookieEnabled : False This example update `IsTranslateLinksInBodyEnabled`, `ApplicationServerTimeout`, and `ConnectorGroupId` parameter. -- `-ObjectId` parameter specifies the application ID. +- `-ApplicationId` parameter specifies the application ID. - `-ExternalUrl` parameter specifies the URL that use to access the application from outside user private network. - `-InternalUrl` parameter specifies the URL that use to access the application from inside user private network. - `-ConnectorGroupId` parameter specifies the Connector group ID that assigned to this application. @@ -178,7 +178,7 @@ This example update `IsTranslateLinksInBodyEnabled`, `ApplicationServerTimeout`, ## Parameters -### -ObjectId +### -ApplicationId Specifies a unique application ID of an application in Microsoft Entra ID. This objectid can be found using the `Get-EntraBetaApplication` command. @@ -186,7 +186,7 @@ This objectid can be found using the `Get-EntraBetaApplication` command. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplicationConnectorGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplicationConnectorGroup.md index cf7173488..061341d0f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplicationConnectorGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyApplicationConnectorGroup.md @@ -26,14 +26,14 @@ The `Set-EntraBetaApplicationProxyApplicationConnectorGroup` cmdlet assigns the ```powershell Set-EntraBetaApplicationProxyApplicationConnectorGroup - -ObjectId + -OnPremisesPublishingProfileId -ConnectorGroupId [] ``` ## Description -The `Set-EntraBetaApplicationProxyApplicationConnectorGroup` cmdlet sets the connector group assigned for the specified application. Specify `ObjectId` and `ConnectorGroupId` parameter to assign the given connector group to a specified application. +The `Set-EntraBetaApplicationProxyApplicationConnectorGroup` cmdlet sets the connector group assigned for the specified application. Specify `OnPremisesPublishingProfileId` and `ConnectorGroupId` parameter to assign the given connector group to a specified application. The application must be configured for Application Proxy in Microsoft Entra ID. @@ -44,7 +44,7 @@ The application must be configured for Application Proxy in Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - ObjectId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + OnPremisesPublishingProfileId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ConnectorGroupId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Set-EntraBetaApplicationProxyApplicationConnectorGroup @params @@ -52,7 +52,7 @@ Set-EntraBetaApplicationProxyApplicationConnectorGroup @params This example set a new Connector Group for a specific application. -- `ObjectId` parameter specifies the application ID. +- `OnPremisesPublishingProfileId` parameter specifies the application ID. - `ConnectorGroupId` parameter specifies the connector group ID that assign to the application. ## Parameters @@ -74,7 +74,7 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -OnPremisesPublishingProfileId The unique application ID for the application the Connector group assigns to. The application ID can be found using the `Get-EntraBetaApplication` command. @@ -82,7 +82,7 @@ The application ID can be found using the `Get-EntraBetaApplication` command. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyConnector.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyConnector.md index 43bf96d73..3e9ab099e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyConnector.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationProxyConnector.md @@ -26,7 +26,7 @@ The `Set-EntraBetaApplicationProxyConnector` cmdlet allows reassignment of the c ```powershell Set-EntraBetaApplicationProxyConnector - -Id + -OnPremisesPublishingProfileId -ConnectorGroupId [] ``` @@ -42,7 +42,7 @@ The `Set-EntraBetaApplicationProxyConnector` cmdlet allows reassignment of the c ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' $params = @{ - Id = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + OnPremisesPublishingProfileId = 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ConnectorGroupId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Set-EntraBetaApplicationProxyConnector @params @@ -50,12 +50,12 @@ Set-EntraBetaApplicationProxyConnector @params This example demonstrates how to move a Connector to a different Connector Group. -- `-Id` parameter specifies the connector ID. +- `-OnPremisesPublishingProfileId` parameter specifies the connector ID. - `-ConnectorGroupId` parameter specifies the application proxy connector group ID. ## Parameters -### -Id +### -OnPremisesPublishingProfileId The ID of the Connector being moved. Use the `Get-EntraBetaApplicationProxyConnectorGroup` command to find the Connector Group ID. @@ -63,7 +63,7 @@ Use the `Get-EntraBetaApplicationProxyConnectorGroup` command to find the Connec ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/EntraBeta/Get-EntraBetaApplicationPasswordCredential.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaApplicationPasswordCredential.Tests.ps1 index 9bdd7f3be..2dc2c4d23 100644 --- a/test/module/EntraBeta/Get-EntraBetaApplicationPasswordCredential.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaApplicationPasswordCredential.Tests.ps1 @@ -27,24 +27,30 @@ BeforeAll { } Describe "Get-EntraBetaApplicationPasswordCredential" { Context "Test for Get-EntraBetaApplicationPasswordCredential" { - It "Should return specific Policy" { - $result = Get-EntraBetaApplicationPasswordCredential -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + It "Should return specific credential" { + $result = Get-EntraBetaApplicationPasswordCredential -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.keyId | Should -Be "bbbbbbbb-1111-2222-3333-rrrrrrrrrrrr" $result.DisplayName | Should -Be "test" $result.CustomKeyIdentifier.gettype().name | Should -Be 'Byte[]' Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is invalObjectId" { - { Get-EntraBetaApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should return specific credential with Alias" { + $result = Get-EntraBetaApplicationPasswordCredential -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ApplicationId is invalid" { + { Get-EntraBetaApplicationPasswordCredential -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Get-EntraBetaApplicationPasswordCredential -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationPasswordCredential" - $result = Get-EntraBetaApplicationPasswordCredential -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaApplicationPasswordCredential -ApplicationId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue From a99946d1834436f9ae564171e891da9d5066e09f Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 12:19:47 +0530 Subject: [PATCH 36/64] paramter updates (#1087) * paramter updates * updates * updates * updates --- .../Get-EntraBetaUserMembership.md | 12 +++--- .../Get-EntraBetaUserOAuth2PermissionGrant.md | 24 +++++------ .../Remove-EntraBetaUserManager.md | 12 +++--- .../Revoke-EntraBetaUserAllRefreshToken.md | 10 ++--- .../Set-EntraBetaUserManager.md | 12 +++--- .../Get-EntraUserMembership.md | 12 +++--- .../Get-EntraUserOAuth2PermissionGrant.md | 20 ++++----- .../Remove-EntraUserManager.md | 11 +++-- .../Revoke-EntraUserAllRefreshToken.md | 16 +++----- .../Set-EntraUserManager.md | 10 ++--- src/CompatibilityAdapterBuilder.ps1 | 2 - .../Entra/Get-EntraUserMembership.Tests.ps1 | 39 ++++++++++-------- ...t-EntraUserOAuth2PermissionGrant.Tests.ps1 | 41 +++++++++++-------- .../Entra/Remove-EntraUserManager.Tests.ps1 | 21 ++++++---- .../Revoke-EntraUserAllRefreshToken.Tests.ps1 | 21 ++++++---- .../Entra/Set-EntraUserManager.Tests.ps1 | 25 +++++++---- .../Get-EntraBetaUserMembership.Tests.ps1 | 41 +++++++++++-------- .../Remove-EntraBetaUserManager.Tests.ps1 | 17 +++++--- .../Set-EntraBetaUserManager.Tests.ps1 | 17 +++++--- 19 files changed, 203 insertions(+), 160 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserMembership.md index 83cd1682f..6bca0f3e0 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserMembership.md @@ -26,7 +26,7 @@ Get user memberships. ```powershell Get-EntraBetaUserMembership - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraBetaUserMembership` cmdlet gets user memberships in Microsoft Entr ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserMembership -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserMembership -UserId 'SawyerM@contoso.com' ``` ```Output @@ -90,7 +90,7 @@ This example demonstrates how to retrieve user memberships in Microsoft Entra ID ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserMembership -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserMembership -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -110,7 +110,7 @@ This example demonstrates how to retrieve users all memberships in Microsoft Ent ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraBetaUserMembership -ObjectId 'SawyerM@contoso.com' -Top 3 +Get-EntraBetaUserMembership -UserId 'SawyerM@contoso.com' -Top 3 ``` ```Output @@ -141,14 +141,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md index 417f429e1..85f43e817 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md @@ -27,7 +27,7 @@ Gets an oAuth2PermissionGrant object. ```powershell Get-EntraBetaUserOAuth2PermissionGrant - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -36,7 +36,7 @@ Get-EntraBetaUserOAuth2PermissionGrant ## Description -The `Get-EntraBetaUserOAuth2PermissionGrant` cmdlet gets an oAuth2PermissionGrant object for the specified user in Microsoft Entra ID. Specify `ObjectId` parameter to retrieve an oAuth2PermissionGrant object. +The `Get-EntraBetaUserOAuth2PermissionGrant` cmdlet gets an oAuth2PermissionGrant object for the specified user in Microsoft Entra ID. Specify `UserId` parameter to retrieve an oAuth2PermissionGrant object. In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation. @@ -56,7 +56,7 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' ``` ```Output @@ -66,13 +66,13 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 9uBzRwC0s0CFCDQN6O4Ik_fW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 11112222-bbbb-3333-cccc-4444dddd5555 Principal 13-01-2024 08:0... ``` -This example retrieves the OAuth2 permission grants for a user using the ObjectId parameter. Use the `Get-EntraBetaUser` cmdlet to obtain the `ObjectId` value. +This example retrieves the OAuth2 permission grants for a user using the ObjectId parameter. Use the `Get-EntraBetaUser` cmdlet to obtain the `UserId` value. ### Example 2: Retrieve the OAuth2 permission grants for a user using object ID parameter ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' +Get-EntraUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' ``` ```Output @@ -84,13 +84,13 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 This example retrieves the OAuth2 permission grants for a user using object ID parameter. -- `-ObjectId` parameter specifies the user ID. +- `-UserId` parameter specifies the user ID. ### Example 3: Retrieve the OAuth2 permission grants for a user using All parameter ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' -All +Get-EntraBetaUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -102,13 +102,13 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 This example retrieves the OAuth2 permission grants for a user using All parameter. -- `-ObjectId` parameter specifies the user ID. +- `-UserId` parameter specifies the user ID. ### Example 4: Retrieve top one OAuth2 permission grant ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' -Top 1 +Get-EntraBetaUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' -Top 1 ``` ```Output @@ -119,7 +119,7 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 This Example Retrieve top one the OAuth2 permission grant in Microsoft Entra ID. -- `-ObjectId` parameter specifies the user ID. +- `-UserId` parameter specifies the user ID. ## Parameters @@ -139,14 +139,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId Specifies the ID (as a User Principal Name or ObjectId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md index 65aef82c7..7f76cf8cc 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md @@ -26,13 +26,13 @@ Removes a user's manager. ```powershell Remove-EntraBetaUserManager - -ObjectId + -UserId [] ``` ## Description -The `Remove-EntraBetaUserManager` cmdlet removes a user's manager in Microsoft Entra ID. Specify the `ObjectId` parameter to remove the manager for a user in Microsoft Entra ID. +The `Remove-EntraBetaUserManager` cmdlet removes a user's manager in Microsoft Entra ID. Specify the `UserId` parameter to remove the manager for a user in Microsoft Entra ID. ## Examples @@ -40,8 +40,8 @@ The `Remove-EntraBetaUserManager` cmdlet removes a user's manager in Microsoft E ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$User = Get-EntraBetaUser -ObjectId 'SawyerM@Contoso.com' -Remove-EntraBetaUserManager -ObjectId $User.ObjectId +$User = Get-EntraBetaUser -Top 1 +Remove-EntraBetaUserManager -UserId $User.ObjectId ``` This example shows how to remove a user's manager. @@ -50,14 +50,14 @@ You can use `Get-EntraBetaUser` command to get the user's details. ## Parameters -### -ObjectId +### -UserId Specifies the ID of a user (as a User Principle Name or ObjectId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md index 8b297a7c7..9bfc171bc 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md @@ -24,7 +24,7 @@ Invalidates the refresh tokens issued to applications for a user. ```powershell Revoke-EntraBetaUserAllRefreshToken - -ObjectId + -UserId [] ``` @@ -44,7 +44,7 @@ This operation is usually performed by the user or an administrator if the user' ```powershell Connect-Entra -Scopes 'User.RevokeSessions.All' -Revoke-EntraBetaUserAllRefreshToken -ObjectId 'SawyerM@contoso.com' +Revoke-EntraBetaUserAllRefreshToken -UserId 'eeeeeeee-4444-5555-6666-ffffffffffff' ``` ```Output @@ -55,18 +55,18 @@ True This example demonstrates how to revoke the tokens for the specified user. -- `-ObjectId` parameter specifies the unique identifier of a user. +- `-UserId` parameter specifies the unique identifier of a user. ## Parameters -### -ObjectId +### -UserId Specifies the unique ID of a user. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md index 81228f660..81d40fa30 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md @@ -25,14 +25,14 @@ Updates a user's manager. ```powershell Set-EntraBetaUserManager - -ObjectId + -UserId -RefObjectId [] ``` ## Description -The `Set-EntraBetaUserManager` cmdlet update the manager for a user in Microsoft Entra ID. Specify the `ObjectId` and `RefObjectId` parameters to update the manager for a user in Microsoft Entra ID. +The `Set-EntraBetaUserManager` cmdlet update the manager for a user in Microsoft Entra ID. Specify the `UserId` and `RefObjectId` parameters to update the manager for a user in Microsoft Entra ID. ## Examples @@ -42,8 +42,8 @@ The `Set-EntraBetaUserManager` cmdlet update the manager for a user in Microsoft Connect-Entra -Scopes 'User.ReadWrite.All' $manager = Get-EntraBetaUser -ObjectId 'Manager@contoso.com' $params = @{ - ObjectId = 'SawyerM@contoso.com' - RefObjectId = $manager.ObjectId + UserId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' + RefObjectId = '55ff55ff-aa66-bb77-cc88-99dd99dd99dd' } Set-EntraBetaUserManager @params ``` @@ -52,14 +52,14 @@ This example demonstrates how to update the manager for the specified user. ## Parameters -### -ObjectId +### -UserId Specifies the ID (as a User Principle Name or ObjectId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserMembership.md index 641f56f67..4c9b9c108 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserMembership.md @@ -26,7 +26,7 @@ Get user memberships. ```powershell Get-EntraUserMembership - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraUserMembership` cmdlet gets user memberships in Microsoft Entra ID ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserMembership -ObjectId 'SawyerM@contoso.com' +Get-EntraUserMembership -UserId 'SawyerM@contoso.com' ``` ```Output @@ -90,7 +90,7 @@ This example demonstrates how to retrieve user memberships in Microsoft Entra ID ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserMembership -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserMembership -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -110,7 +110,7 @@ This example demonstrates how to retrieve users all memberships in Microsoft Ent ```powershell Connect-Entra -Scopes 'User.Read' -Get-EntraUserMembership -ObjectId 'SawyerM@contoso.com' -Top 3 +Get-EntraUserMembership -UserId 'SawyerM@contoso.com' -Top 3 ``` ```Output @@ -141,14 +141,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId Specifies the ID of a user (as a User Principal Name or ObjectId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOAuth2PermissionGrant.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOAuth2PermissionGrant.md index 5e7c9e911..b69676b2e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOAuth2PermissionGrant.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserOAuth2PermissionGrant.md @@ -26,7 +26,7 @@ Gets an oAuth2PermissionGrant object. ```powershell Get-EntraUserOAuth2PermissionGrant - -ObjectId + -UserId [-All] [-Top ] [-Property ] @@ -35,7 +35,7 @@ Get-EntraUserOAuth2PermissionGrant ## Description -The `Get-EntraUserOAuth2PermissionGrant` cmdlet gets an oAuth2PermissionGrant object for the specified user in Microsoft Entra ID. Specify `ObjectId` parameter to retrieve an oAuth2PermissionGrant object. +The `Get-EntraUserOAuth2PermissionGrant` cmdlet gets an oAuth2PermissionGrant object for the specified user in Microsoft Entra ID. Specify `UserId` parameter to retrieve an oAuth2PermissionGrant object. In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation. @@ -55,7 +55,7 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' +Get-EntraUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' ``` ```Output @@ -65,13 +65,13 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 9uBzRwC0s0CFCDQN6O4Ik_fW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 11112222-bbbb-3333-cccc-4444dddd5555 Principal 13-01-2024 08:0... ``` -This example retrieves the OAuth2 permission grants for a user using the ObjectId parameter. Use the `Get-EntraBetaUser` cmdlet to obtain the `ObjectId` value. +This example retrieves the OAuth2 permission grants for a user using the ObjectId parameter. Use the `Get-EntraUser` cmdlet to obtain the `UserId` value. ### Example 2: Retrieve the OAuth2 permission grants for a user using object ID parameter ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' +Get-EntraUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' ``` ```Output @@ -83,13 +83,13 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 This example retrieves the OAuth2 permission grants for a user using object ID parameter. -- `-ObjectId` parameter specifies the user ID. +- `-UserId` parameter specifies the user ID. ### Example 3: Retrieve the OAuth2 permission grants for a user using All parameter ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraUserOAuth2PermissionGrant -ObjectId 'SawyerM@contoso.com' -All +Get-EntraUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' -All ``` ```Output @@ -118,7 +118,7 @@ HXFXwKLgoUC4rwbZbCDIdffW8XpadQNIoHik9aQxrVHR6StBYBRhQI7tzKID_LIV 00001111-aaaa-2 This Example Retrieve top one the OAuth2 permission grant in Microsoft Entra ID. -- `-ObjectId` parameter specifies the user ID. +- `-UserId` parameter specifies the user ID. ## Parameters @@ -138,14 +138,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -UserId Specifies the ID (as a User Principal Name or ObjectId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md index cd8055b06..1f780a231 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md @@ -26,8 +26,7 @@ Removes a user's manager. ```powershell Remove-EntraUserManager - -ObjectId - [] + -UserId ``` ## Description @@ -40,8 +39,8 @@ The `Remove-EntraUserManager` cmdlet removes a user's manager in Microsoft Entra ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$User = Get-EntraUser -ObjectId 'SawyerM@Contoso.com' -Remove-EntraUserManager -ObjectId $User.ObjectId +$User = Get-EntraUser -Top 1 +Remove-EntraUserManager -UserId $User.ObjectId ``` This example shows how to remove a user's manager. @@ -50,14 +49,14 @@ You can use `Get-EntraUser` command to get the user's details. ## Parameters -### -ObjectId +### -UserId Specifies the ID of a user (as a User Principle Name or ObjectId) in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md index 5ae2a38e9..d96d2cdf3 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md @@ -24,7 +24,7 @@ Invalidates the refresh tokens issued to applications for a user. ```powershell Revoke-EntraUserAllRefreshToken - -ObjectId + -UserId [] ``` @@ -44,29 +44,23 @@ This operation is usually performed by the user or an administrator if the user' ```powershell Connect-Entra -Scopes 'User.RevokeSessions.All' -Revoke-EntraUserAllRefreshToken -ObjectId 'SawyerM@contoso.com' -``` - -```Output -Value ------ -True +Revoke-EntraUserAllRefreshToken -UserId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` This example demonstrates how to revoke the tokens for the specified user. -- `-ObjectId` parameter specifies the unique identifier of a user. +- `-UserId` parameter specifies the unique identifier of a user. ## Parameters -### -ObjectId +### -UserId Specifies the unique ID of a user. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md index 12f2c2a09..86fffa11a 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md @@ -25,14 +25,14 @@ Updates a user's manager. ```powershell Set-EntraUserManager - -ObjectId + -UserId -RefObjectId [] ``` ## Description -The `Set-EntraUserManager` cmdlet update the manager for a user in Microsoft Entra ID. Specify the `ObjectId` and `RefObjectId` parameters to update the manager for a user in Microsoft Entra ID. +The `Set-EntraUserManager` cmdlet update the manager for a user in Microsoft Entra ID. Specify the `UserId` and `RefObjectId` parameters to update the manager for a user in Microsoft Entra ID. ## Examples @@ -42,7 +42,7 @@ The `Set-EntraUserManager` cmdlet update the manager for a user in Microsoft Ent Connect-Entra -Scopes 'User.ReadWrite.All' $manager = Get-EntraUser -ObjectId 'Manager@contoso.com' $params = @{ - ObjectId = 'SawyerM@contoso.com' + UserId = 'SawyerM@contoso.com' RefObjectId = $manager.ObjectId } Set-EntraUserManager @params @@ -52,14 +52,14 @@ This example demonstrates how to update the manager for the specified user. ## Parameters -### -ObjectId +### -UserId Specifies the ID (as a User Principle Name or ObjectId) of a user in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 4e4d52027..ad1e60d1f 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -25,7 +25,6 @@ class CompatibilityAdapterBuilder { hidden [string] $BasePath = $null hidden [string] $LoadMessage hidden [string[]] $cmdtoSkipNameconverssion = @( - 'Revoke-EntraUserAllRefreshToken', 'Select-EntraGroupIdsGroupIsMemberOf', 'Get-EntraUserAppRoleAssignment', 'Get-EntraPermissionGrantConditionSet', @@ -61,7 +60,6 @@ class CompatibilityAdapterBuilder { 'Set-EntraPermissionGrantConditionSet', 'Remove-EntraDeletedApplication', 'Select-EntraGroupIdsUserIsMemberOf', - 'Get-EntraUserOAuth2PermissionGrant', 'Add-EntraBetaServicePrincipalPolicy', 'Get-EntraBetaPrivilegedRoleDefinition', 'Get-EntraBetaFeatureRolloutPolicy', diff --git a/test/module/Entra/Get-EntraUserMembership.Tests.ps1 b/test/module/Entra/Get-EntraUserMembership.Tests.ps1 index 5b06b93fd..6c8a92343 100644 --- a/test/module/Entra/Get-EntraUserMembership.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserMembership.Tests.ps1 @@ -27,59 +27,66 @@ BeforeAll { Describe "Get-EntraUserMembership" { Context "Test for Get-EntraUserMembership" { It "Should return specific user membership" { + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgUserMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific user membership with alias" { $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraUserMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraUserMembership -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraUserMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is invalid" { + { Get-EntraUserMembership -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return all user membership" { - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } It "Should return top user membership" { - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 5 + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 5 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain ObjectId" { - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" @@ -87,13 +94,13 @@ Describe "Get-EntraUserMembership" { } It "Should fail when Property is empty" { - { Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserMembership" - $result = Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserMembership" @@ -111,7 +118,7 @@ Describe "Get-EntraUserMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserMembership -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraUserMembership -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraUserOAuth2PermissionGrant.Tests.ps1 b/test/module/Entra/Get-EntraUserOAuth2PermissionGrant.Tests.ps1 index b7ad90c06..2a69bbfff 100644 --- a/test/module/Entra/Get-EntraUserOAuth2PermissionGrant.Tests.ps1 +++ b/test/module/Entra/Get-EntraUserOAuth2PermissionGrant.Tests.ps1 @@ -27,6 +27,15 @@ BeforeAll { Describe "Get-EntraUserOAuth2PermissionGrant" { Context "Test for Get-EntraUserOAuth2PermissionGrant" { It "Should return specific UserOAuth2PermissionGrant" { + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result | Should -Not -BeNullOrEmpty + $result.PrincipalId | should -Contain 'aaaaaaaa-bbbb-cccc-1111-222222222222' + $result.Id | Should -Contain 'Aa1Bb2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_~Jj0Kk1Ll2' + + Should -Invoke -CommandName Get-MgUserOAuth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific UserOAuth2PermissionGrant with alias" { $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" $result | Should -Not -BeNullOrEmpty $result.PrincipalId | should -Contain 'aaaaaaaa-bbbb-cccc-1111-222222222222' @@ -35,54 +44,54 @@ Describe "Get-EntraUserOAuth2PermissionGrant" { Should -Invoke -CommandName Get-MgUserOAuth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraUserOAuth2PermissionGrant -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is invalid" { + { Get-EntraUserOAuth2PermissionGrant -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return all User OAuth2Permission Grant" { - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -All + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserOAuth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All has an argument" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + { Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" } It "Should return top User OAuth2Permission Grant" { - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top 1 + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgUserOAuth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain PrincipalId" { - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" $result.PrincipalId | should -Contain "aaaaaaaa-bbbb-cccc-1111-222222222222" } - It "Should contain UserId in parameters when passed ObjectId to it" { - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" + It "Should contain UserId in parameters when passed UserId to it" { + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" } It "Property parameter should work" { - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Property ConsentType + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Property ConsentType $result | Should -Not -BeNullOrEmpty $result.ConsentType | Should -Be "Principal" @@ -90,13 +99,13 @@ Describe "Get-EntraUserOAuth2PermissionGrant" { } It "Should fail when Property is empty" { - { Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOAuth2PermissionGrant" - $result = Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result = Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserOAuth2PermissionGrant" @@ -114,7 +123,7 @@ Describe "Get-EntraUserOAuth2PermissionGrant" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraUserOAuth2PermissionGrant -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Debug } | Should -Not -Throw + { Get-EntraUserOAuth2PermissionGrant -UserId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraUserManager.Tests.ps1 b/test/module/Entra/Remove-EntraUserManager.Tests.ps1 index 29d6baee0..ddc2f3c83 100644 --- a/test/module/Entra/Remove-EntraUserManager.Tests.ps1 +++ b/test/module/Entra/Remove-EntraUserManager.Tests.ps1 @@ -14,20 +14,25 @@ BeforeAll { Describe "Remove-EntraUserManager" { Context "Test for Remove-EntraUserManager" { It "Should return empty object" { + $result = Remove-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgUserManagerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgUserManagerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string" { - { Remove-EntraUserManager -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string" { + { Remove-EntraUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Remove-EntraUserManager -ObjectId } | Should -Throw "Missing an argument for parameter*" + It "Should fail when UserId is empty" { + { Remove-EntraUserManager -UserId } | Should -Throw "Missing an argument for parameter*" } - It "Should contain Id in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { Mock -CommandName Remove-MgUserManagerByRef -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Remove-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.userId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -36,7 +41,7 @@ Describe "Remove-EntraUserManager" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraUserManager" - Remove-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + Remove-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraUserManager" @@ -53,7 +58,7 @@ Describe "Remove-EntraUserManager" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Remove-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Revoke-EntraUserAllRefreshToken.Tests.ps1 b/test/module/Entra/Revoke-EntraUserAllRefreshToken.Tests.ps1 index 9e919b79f..96f8afde1 100644 --- a/test/module/Entra/Revoke-EntraUserAllRefreshToken.Tests.ps1 +++ b/test/module/Entra/Revoke-EntraUserAllRefreshToken.Tests.ps1 @@ -14,20 +14,25 @@ BeforeAll { Describe "Revoke-EntraUserAllRefreshToken" { Context "Test for Revoke-EntraUserAllRefreshToken" { It "Should return empty object" { + $result = Revoke-EntraUserAllRefreshToken -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Revoke-MgUserSignInSession -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias" { $result = Revoke-EntraUserAllRefreshToken -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Revoke-MgUserSignInSession -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string" { - { Revoke-EntraUserAllRefreshToken -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string" { + { Revoke-EntraUserAllRefreshToken -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Revoke-EntraUserAllRefreshToken -ObjectId } | Should -Throw "Missing an argument for parameter*" + It "Should fail when UserId is empty" { + { Revoke-EntraUserAllRefreshToken -UserId } | Should -Throw "Missing an argument for parameter*" } - It "Should contain Id in parameters when passed ObjectId to it" { + It "Should contain Id in parameters when passed UserId to it" { Mock -CommandName Revoke-MgUserSignInSession -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Revoke-EntraUserAllRefreshToken -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Revoke-EntraUserAllRefreshToken -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.userId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -35,7 +40,7 @@ Describe "Revoke-EntraUserAllRefreshToken" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Revoke-EntraUserAllRefreshToken" - Revoke-EntraUserAllRefreshToken -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + Revoke-EntraUserAllRefreshToken -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Revoke-EntraUserAllRefreshToken" @@ -52,7 +57,7 @@ Describe "Revoke-EntraUserAllRefreshToken" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Revoke-EntraUserAllRefreshToken -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Revoke-EntraUserAllRefreshToken -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraUserManager.Tests.ps1 b/test/module/Entra/Set-EntraUserManager.Tests.ps1 index 302c3f418..e7a44cb6b 100644 --- a/test/module/Entra/Set-EntraUserManager.Tests.ps1 +++ b/test/module/Entra/Set-EntraUserManager.Tests.ps1 @@ -13,28 +13,35 @@ BeforeAll { Describe "Set-EntraUserManager" { Context "Test for Set-EntraUserManager" { It "Should return specific User" { + $result = Set-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Set-MgUserManagerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific User with alias" { $result = Set-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Set-MgUserManagerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string value" { - { Set-EntraUserManager -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Set-EntraUserManager -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Set-EntraUserManager -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Set-EntraUserManager -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should fail when RefObjectId is invalid" { - { Set-EntraUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" RefObjectId ""} | Should -Throw "A positional parameter cannot be found that accepts argument*" + { Set-EntraUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" RefObjectId ""} | Should -Throw "A positional parameter cannot be found that accepts argument*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { Mock -CommandName Set-MgUserManagerByRef -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Set-EntraUserManager -ObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" + $result = Set-EntraUserManager -UserId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" $params = Get-Parameters -data $result $params.UserId | Should -Match "00001111-aaaa-2222-bbbb-3333cccc4444" } @@ -42,7 +49,7 @@ Describe "Set-EntraUserManager" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUserManager" - Set-EntraUserManager -ObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" + Set-EntraUserManager -UserId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUserManager" @@ -59,7 +66,7 @@ Describe "Set-EntraUserManager" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraUserManager -ObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw + { Set-EntraUserManager -UserId "00001111-aaaa-2222-bbbb-3333cccc4444" -RefObjectId "00001111-aaaa-2222-bbbb-3333cccc4444" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserMembership.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserMembership.Tests.ps1 index 66da2ee0d..0d3344256 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserMembership.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserMembership.Tests.ps1 @@ -33,6 +33,15 @@ BeforeAll { Describe "Get-EntraBetaUserMembership" { Context "Test for Get-EntraBetaUserMembership" { It "Should return specific user membership" { + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" + $result.AdditionalProperties.DisplayName | Should -Be "Mock-Membership" + $result.AdditionalProperties."@odata.type" | Should -Be "#microsoft.graph.group" + + Should -Invoke -CommandName Get-MgBetaUserMemberOf -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific user membership with alias" { $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" @@ -41,58 +50,58 @@ Describe "Get-EntraBetaUserMembership" { Should -Invoke -CommandName Get-MgBetaUserMemberOf -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserMembership -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraBetaUserMembership -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaUserMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is invalid" { + { Get-EntraBetaUserMembership -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return all user memberships" { - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgBetaUserMemberOf -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All is invalid" { - { Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 user memberships" { - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1 $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" Should -Invoke -CommandName Get-MgBetaUserMemberOf -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top is empty" { - { Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain ObjectId" { - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result.ObjectId | should -Be "aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" } It "Property parameter should work" { - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb' Should -Invoke -CommandName Get-MgBetaUserMemberOf -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserMembership" - $result = Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserMembership" @@ -108,7 +117,7 @@ Describe "Get-EntraBetaUserMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaUserMembership -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Get-EntraBetaUserMembership -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Remove-EntraBetaUserManager.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaUserManager.Tests.ps1 index ad571bc50..ec9a1e6f0 100644 --- a/test/module/EntraBeta/Remove-EntraBetaUserManager.Tests.ps1 +++ b/test/module/EntraBeta/Remove-EntraBetaUserManager.Tests.ps1 @@ -13,26 +13,31 @@ BeforeAll { Describe "Remove-EntraBetaUserManager" { Context "Test for Remove-EntraBetaUserManager" { It "Should return empty object" { + $result = Remove-EntraBetaUserManager -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraBetaUserManager -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaUserManager -ObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + It "Should fail when UserId is empty" { + { Remove-EntraBetaUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter*" } It "Should fail when invalid parameter is passed" { { Remove-EntraBetaUserManager -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { Mock -CommandName Remove-MgBetaUserManagerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Remove-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Remove-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaUserManager" - $result = Remove-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Remove-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaUserManager" Should -Invoke -CommandName Remove-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -47,7 +52,7 @@ Describe "Remove-EntraBetaUserManager" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaUserManager -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Remove-EntraBetaUserManager -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaUserManager.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaUserManager.Tests.ps1 index 8224c4970..904c11306 100644 --- a/test/module/EntraBeta/Set-EntraBetaUserManager.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaUserManager.Tests.ps1 @@ -13,26 +13,31 @@ BeforeAll { Describe "Set-EntraBetaUserManager"{ Context "Test for Set-EntraBetaUserManager" { It "Should return empty object"{ + $result = Set-EntraBetaUserManager -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Set-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with alias"{ $result = Set-EntraBetaUserManager -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Set-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraBetaUserManager -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty" { + { Set-EntraBetaUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should fail when invalid parameter is passed" { { Set-EntraBetaUserManager -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { Mock -CommandName Set-MgBetaUserManagerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaUserManager -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Set-EntraBetaUserManager -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result $params.UserId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaUserManager" - $result = Set-EntraBetaUserManager -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result = Set-EntraBetaUserManager -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaUserManager" Should -Invoke -CommandName Set-MgBetaUserManagerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -47,7 +52,7 @@ Describe "Set-EntraBetaUserManager"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaUserManager -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + { Set-EntraBetaUserManager -UserId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From a77b9896f42c93605488ee2d0df1da76039fa12c Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 12:31:41 +0530 Subject: [PATCH 37/64] parameter updates (#1089) * parameter updates * updates * updates * ut updates --- ...Get-EntraBetaApplicationServiceEndpoint.md | 18 ++++++++-------- .../New-EntraBetaApplicationKeyCredential.md | 14 ++++++------- ...emove-EntraBetaApplicationKeyCredential.md | 10 ++++----- .../Remove-EntraBetaApplicationOwner.md | 10 ++++----- ...-EntraBetaApplicationPasswordCredential.md | 12 +++++------ .../Get-EntraApplicationServiceEndpoint.md | 18 ++++++++-------- .../New-EntraApplicationKeyCredential.md | 14 ++++++------- .../Remove-EntraApplicationKeyCredential.md | 10 ++++----- .../Remove-EntraApplicationOwner.md | 10 ++++----- ...move-EntraApplicationPasswordCredential.md | 12 +++++------ .../Remove-EntraApplicationOwner.Tests.ps1 | 21 ++++++++++++------- ...traApplicationPasswordCredential.Tests.ps1 | 21 ++++++++++++------- 12 files changed, 90 insertions(+), 80 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationServiceEndpoint.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationServiceEndpoint.md index ab99392b4..cc092ed75 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationServiceEndpoint.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationServiceEndpoint.md @@ -24,7 +24,7 @@ Retrieve the service endpoint of an application. ```powershell Get-EntraBetaApplicationServiceEndpoint - -ObjectId + -ApplicationId [-All] [-Top ] [-Property ] @@ -46,36 +46,36 @@ Other services can use the information stored in the ServiceEndpoint entity to f ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraBetaApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraBetaApplicationServiceEndpoint -ObjectId $application.ObjectId +Get-EntraBetaApplicationServiceEndpoint -ApplicationId $application.ObjectId ``` This example demonstrates how to retrieve service endpoint of the application that is specified through the Object ID parameter. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ### Example 2: Get all service endpoints ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraBetaApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraBetaApplicationServiceEndpoint -ObjectId $application.ObjectId -All +Get-EntraBetaApplicationServiceEndpoint -ApplicationId $application.ObjectId -All ``` This example demonstrates how to retrieve all service endpoints of a specified application. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ### Example 3: Get top five service endpoints ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraBetaApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraBetaApplicationServiceEndpoint -ObjectId $application.ObjectId -Top 5 +Get-EntraBetaApplicationServiceEndpoint -ApplicationId $application.ObjectId -Top 5 ``` This example demonstrates how to retrieve five service endpoints of a specified application. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ## Parameters @@ -95,14 +95,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the object ID of the application for which the service endpoint is retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationKeyCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationKeyCredential.md index 28ed19652..8ecc2c243 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationKeyCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationKeyCredential.md @@ -26,7 +26,7 @@ Creates a key credential for an application. ```powershell New-EntraBetaApplicationKeyCredential - -ObjectId + -ApplicationId [-CustomKeyIdentifier ] [-Type ] [-Usage ] @@ -53,7 +53,7 @@ Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy $AppId = (Get-EntraApplication -Top 1).Objectid $params = @{ - ObjectId = $AppId + ApplicationId = $AppId CustomKeyIdentifier = 'EntraPowerShellKey' StartDate = '2024-03-21T14:14:14Z' Type = 'Symmetric' @@ -76,7 +76,7 @@ Value : {49, 50, 51} This example shows how to create an application key credential. -- `-ObjectId` Specifies a unique ID of an application +- `-ApplicationId` Specifies a unique ID of an application - `-CustomKeyIdentifier` Specifies a custom key ID. - `-StartDate` Specifies the time when the key becomes valid as a DateTime object. - `-Type` Specifies the type of the key. @@ -99,7 +99,7 @@ $base64Thumbprint = [System.Convert]::ToBase64String($bin) $keyid = [System.Guid]::NewGuid().ToString() $params = @{ - ObjectId = '22223333-cccc-4444-dddd-5555eeee6666' + ApplicationId = '22223333-cccc-4444-dddd-5555eeee6666' CustomKeyIdentifier = $base64Thumbprint Type = 'AsymmetricX509Cert' Usage = 'Verify' @@ -113,7 +113,7 @@ New-EntraBetaApplicationKeyCredential @params This example shows how to create an application key credential. -- `-ObjectId` Specifies a unique ID of an application +- `-ApplicationId` Specifies a unique ID of an application - `-CustomKeyIdentifier` Specifies a custom key ID. - `-StartDate` Specifies the time when the key becomes valid as a DateTime object. - `-EndDate` Specifies the time when the key becomes invalid as a DateTime object. @@ -155,14 +155,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationKeyCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationKeyCredential.md index 0f627f39e..94f17eefd 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationKeyCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationKeyCredential.md @@ -25,7 +25,7 @@ Removes a key credential from an application. ```powershell Remove-EntraBetaApplicationKeyCredential - -ObjectId + -ApplicationId -KeyId [] ``` @@ -44,7 +44,7 @@ An application can use this command along with `New-EntraBetaApplicationKeyCrede Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraBetaApplication -Filter "displayName eq ''" $params = @{ - ObjectId = $application.Id + ApplicationId = $application.Id KeyId = 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' } @@ -53,7 +53,7 @@ Remove-EntraBetaApplicationKeyCredential @params This command removes the specified key credential from the specified application. -- `-ObjectId` Specifies the ID of an application. +- `-ApplicationId` Specifies the ID of an application. - `-KeyId` Specifies a custom key ID. Use `Get-EntraBetaApplicationKeyCredential` to get the keyId details. ## Parameters @@ -74,14 +74,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationOwner.md index 61bb2a7ad..78acdbbd2 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationOwner.md @@ -27,7 +27,7 @@ Removes an owner from an application. ```powershell Remove-EntraBetaApplicationOwner -OwnerId - -ObjectId + -ApplicationId [] ``` @@ -43,7 +43,7 @@ The `Remove-EntraBetaApplicationOwner` cmdlet removes an owner from an applicati Connect-Entra -Scopes 'Application.ReadWrite.All' $Application = Get-EntraBetaApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId OwnerId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } Remove-EntraBetaApplicationOwner @params @@ -51,19 +51,19 @@ Remove-EntraBetaApplicationOwner @params This example removes the specified owner from the specified application. You can use the command `Get-EntraBetaApplication` to get application Id. -- `-ObjectId` parameter specifies the the unique identifier of a application. +- `-ApplicationId` parameter specifies the the unique identifier of a application. - `-OwnerId` parameter specifies the ID of the owner. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationPasswordCredential.md index 3bd6f6ecf..4e325b087 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaApplicationPasswordCredential.md @@ -25,7 +25,7 @@ Removes a password credential from an application. ```powershell Remove-EntraBetaApplicationPasswordCredential - -ObjectId + -ApplicationId -KeyId [] ``` @@ -41,13 +41,13 @@ The `Remove-EntraBetaApplicationPasswordCredential` cmdlet removes a password cr ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' $application = Get-EntraBetaApplication -Filter "displayName eq 'Contoso Helpdesk App'" -$KeyIDs = Get-EntraBetaApplicationPasswordCredential -ObjectId $application.Id -Remove-EntraBetaApplicationPasswordCredential -ObjectId $application.Id -KeyId $KeyIds[0].KeyId +$KeyIDs = Get-EntraBetaApplicationPasswordCredential -ApplicationId $application.Id +Remove-EntraBetaApplicationPasswordCredential -ApplicationId $application.Id -KeyId $KeyIds[0].KeyId ``` This example demonstrates how to remove the password credential for an application. -- `ObjectId` Specifies the ID of the application. Use `Get-EntraBetaApplication` to get application ObjectId value. +- `ApplicationId` Specifies the ID of the application. Use `Get-EntraBetaApplication` to get application ApplicationId value. - `KeyId` Specifies the ID of the password credential. Use `Get-EntraBetaApplicationPasswordCredential` to retrieve a specific credential details. ## Parameters @@ -68,14 +68,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of the application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationServiceEndpoint.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationServiceEndpoint.md index 6bc41ecf5..69df671ca 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationServiceEndpoint.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationServiceEndpoint.md @@ -26,7 +26,7 @@ Retrieve the service endpoint of an application. ```powershell Get-EntraApplicationServiceEndpoint - -ObjectId + -ApplicationId [-All] [-Top ] [-Property ] @@ -48,36 +48,36 @@ Other services can use the information stored in the ServiceEndpoint entity to f ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraApplicationServiceEndpoint -ObjectId $application.ObjectId +Get-EntraApplicationServiceEndpoint -ApplicationId $application.ObjectId ``` This example demonstrates how to retrieve service endpoint of the application that is specified through the Object ID parameter. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ### Example 2: Get all service endpoints ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraApplicationServiceEndpoint -ObjectId $application.ObjectId -All +Get-EntraApplicationServiceEndpoint -ApplicationId $application.ObjectId -All ``` This example demonstrates how to retrieve all service endpoints of a specified application. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ### Example 3: Get top five service endpoints ```powershell Connect-Entra -Scopes 'Application.Read.All' $application = Get-EntraApplication -Filter "DisplayName eq 'Contoso Helpdesk Application'" -Get-EntraApplicationServiceEndpoint -ObjectId $application.ObjectId -Top 5 +Get-EntraApplicationServiceEndpoint -ApplicationId $application.ObjectId -Top 5 ``` This example demonstrates how to retrieve five service endpoints of a specified application. -`-ObjectId` parameter specifies the ID of an application object in Microsoft Entra ID. +`-ApplicationId` parameter specifies the ID of an application object in Microsoft Entra ID. ## Parameters @@ -97,14 +97,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the object ID of the application for which the service endpoint is retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationKeyCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationKeyCredential.md index 9c591ba6a..1eeb592e5 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationKeyCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationKeyCredential.md @@ -27,7 +27,7 @@ Creates a key credential for an application. ```powershell New-EntraApplicationKeyCredential - -ObjectId + -ApplicationId [-CustomKeyIdentifier ] [-Type ] [-Usage ] @@ -54,7 +54,7 @@ Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy $AppId = (Get-EntraApplication -Top 1).Objectid $params = @{ - ObjectId = $AppId + ApplicationId = $AppId CustomKeyIdentifier = 'EntraPowerShellKey' StartDate = '2024-03-21T14:14:14Z' Type = 'Symmetric' @@ -77,7 +77,7 @@ Value : {49, 50, 51} This example shows how to create an application key credential. -- `-ObjectId` Specifies a unique ID of an application +- `-ApplicationId` Specifies a unique ID of an application - `-CustomKeyIdentifier` Specifies a custom key ID. - `-StartDate` Specifies the time when the key becomes valid as a DateTime object. - `-Type` Specifies the type of the key. @@ -100,7 +100,7 @@ $base64Thumbprint = [System.Convert]::ToBase64String($bin) $keyid = [System.Guid]::NewGuid().ToString() $params = @{ - ObjectId = '22223333-cccc-4444-dddd-5555eeee6666' + ApplicationId = '22223333-cccc-4444-dddd-5555eeee6666' CustomKeyIdentifier = $base64Thumbprint Type = 'AsymmetricX509Cert' Usage = 'Verify' @@ -114,7 +114,7 @@ New-EntraApplicationKeyCredential @params This example shows how to create an application key credential. -- `-ObjectId` Specifies a unique ID of an application +- `-ApplicationId` Specifies a unique ID of an application - `-CustomKeyIdentifier` Specifies a custom key ID. - `-StartDate` Specifies the time when the key becomes valid as a DateTime object. - `-EndDate` Specifies the time when the key becomes invalid as a DateTime object. @@ -156,14 +156,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationKeyCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationKeyCredential.md index 6b84a9663..0e79038fc 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationKeyCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationKeyCredential.md @@ -26,7 +26,7 @@ Removes a key credential from an application. ```powershell Remove-EntraApplicationKeyCredential - -ObjectId + -ApplicationId -KeyId [] ``` @@ -45,7 +45,7 @@ An application can use this command along with `New-EntraApplicationKeyCredentia Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq ''" $params = @{ - ObjectId = $application.Id + ApplicationId = $application.Id KeyId = 'aaaaaaaa-0b0b-1c1c-2d2d-333333333333' } @@ -54,7 +54,7 @@ Remove-EntraApplicationKeyCredential @params This command removes the specified key credential from the specified application. -- `-ObjectId` Specifies the ID of an application. +- `-ApplicationId` Specifies the ID of an application. - `-KeyId` Specifies a custom key ID. Use `Get-EntraApplicationKeyCredential` to get the keyId details. ## Parameters @@ -75,14 +75,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationOwner.md index 08dc43de7..474f34044 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationOwner.md @@ -27,7 +27,7 @@ Removes an owner from an application. ```powershell Remove-EntraApplicationOwner -OwnerId - -ObjectId + -ApplicationId [] ``` @@ -43,7 +43,7 @@ The `Remove-EntraApplicationOwner` cmdlet removes an owner from an application i Connect-Entra -Scopes 'Application.ReadWrite.All' $Application = Get-EntraApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId OwnerId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' } @@ -52,19 +52,19 @@ Remove-EntraApplicationOwner @params This example removes the specified owner from the specified application. You can use the command `Get-EntraApplication` to get application Id. -- `-ObjectId` parameter specifies the the unique identifier of a application. +- `-ApplicationId` parameter specifies the the unique identifier of a application. - `-OwnerId` parameter specifies the ID of the owner. ## Parameters -### -ObjectId +### -ApplicationId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationPasswordCredential.md index 9b69c3995..f64e20627 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraApplicationPasswordCredential.md @@ -26,7 +26,7 @@ Removes a password credential from an application. ```powershell Remove-EntraApplicationPasswordCredential - -ObjectId + -ApplicationId -KeyId [] ``` @@ -42,13 +42,13 @@ The `Remove-EntraApplicationPasswordCredential` cmdlet removes a password creden ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $application = Get-EntraApplication -Filter "displayName eq 'Contoso Helpdesk App'" -$KeyIDs = Get-EntraApplicationPasswordCredential -ObjectId $application.Id -Remove-EntraApplicationPasswordCredential -ObjectId $application.Id -KeyId $KeyIds[0].KeyId +$KeyIDs = Get-EntraApplicationPasswordCredential -ApplicationId $application.Id +Remove-EntraApplicationPasswordCredential -ApplicationId $application.Id -KeyId $KeyIds[0].KeyId ``` This example demonstrates how to remove the password credential for an application. -- `ObjectId` Specifies the ID of the application. Use `Get-EntraApplication` to get application ObjectId value. +- `ApplicationId` Specifies the ID of the application. Use `Get-EntraApplication` to get application ObjectId value. - `KeyId` Specifies the ID of the password credential. Use `Get-EntraApplicationPasswordCredential` to retrieve a specific credential details. ## Parameters @@ -69,14 +69,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies the ID of the application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 index e09af7a59..97fbc3515 100644 --- a/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 @@ -11,32 +11,37 @@ BeforeAll { } Describe "Remove-EntraApplicationOwner"{ + It "Should return empty object" { + $result = Remove-EntraApplicationOwner -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } It "Should return empty object" { $result = Remove-EntraApplicationOwner -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraApplicationOwner -ObjectId "" } + It "Should fail when ApplicationId is empty" { + { Remove-EntraApplicationOwner -ApplicationId "" } } - It "Should fail when -OwnerId is empty" { + It "Should fail when OwnerId is empty" { { Remove-EntraApplicationOwner -OwnerId "" } } - It "Should contain DeviceId in parameters" { + It "Should contain ApplicationId in parameters" { Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraApplicationOwner -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result = Remove-EntraApplicationOwner -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" } It "Should contain DirectoryObjectId in parameters" { Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraApplicationOwner -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result = Remove-EntraApplicationOwner -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" $params = Get-Parameters -data $result $params.DirectoryObjectId | Should -Be "bbbbbbbb-cccc-dddd-2222-333333333333" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationOwner" - $result = Remove-EntraApplicationOwner -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result = Remove-EntraApplicationOwner -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationOwner" Should -Invoke -CommandName Remove-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -51,7 +56,7 @@ Describe "Remove-EntraApplicationOwner"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraApplicationOwner -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" -Debug } | Should -Not -Throw + { Remove-EntraApplicationOwner -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -OwnerId "bbbbbbbb-cccc-dddd-2222-333333333333" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 index 6b48b4803..88efef512 100644 --- a/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 @@ -12,15 +12,20 @@ BeforeAll { Describe "Remove-EntraApplicationPasswordCredential"{ It "Should return empty object" { + $result = Remove-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object with alias" { $result = Remove-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Remove-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { Remove-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { Remove-EntraApplicationPasswordCredential -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { Remove-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { Remove-EntraApplicationPasswordCredential -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when KeyId is empty" { { Remove-EntraApplicationPasswordCredential -KeyId "" } | Should -Throw "Cannot bind argument to parameter 'KeyId'*" @@ -31,15 +36,15 @@ Describe "Remove-EntraApplicationPasswordCredential"{ It "Should fail when invalid parameter is passed" { { Remove-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { Mock -CommandName Remove-MgApplicationPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Remove-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result = Remove-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationPasswordCredential" - $result = Remove-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" + $result = Remove-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationPasswordCredential" Should -Invoke -CommandName Remove-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -54,7 +59,7 @@ Describe "Remove-EntraApplicationPasswordCredential"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraApplicationPasswordCredential -ObjectId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" -Debug } | Should -Not -Throw + { Remove-EntraApplicationPasswordCredential -ApplicationId "aaaaaaaa-bbbb-cccc-1111-222222222222" -KeyId "bbbbbbbb-cccc-dddd-2222-333333333333" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From dd01405ea79884b63e2f08b0686e297c19e74483 Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 13:19:01 +0530 Subject: [PATCH 38/64] parameter updates (#1095) * parameter updates * updates * updates * updates * UT updates --- .../New-EntraBetaAttributeSet.ps1 | 45 ++++++++++++- .../Set-EntraBetaAttributeSet.ps1 | 64 ++++--------------- .../Get-EntraBetaAttributeSet.md | 10 +-- .../Get-EntraBetaContactDirectReport.md | 18 +++--- .../Get-EntraBetaContactMembership.md | 12 ++-- .../Get-EntraBetaDeletedDirectoryObject.md | 10 +-- .../Get-EntraBetaUserThumbnailPhoto.md | 12 ++-- ...w-EntraBetaApplicationExtensionProperty.md | 18 +++--- .../New-EntraBetaAttributeSet.md | 10 +-- .../Set-EntraBetaAttributeSet.md | 16 ++--- .../Set-EntraBetaUserThumbnailPhoto.md | 16 ++--- .../Get-EntraContactDirectReport.md | 18 +++--- .../Get-EntraContactMembership.md | 12 ++-- .../Get-EntraDeletedDirectoryObject.md | 10 +-- .../Get-EntraUserThumbnailPhoto.md | 12 ++-- .../New-EntraApplicationExtensionProperty.md | 18 +++--- .../Set-EntraUserThumbnailPhoto.md | 16 ++--- src/CompatibilityAdapterBuilder.ps1 | 1 - .../Get-EntraContactMembership.Tests.ps1 | 39 ++++++----- ...ntraApplicationExtensionProperty.Tests.ps1 | 37 +++++++---- .../Set-EntraUserThumbnailPhoto.Tests.ps1 | 25 +++++--- .../Get-EntraBetaAttributeSet.Tests.ps1 | 32 ++++++---- .../New-EntraBetaAttributeSet.Tests.ps1 | 26 +++++--- .../Set-EntraBetaAttributeSet.Tests.ps1 | 23 ++++--- 24 files changed, 278 insertions(+), 222 deletions(-) diff --git a/module/EntraBeta/customizations/New-EntraBetaAttributeSet.ps1 b/module/EntraBeta/customizations/New-EntraBetaAttributeSet.ps1 index 9c5d16974..83c30cf43 100644 --- a/module/EntraBeta/customizations/New-EntraBetaAttributeSet.ps1 +++ b/module/EntraBeta/customizations/New-EntraBetaAttributeSet.ps1 @@ -3,8 +3,51 @@ # ------------------------------------------------------------------------------ @{ SourceName = "New-AzureADMSAttributeSet" - TargetName = "New-MgBetaDirectoryAttributeSet" + TargetName = $null Parameters = $null Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] + param ( + [Alias('Id')] + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $AttributeSetId, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.Nullable`1[System.Int32]] $MaxAttributesPerSet, + [Parameter(ParameterSetName = "InvokeByDynamicParameters")] + [System.String] $Description + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand + + if ($null -ne $PSBoundParameters["AttributeSetId"]) + { + $params["Id"] = $PSBoundParameters["AttributeSetId"] + } + if ($null -ne $PSBoundParameters["MaxAttributesPerSet"]) + { + $params["MaxAttributesPerSet"] = $PSBoundParameters["MaxAttributesPerSet"] + } + if ($null -ne $PSBoundParameters["Description"]) + { + $params["Description"] = $PSBoundParameters["Description"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = New-MgBetaDirectoryAttributeSet @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + + } + } + $response + } +'@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 b/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 index 98d1da6d1..7641ebb7e 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 @@ -7,70 +7,32 @@ Parameters = $null Outputs = $null CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Alias("Id")] + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $AttributeSetId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String] $Description, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.Int32] $MaxAttributesPerSet + ) PROCESS { $params = @{} - $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - if ($null -ne $PSBoundParameters["OutVariable"]) + if ($null -ne $PSBoundParameters["AttributeSetId"]) { - $params["OutVariable"] = $PSBoundParameters["OutVariable"] - } - if($PSBoundParameters.ContainsKey("Debug")) - { - $params["Debug"] = $PSBoundParameters["Debug"] - } - if ($null -ne $PSBoundParameters["Id"]) - { - $params["AttributeSetId"] = $PSBoundParameters["Id"] - } - if ($null -ne $PSBoundParameters["PipelineVariable"]) - { - $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] - } - if ($null -ne $PSBoundParameters["InformationVariable"]) - { - $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] - } - if($PSBoundParameters.ContainsKey("Verbose")) - { - $params["Verbose"] = $PSBoundParameters["Verbose"] - } - if ($null -ne $PSBoundParameters["ProgressAction"]) - { - $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + $params["AttributeSetId"] = $PSBoundParameters["AttributeSetId"] } if ($null -ne $PSBoundParameters["Description"]) { $params["Description"] = $PSBoundParameters["Description"] } - if ($null -ne $PSBoundParameters["InformationAction"]) - { - $params["InformationAction"] = $PSBoundParameters["InformationAction"] - } if ($null -ne $PSBoundParameters["MaxAttributesPerSet"]) { $params["MaxAttributesPerSet"] = $PSBoundParameters["MaxAttributesPerSet"] } - if ($null -ne $PSBoundParameters["ErrorAction"]) - { - $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] - } - if ($null -ne $PSBoundParameters["OutBuffer"]) - { - $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] - } - if ($null -ne $PSBoundParameters["WarningAction"]) - { - $params["WarningAction"] = $PSBoundParameters["WarningAction"] - } - if ($null -ne $PSBoundParameters["ErrorVariable"]) - { - $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] - } - if ($null -ne $PSBoundParameters["WarningVariable"]) - { - $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] - } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAttributeSet.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAttributeSet.md index 3bb4f8274..8a8edb8c3 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAttributeSet.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAttributeSet.md @@ -36,7 +36,7 @@ Get-EntraBetaAttributeSet ```powershell Get-EntraBetaAttributeSet - -Id + -AttributeSetId [] ``` @@ -75,7 +75,7 @@ This example returns all attribute sets. ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' -Get-EntraBetaAttributeSet -Id 'Testing' +Get-EntraBetaAttributeSet -AttributeSetId 'Testing' ``` ```Output @@ -86,11 +86,11 @@ Testing Attributes for engineering team 10 This example demonstrates how to retrieve an attribute set by Id. -- `Id` parameter specifies the unique identifier for the attribute set within a tenant. +- `-AttributeSetId` parameter specifies the unique identifier for the attribute set within a tenant. ## Parameters -### -Id +### -AttributeSetId Unique identifier for the attribute set within a tenant. @@ -99,7 +99,7 @@ This identifier can be up to 32 characters long and may include Unicode characte ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactDirectReport.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactDirectReport.md index 9c419f47b..5e48603c8 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactDirectReport.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactDirectReport.md @@ -26,7 +26,7 @@ Get the direct reports for a contact. ```powershell Get-EntraBetaContactDirectReport - -ObjectId + -OrgContactId [-All] [-Top ] [-Property ] @@ -44,37 +44,37 @@ The `Get-EntraBetaContactDirectReport` cmdlet gets the direct reports for a cont ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraBetaContactDirectReport -ObjectId $Contact.ObjectId +Get-EntraBetaContactDirectReport -OrgContactId $Contact.ObjectId ``` This example shows how to retrieve direct reports for an organizational contact. You can use the command `Get-EntraBetaContact` to get organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 2: Get all direct reports of a contact ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraBetaContactDirectReport -ObjectId $Contact.ObjectId -All +Get-EntraBetaContactDirectReport -OrgContactId $Contact.ObjectId -All ``` This example shows how to retrieve all direct reports for an organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 3: Get top two direct reports of a contact ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraBetaContactDirectReport -ObjectId $Contact.ObjectId -Top 2 +Get-EntraBetaContactDirectReport -OrgContactId $Contact.ObjectId -Top 2 ``` This example shows how to retrieve top two direct reports for an organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ## Parameters @@ -94,14 +94,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactMembership.md index fceb80dce..4172e7400 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaContactMembership.md @@ -26,7 +26,7 @@ Get a contact membership. ```powershell Get-EntraBetaContactMembership - -ObjectId + -OrgContactId [-All] [-Top ] [-Property ] @@ -46,7 +46,7 @@ This command is useful to administrators who need to understand which groups, ro ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntrabetaContactMembership -ObjectId $Contact.ObjectId +Get-EntrabetaContactMembership -OrgContactId $Contact.ObjectId ``` ```Output @@ -64,7 +64,7 @@ This command gets all the memberships for specified contact. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntraBetaContactMembership -ObjectId $Contact.ObjectId -All +Get-EntraBetaContactMembership -OrgContactId $Contact.ObjectId -All ``` ```Output @@ -82,7 +82,7 @@ This command gets all the memberships for specified contact. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntraBetaContactMembership -ObjectId $Contact.ObjectId -Top 2 +Get-EntraBetaContactMembership -OrgContactId $Contact.ObjectId -Top 2 ``` ```Output @@ -112,14 +112,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedDirectoryObject.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedDirectoryObject.md index 5027af564..faaa9d2a7 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedDirectoryObject.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedDirectoryObject.md @@ -26,7 +26,7 @@ Retrieves a soft deleted directory object from the directory. ```powershell Get-EntraBetaDeletedDirectoryObject - -Id + -DirectoryObjectId [-Property ] [] ``` @@ -44,7 +44,7 @@ Office 365 Groups). ```powershell Connect-Entra -Scopes 'AdministrativeUnit.Read.All', 'Application.Read.All','Group.Read.All','User.Read.All' -Get-EntraBetaDeletedDirectoryObject -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaDeletedDirectoryObject -DirectoryObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -55,7 +55,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb 06-08-2024 04:23:34 This example shows how to retrieve the deleted directory object from the directory. -- `-Id` parameter specifies the Id of the directory object to retrieve. +- `-DirectoryObjectId` parameter specifies the Id of the directory object to retrieve. ### Example 2: Retrieve a deleted directory object with more details. @@ -76,14 +76,14 @@ This example shows how to retrieve the deleted directory object details from the ## Parameters -### -Id +### -DirectoryObjectId The Id of the directory object to retrieve. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserThumbnailPhoto.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserThumbnailPhoto.md index 02ab32d6d..fce5e43d6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserThumbnailPhoto.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserThumbnailPhoto.md @@ -26,7 +26,7 @@ Retrieve the thumbnail photo of a user. ```powershell Get-EntraBetaUserThumbnailPhoto - -ObjectId + -UserId [-FileName ] [-FilePath ] [-View ] @@ -43,7 +43,7 @@ Retrieve the thumbnail photo of a user. ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraBetaUserThumbnailPhoto -ObjectId 'SawyerM@contoso.com' +Get-EntraBetaUserThumbnailPhoto -UserId 'SawyerM@contoso.com' ``` ```Output @@ -52,9 +52,9 @@ Id Height Width default 292 278 ``` -This example shows how to retrieve the thumbnail photo of a user that is specified through the value of the ObejctId parameter. +This example shows how to retrieve the thumbnail photo of a user that is specified through the value of the UserId parameter. -- `-ObjectId` parameter specifies the user for which the thumbnail photo is retrieved. +- `-UserId` parameter specifies the user for which the thumbnail photo is retrieved. ## Parameters @@ -90,14 +90,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId The object ID of the user for which the thumbnail photo is retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationExtensionProperty.md index dd9c6e007..011aa08b7 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationExtensionProperty.md @@ -27,7 +27,7 @@ Creates an application extension property. ```powershell New-EntraBetaApplicationExtensionProperty - -ObjectId + -ApplicationId [-DataType ] -Name [-TargetObjects ] @@ -46,7 +46,7 @@ The `New-EntraBetaApplicationExtensionProperty` cmdlet creates an application ex Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' } @@ -61,7 +61,7 @@ DeletedDateTime Id AppDisplayName DataType Is This command creates an application extension property of the string type for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. ### Example 2: Create an extension property with data type parameter @@ -70,7 +70,7 @@ This command creates an application extension property of the string type for th Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraBetaApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' DataType = 'Boolean' } @@ -86,7 +86,7 @@ DeletedDateTime Id AppDisplayName DataType Is This command creates an application extension property of the specified data type for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. - `-DataType` parameter specifies the data type of the value the extension property can hold. @@ -98,7 +98,7 @@ $Application = Get-EntraBetaApplication -SearchString '' $targets = New-Object System.Collections.Generic.List[System.String] $targets.Add('User') $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' TargetObjects = $targets } @@ -114,7 +114,7 @@ DeletedDateTime Id AppDisplayName DataType Is The example shows how to create an application extension property with the specified target objects for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. - `-TargetObjects` parameter specifies the Microsoft Graph resources that use the extension property. All values must be in PascalCase. @@ -159,14 +159,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAttributeSet.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAttributeSet.md index 95d562a6e..2ea61015b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAttributeSet.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaAttributeSet.md @@ -28,7 +28,7 @@ Adds a new attribute set. New-EntraBetaAttributeSet [-Description ] [-MaxAttributesPerSet ] - [-Id ] + [-AttributeSetId ] [] ``` @@ -45,7 +45,7 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Testing' + AttributeSetId = 'Testing' Description = 'Attributes for engineering team' MaxAttributesPerSet = 10 } @@ -61,7 +61,7 @@ Testing Attributes for engineering team 10 This example demonstrates hoe to add a single attribute set. -- `-Id` parameter specifies the name of the attribute set. +- `-AttributeSetId` parameter specifies the name of the attribute set. - `-Description` parameter specifies the description for the attribute set. - `-MaxAttributesPerSet` parameter specifies the maximum number of custom security attributes. @@ -83,14 +83,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -AttributeSetId Name of the attribute set. Unique identifier for the attribute set within a tenant, up to 32 Unicode characters. It can't contain spaces or special characters, is case sensitive, and can't be changed later. Required. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: False Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md index b3d8f64b4..d242398d1 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md @@ -26,7 +26,7 @@ Updates an existing attribute set. ```powershell Set-EntraBetaAttributeSet - -Id + -AttributeSetId [-Description ] [-MaxAttributesPerSet ] [] @@ -34,7 +34,7 @@ Set-EntraBetaAttributeSet ## Description -Updates a Microsoft Entra ID attribute set object identified by ID. Specify `Id` parameter to update an attribute set. +Updates a Microsoft Entra ID attribute set object identified by ID. Specify `AttributeSetId` parameter to update an attribute set. You can only update the `description` and `maxAttributesPerSet` properties. @@ -47,7 +47,7 @@ In delegated scenarios with work or school accounts, the signed-in user must be ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Engineering' + AttributeSetId = 'Engineering' Description = 'Attributes for engineering team' } Set-EntraBetaAttributeSet @params @@ -55,7 +55,7 @@ Set-EntraBetaAttributeSet @params This example update an attribute set. -- `Id` parameter specifies the name of the attribute set. You can `Get-EntraBetaAttributeSet` to get more details. +- `AttributeSetId` parameter specifies the name of the attribute set. You can `Get-EntraBetaAttributeSet` to get more details. - `Description` parameter specifies the description for the attribute set. ### Example 2: Update an attribute set using MaxAttributesPerSet @@ -63,7 +63,7 @@ This example update an attribute set. ```powershell Connect-Entra -Scopes 'CustomSecAttributeDefinition.ReadWrite.All' $params = @{ - Id = 'Engineering' + AttributeSetId = 'Engineering' MaxAttributesPerSet = 10 } Set-EntraBetaAttributeSet @params @@ -71,7 +71,7 @@ Set-EntraBetaAttributeSet @params This example update an attribute set using MaxAttributesPerSet. -- `-Id` parameter specifies the name of the attribute set. You can `Get-EntraBetaAttributeSet` to get more details. +- `-AttributeSetId` parameter specifies the name of the attribute set. You can `Get-EntraBetaAttributeSet` to get more details. - `-MaxAttributesPerSet` parameter specifies the maximum number of custom security attributes. ## Parameters @@ -92,14 +92,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -AttributeSetId Name of the attribute set. Unique identifier for the attribute set within a tenant. This identifier can be up to 32 characters long and may include Unicode characters. It cannot contain spaces or special characters, and it cannot be changed later. The identifier is case insensitive. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserThumbnailPhoto.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserThumbnailPhoto.md index 7c1397712..5e7ecbbe9 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserThumbnailPhoto.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserThumbnailPhoto.md @@ -29,7 +29,7 @@ Set the thumbnail photo for a user. ```powershell Set-EntraBetaUserThumbnailPhoto -FilePath - [-ObjectId ] + [-UserId ] [] ``` @@ -38,7 +38,7 @@ Set-EntraBetaUserThumbnailPhoto ```powershell Set-EntraBetaUserThumbnailPhoto -ImageByteArray - [-ObjectId ] + [-UserId ] [] ``` @@ -47,7 +47,7 @@ Set-EntraBetaUserThumbnailPhoto ```powershell Set-EntraBetaUserThumbnailPhoto -FileStream - [-ObjectId ] + [-UserId ] [] ``` @@ -64,15 +64,15 @@ Updating any user's photo in the organization requires the User.ReadWrite.All pe ```powershell Connect-Entra -Scopes 'User.ReadWrite','User.ReadWrite.All' $params = @{ - ObjectId = 'SawyerM@contoso.com' + UserId = 'SawyerM@contoso.com' FilePath = 'D:\UserThumbnailPhoto.jpg' } Set-EntraBetaUserThumbnailPhoto @params ``` -This example sets the thumbnail photo of the user specified with the ObjectId parameter to the image specified with the FilePath parameter. +This example sets the thumbnail photo of the user specified with the UserId parameter to the image specified with the FilePath 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. - `-FilePath` parameter specifies the file path of the image to be uploaded as the user thumbnail photo. ## Parameters @@ -125,14 +125,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId The Object ID of the user for which the user thumbnail photo is set. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: False Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactDirectReport.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactDirectReport.md index 8156c820a..5ba96a392 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactDirectReport.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactDirectReport.md @@ -27,7 +27,7 @@ Get the direct reports for a contact. ```powershell Get-EntraContactDirectReport - -ObjectId + -OrgContactId [-All] [-Top ] [-Property ] @@ -45,38 +45,38 @@ The `Get-EntraContactDirectReport` cmdlet gets the direct reports for a contact. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraContactDirectReport -ObjectId $Contact.ObjectId +Get-EntraContactDirectReport -OrgContactId $Contact.ObjectId ``` This example shows how to retrieve direct reports for an organizational contact. You can use the command `Get-EntraBetaContact` to get organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 2: Get all direct reports of a contact ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraContactDirectReport -ObjectId $Contact.ObjectId -All +Get-EntraContactDirectReport -OrgContactId $Contact.ObjectId -All ``` This example shows how to retrieve all direct reports for an organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ### Example 3: Get top two direct reports of a contact ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Top 1 -Get-EntraContactDirectReport -ObjectId $Contact.ObjectId -Top 2 +Get-EntraContactDirectReport -OrgContactId $Contact.ObjectId -Top 2 ``` This example shows how to retrieve top two direct reports for an organizational contact. -- `-ObjectId` parameter specifies the contact Id. +- `-OrgContactId` parameter specifies the contact Id. ## Parameters @@ -96,14 +96,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactMembership.md index eba9f4740..e09631eec 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraContactMembership.md @@ -26,7 +26,7 @@ Get a contact membership. ```powershell Get-EntraContactMembership - -ObjectId + -OrgContactId [-All] [-Top ] [-Property ] @@ -46,7 +46,7 @@ This command is useful to administrators who need to understand which groups, ro ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntraContactMembership -ObjectId $Contact.ObjectId +Get-EntraContactMembership -OrgContactId $Contact.ObjectId ``` ```Output @@ -64,7 +64,7 @@ This command gets all the memberships for specified contact. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntraContactMembership -ObjectId $Contact.ObjectId -All +Get-EntraContactMembership -OrgContactId $Contact.ObjectId -All ``` ```Output @@ -82,7 +82,7 @@ This command gets all the memberships for specified contact. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraContact -Filter "DisplayName eq 'Contoso Contact'" -Get-EntraContactMembership -ObjectId $Contact.ObjectId -Top 2 +Get-EntraContactMembership -OrgContactId $Contact.ObjectId -Top 2 ``` ```Output @@ -112,14 +112,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -OrgContactId Specifies the ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedDirectoryObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedDirectoryObject.md index 9ca990791..099bb9947 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedDirectoryObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedDirectoryObject.md @@ -26,7 +26,7 @@ Retrieves a soft deleted directory object from the directory. ```powershell Get-EntraDeletedDirectoryObject - -Id + -DirectoryObjectId [-Property ] [] ``` @@ -43,7 +43,7 @@ Office 365 Groups). ```powershell Connect-Entra -Scopes 'AdministrativeUnit.Read.All', 'Application.Read.All','Group.Read.All','User.Read.All' -Get-EntraDeletedDirectoryObject -Id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraDeletedDirectoryObject -DirectoryObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -54,7 +54,7 @@ aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb 2/2/2024 5:33:56 AM This example shows how to retrieve the deleted directory object from the directory. -- `-Id` parameter specifies the Id of the directory object to retrieve. +- `-DirectoryObjectId` parameter specifies the Id of the directory object to retrieve. ### Example 2: Retrieve a deleted directory object with more details. @@ -75,14 +75,14 @@ This example shows how to retrieve the deleted directory object details from the ## Parameters -### -Id +### -DirectoryObjectId The Id of the directory object to retrieve. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserThumbnailPhoto.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserThumbnailPhoto.md index 2802055e5..4af5ff382 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserThumbnailPhoto.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserThumbnailPhoto.md @@ -26,7 +26,7 @@ Retrieve the thumbnail photo of a user. ```powershell Get-EntraUserThumbnailPhoto - -ObjectId + -UserId [-FileName ] [-View ] [-FilePath ] @@ -44,7 +44,7 @@ Retrieve the thumbnail photo of a user. ```powershell Connect-Entra -Scopes 'User.Read','User.Read.All' -Get-EntraUserThumbnailPhoto -ObjectId 'SawyerM@contoso.com' +Get-EntraUserThumbnailPhoto -UserId 'SawyerM@contoso.com' ``` ```Output @@ -53,9 +53,9 @@ Id Height Width default 292 278 ``` -This example shows how to retrieve the thumbnail photo of a user that is specified through the value of the ObejctId parameter. +This example shows how to retrieve the thumbnail photo of a user that is specified through the value of the UserId parameter. -- `-ObjectId` parameter specifies the user for which the thumbnail photo is retrieved. +- `-UserId` parameter specifies the user for which the thumbnail photo is retrieved. ## Parameters @@ -91,14 +91,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId The object ID of the user for which the thumbnail photo is retrieved. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationExtensionProperty.md index f8821fbf3..f82004aca 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationExtensionProperty.md @@ -27,7 +27,7 @@ Creates an application extension property. ```powershell New-EntraApplicationExtensionProperty - -ObjectId + -ApplicationId -Name [-DataType ] [-TargetObjects ] @@ -46,7 +46,7 @@ The `New-EntraApplicationExtensionProperty` cmdlet creates an application extens Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' } @@ -61,7 +61,7 @@ DeletedDateTime Id AppDisplayName DataType Is This command creates an application extension property of the string type for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. ### Example 2: Create an extension property with data type parameter @@ -70,7 +70,7 @@ This command creates an application extension property of the string type for th Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $Application = Get-EntraApplication -SearchString '' $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' DataType = 'Boolean' } @@ -86,7 +86,7 @@ DeletedDateTime Id AppDisplayName DataType Is This command creates an application extension property of the specified data type for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. - `-DataType` parameter specifies the data type of the value the extension property can hold. @@ -98,7 +98,7 @@ $Application = Get-EntraApplication -SearchString '' $targets = New-Object System.Collections.Generic.List[System.String] $targets.Add('User') $params = @{ - ObjectId = $Application.ObjectId + ApplicationId = $Application.ObjectId Name = 'NewAttribute' TargetObjects = $targets } @@ -114,7 +114,7 @@ DeletedDateTime Id AppDisplayName DataType Is The example shows how to create an application extension property with the specified target objects for the specified object. -- `-ObjectId` parameter specifies the unique identifier of an application. +- `-ApplicationId` parameter specifies the unique identifier of an application. - `-Name` parameter specifies the name of the extension property. - `-TargetObjects` parameter specifies the Microsoft Graph resources that use the extension property. All values must be in PascalCase. @@ -159,14 +159,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ApplicationId Specifies a unique ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserThumbnailPhoto.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserThumbnailPhoto.md index 5f1c74f30..1ee55c9b0 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserThumbnailPhoto.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserThumbnailPhoto.md @@ -28,7 +28,7 @@ Set the thumbnail photo for a user. ```powershell Set-EntraUserThumbnailPhoto - [-ObjectId ] + [-UserId ] -FilePath [] ``` @@ -38,7 +38,7 @@ Set-EntraUserThumbnailPhoto ```powershell Set-EntraUserThumbnailPhoto -FileStream - [-ObjectId ] + [-UserId ] [] ``` @@ -46,7 +46,7 @@ Set-EntraUserThumbnailPhoto ```powershell Set-EntraUserThumbnailPhoto - [-ObjectId ] + [-UserId ] -ImageByteArray [] ``` @@ -64,15 +64,15 @@ Updating any user's photo in the organization requires the User.ReadWrite.All pe ```powershell Connect-Entra -Scopes 'User.ReadWrite','User.ReadWrite.All' $params = @{ - ObjectId = 'SawyerM@contoso.com' + UserId = 'SawyerM@contoso.com' FilePath = 'D:\UserThumbnailPhoto.jpg' } Set-EntraUserThumbnailPhoto @params ``` -This example sets the thumbnail photo of the user specified with the ObjectId parameter to the image specified with the FilePath parameter. +This example sets the thumbnail photo of the user specified with the UserId parameter to the image specified with the FilePath 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. - `-FilePath` parameter specifies the file path of the image to be uploaded as the user thumbnail photo. ## Parameters @@ -93,14 +93,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -UserId The Object ID of the user for which the user thumbnail photo is set. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: False Position: Named diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index ad1e60d1f..edd8c6764 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -38,7 +38,6 @@ class CompatibilityAdapterBuilder { 'Get-EntraServicePrincipalDelegatedPermissionClassification', 'Set-EntraServicePrincipal', 'New-EntraConditionalAccessPolicy', - 'Set-EntraUserThumbnailPhoto', 'Reset-EntraLifeCycleGroup', 'Get-EntraObjectByObjectId', 'Remove-EntraPermissionGrantConditionSet', diff --git a/test/module/Entra/Get-EntraContactMembership.Tests.ps1 b/test/module/Entra/Get-EntraContactMembership.Tests.ps1 index 2faa9bb97..2d917c32a 100644 --- a/test/module/Entra/Get-EntraContactMembership.Tests.ps1 +++ b/test/module/Entra/Get-EntraContactMembership.Tests.ps1 @@ -11,7 +11,7 @@ BeforeAll { return @( [PSCustomObject]@{ "Id" = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" - " DeletedDateTime" = $null + "DeletedDateTime" = $null "AdditionalProperties" = @{"@odata.type" ="#microsoft.graph.group" "DisplayName" = "All Employees" "MailNickname" = "Employees" @@ -32,6 +32,15 @@ BeforeAll { Describe "Get-EntraContactMembership" { Context "Test for Get-EntraContactMembership" { It "Should return specific Contact Membership" { + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + $result.DeletedDateTime | Should -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgContactMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific Contact Membership with alias" { $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -40,48 +49,48 @@ Describe "Get-EntraContactMembership" { Should -Invoke -CommandName Get-MgContactMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is invalid" { - { Get-EntraContactMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when OrgContactId is invalid" { + { Get-EntraContactMembership -OrgContactId "" } | Should -Throw "Cannot bind argument to parameter 'OrgContactId' because it is an empty string." } It "Should return all Contact Membership" { - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -All + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -All $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgContactMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" + { Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" } It "Should return top Contact Membership" { - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top 1 + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top 1 $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgContactMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when top is empty" { - { Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when top is invalid" { - { Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top DF } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Top DF } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Result should Contain ObjectId" { - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result.ObjectId | should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } - It "Should contain OrgContactId in parameters when passed ObjectId to it" { - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + It "Should contain OrgContactId in parameters when passed OrgContactId to it" { + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $params = Get-Parameters -data $result.Parameters $params.OrgContactId | Should -Match "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" } It "Property parameter should work" { - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -89,13 +98,13 @@ Describe "Get-EntraContactMembership" { } It "Should fail when Property is empty" { - { Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraContactMembership" - $result = Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result = Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraContactMembership" @@ -113,7 +122,7 @@ Describe "Get-EntraContactMembership" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraContactMembership -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + { Get-EntraContactMembership -OrgContactId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 index 6d0cdbf7e..2ba614f4b 100644 --- a/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 +++ b/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 @@ -18,7 +18,7 @@ BeforeAll { "IsSyncedFromOnPremises" = $False "Name" = "Mock-App" "TargetObjects" = "Application" - "AdditionalProperties" = @{"@odata.context" = "https://graph.microsoft.com/v1.0/$metadata#applications('aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb')/extensionProperties/$entity"} + "AdditionalProperties" = @{"@odata.context" = "https://graph.microsoft.com/v1.0/`$metadata#applications('aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb')/extensionProperties/`$entity"} "Parameters" = $args } ) @@ -30,43 +30,52 @@ BeforeAll { Describe "New-EntraApplicationExtensionProperty" { Context "Test for New-EntraApplicationExtensionProperty" { It "Should return created MS application extension property" { - $result = New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" + $result = New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" $result.Name | Should -Be "Mock-App" $result.TargetObjects | Should -Be "Application" $result.DataType | Should -Be "MockType" + Should -Invoke -CommandName New-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return created MS application extension property with alias" { + $result = New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result.Name | Should -Be "Mock-App" + $result.TargetObjects | Should -Be "Application" + $result.DataType | Should -Be "MockType" Should -Invoke -CommandName New-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectlId is empty" { - { New-EntraApplicationExtensionProperty -ObjectId -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { New-EntraApplicationExtensionProperty -ApplicationId -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } - It "Should fail when ObjectlId is invalid" { - { New-EntraApplicationExtensionProperty -ObjectId "" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ApplicationId is invalid" { + { New-EntraApplicationExtensionProperty -ApplicationId "" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId' because it is an empty string." } It "Should fail when DataType is empty" { - { New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'DataType'*" + { New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType -Name "Mock-App" -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'DataType'*" } It "Should fail when Name is empty" { - { New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'Name'*" + { New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name -TargetObjects "Application" } | Should -Throw "Missing an argument for parameter 'Name'*" } It "Should fail when TargetObjects is empty" { - { New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects } | Should -Throw "Missing an argument for parameter 'TargetObjects'*" + { New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects } | Should -Throw "Missing an argument for parameter 'TargetObjects'*" } It "Result should Contain ObjectId" { - $result = New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" + $result = New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" $result.ObjectId | should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationExtensionProperty" - $result = New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" + $result = New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationExtensionProperty" Should -Invoke -CommandName New-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -81,7 +90,7 @@ Context "Test for New-EntraApplicationExtensionProperty" { try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraApplicationExtensionProperty -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" -Debug } | Should -Not -Throw + { New-EntraApplicationExtensionProperty -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -DataType "MockType" -Name "Mock-App" -TargetObjects "Application" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Set-EntraUserThumbnailPhoto.Tests.ps1 b/test/module/Entra/Set-EntraUserThumbnailPhoto.Tests.ps1 index 76454d2f5..dfacac310 100644 --- a/test/module/Entra/Set-EntraUserThumbnailPhoto.Tests.ps1 +++ b/test/module/Entra/Set-EntraUserThumbnailPhoto.Tests.ps1 @@ -13,28 +13,35 @@ BeforeAll { Describe "Set-EntraUserThumbnailPhoto" { Context "Test for Set-EntraUserThumbnailPhoto" { It "Should return specific User" { + $result = Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Set-MgUserPhotoContent -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should return specific User with alias" { $result = Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' $result | Should -BeNullOrEmpty Should -Invoke -CommandName Set-MgUserPhotoContent -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty string value" { - { Set-EntraUserThumbnailPhoto -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is empty string value" { + { Set-EntraUserThumbnailPhoto -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } - It "Should fail when ObjectId is empty" { - { Set-EntraUserThumbnailPhoto -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'. Specify a parameter of type 'System.String' and try again." + It "Should fail when UserId is empty" { + { Set-EntraUserThumbnailPhoto -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." } It "Should fail when RefObjectId is invalid" { - { Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" RefObjectId ""} | Should -Throw "A positional parameter cannot be found that accepts argument*" + { Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" RefObjectId ""} | Should -Throw "A positional parameter cannot be found that accepts argument*" } It "Should contain UserId in parameters when passed ObjectId to it" { Mock -CommandName Set-MgUserPhotoContent -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' + $result = Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' $params = Get-Parameters -data $result $params.UserId | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -42,7 +49,7 @@ Describe "Set-EntraUserThumbnailPhoto" { It "Should contain InFile in parameters" { Mock -CommandName Set-MgUserPhotoContent -MockWith { $args } -ModuleName Microsoft.Graph.Entra - $result = Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' + $result = Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' $params = Get-Parameters -data $result $params.InFile | Should -Match "UserThumbnailPhoto.jpg" } @@ -50,7 +57,7 @@ Describe "Set-EntraUserThumbnailPhoto" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUserThumbnailPhoto" - Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' + Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg' $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraUserThumbnailPhoto" @@ -67,7 +74,7 @@ Describe "Set-EntraUserThumbnailPhoto" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraUserThumbnailPhoto -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg'-Debug } | Should -Not -Throw + { Set-EntraUserThumbnailPhoto -UserId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -FilePath 'D:\UserThumbnailPhoto.jpg'-Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaAttributeSet.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaAttributeSet.Tests.ps1 index 449ffd30b..066681422 100644 --- a/test/module/EntraBeta/Get-EntraBetaAttributeSet.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaAttributeSet.Tests.ps1 @@ -24,7 +24,17 @@ BeforeAll { Describe "Get-EntraBetaAttributeSet" { Context "Test for Get-EntraBetaAttributeSet" { - It "Should get attribute set by Id" { + It "Should get attribute set by AttributeSetId" { + $result = Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'bbbbcccc-1111-dddd-2222-eeee3333ffff' + $result.Description | should -Be "new test" + $result.MaxAttributesPerSet | should -Be 22 + + Should -Invoke -CommandName Get-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should get attribute set using alias" { $result = Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbcccc-1111-dddd-2222-eeee3333ffff' @@ -34,28 +44,28 @@ Describe "Get-EntraBetaAttributeSet" { Should -Invoke -CommandName Get-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraBetaAttributeSet -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when AttributeSetId is empty" { + { Get-EntraBetaAttributeSet -AttributeSetId } | Should -Throw "Missing an argument for parameter 'AttributeSetId'*" } - It "Should fail when Id is invalid" { - { Get-EntraBetaAttributeSet -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when AttributeSetId is invalid" { + { Get-EntraBetaAttributeSet -AttributeSetId "" } | Should -Throw "Cannot bind argument to parameter 'AttributeSetId' because it is an empty string." } It "Result should Contain ObjectId" { - $result = Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result.ObjectId | should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" } It "Should contain AttributeSetId in parameters when passed Id to it" { - $result = Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $params = Get-Parameters -data $result.Parameters $params.AttributeSetId | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAttributeSet" - $result = Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" + $result = Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAttributeSet" Should -Invoke -CommandName Get-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -64,14 +74,14 @@ Describe "Get-EntraBetaAttributeSet" { } } It "Property parameter should work" { - $result = Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Property Id + $result = Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be 'bbbbcccc-1111-dddd-2222-eeee3333ffff' Should -Invoke -CommandName Get-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should execute successfully without throwing an error " { # Disable confirmation prompts @@ -80,7 +90,7 @@ Describe "Get-EntraBetaAttributeSet" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaAttributeSet -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw + { Get-EntraBetaAttributeSet -AttributeSetId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/New-EntraBetaAttributeSet.Tests.ps1 b/test/module/EntraBeta/New-EntraBetaAttributeSet.Tests.ps1 index a0c7110ce..d1fa542d1 100644 --- a/test/module/EntraBeta/New-EntraBetaAttributeSet.Tests.ps1 +++ b/test/module/EntraBeta/New-EntraBetaAttributeSet.Tests.ps1 @@ -25,6 +25,16 @@ BeforeAll { Describe "New-EntraBetaAttributeSet" { Context "Test for New-EntraBetaAttributeSet" { It "Should create new attribute set" { + $result = New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccc55' + $result.Description | should -Be "New AttributeSet" + $result.MaxAttributesPerSet | should -Be 21 + + Should -Invoke -CommandName New-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should create new attribute set with alias" { $result = New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 $result | Should -Not -BeNullOrEmpty $result.Id | should -Be 'bbbbbbbb-1111-2222-3333-cccccccccc55' @@ -34,31 +44,31 @@ Describe "New-EntraBetaAttributeSet" { Should -Invoke -CommandName New-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when Id is empty" { - { New-EntraBetaAttributeSet -Id -Description "New AttributeSet" -MaxAttributesPerSet 21 } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when AttributeSetId is empty" { + { New-EntraBetaAttributeSet -AttributeSetId -Description "New AttributeSet" -MaxAttributesPerSet 21 } | Should -Throw "Missing an argument for parameter 'AttributeSetId'*" } It "Should fail when Description is empty" { - { New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description -MaxAttributesPerSet 21 } | Should -Throw "Missing an argument for parameter 'Description'*" + { New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description -MaxAttributesPerSet 21 } | Should -Throw "Missing an argument for parameter 'Description'*" } It "Should fail when MaxAttributesPerSet is empty" { - { New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet } | Should -Throw "Missing an argument for parameter 'MaxAttributesPerSet'*" + { New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet } | Should -Throw "Missing an argument for parameter 'MaxAttributesPerSet'*" } It "Should fail when MaxAttributesPerSet is invalid" { - { New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet "XYZ" } | Should -Throw "Cannot process argument transformation on parameter 'MaxAttributesPerSet'*" + { New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet "XYZ" } | Should -Throw "Cannot process argument transformation on parameter 'MaxAttributesPerSet'*" } It "Result should Contain ObjectId" { - $result = New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 + $result = New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccc55" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaAttributeSet" - $result = New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 + $result = New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaAttributeSet" @@ -76,7 +86,7 @@ Describe "New-EntraBetaAttributeSet" { try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraBetaAttributeSet -Id "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 -Debug } | Should -Not -Throw + { New-EntraBetaAttributeSet -AttributeSetId "bbbbbbbb-1111-2222-3333-cccccccccc55" -Description "New AttributeSet" -MaxAttributesPerSet 21 -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaAttributeSet.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaAttributeSet.Tests.ps1 index fe688ceae..0efb9b012 100644 --- a/test/module/EntraBeta/Set-EntraBetaAttributeSet.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaAttributeSet.Tests.ps1 @@ -14,39 +14,46 @@ BeforeAll { Describe "Set-EntraBetaAttributeSet" { Context "Test for Set-EntraBetaAttributeSet" { It "Should update attribute set" { + $result = Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 + $result | Should -Be -NullOrEmpty + + Should -Invoke -CommandName Update-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should update attribute set with alias" { $result = Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 $result | Should -Be -NullOrEmpty Should -Invoke -CommandName Update-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when Id is empty" { - { Set-EntraBetaAttributeSet -Id -Description "Update AttributeSet" -MaxAttributesPerSet 22 } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when AttributeSetId is empty" { + { Set-EntraBetaAttributeSet -AttributeSetId -Description "Update AttributeSet" -MaxAttributesPerSet 22 } | Should -Throw "Missing an argument for parameter 'AttributeSetId'*" } It "Should fail when Description is empty" { - { Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description -MaxAttributesPerSet 22 } | Should -Throw "Missing an argument for parameter 'Description'*" + { Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description -MaxAttributesPerSet 22 } | Should -Throw "Missing an argument for parameter 'Description'*" } It "Should fail when MaxAttributesPerSet is empty" { - { Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet } | Should -Throw "Missing an argument for parameter 'MaxAttributesPerSet'*" + { Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet } | Should -Throw "Missing an argument for parameter 'MaxAttributesPerSet'*" } It "Should fail when MaxAttributesPerSet is invalid" { - { Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet "XYZ" } | Should -Throw "Cannot process argument transformation on parameter 'MaxAttributesPerSet'*" + { Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet "XYZ" } | Should -Throw "Cannot process argument transformation on parameter 'MaxAttributesPerSet'*" } It "Should contain AttributeSetId in parameters when passed Id to it" { Mock -CommandName Update-MgBetaDirectoryAttributeSet -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta - $result = Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 + $result = Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 $params = Get-Parameters -data $result $params.AttributeSetId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaAttributeSet" - $result = Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 + $result = Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 $result | Should -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaAttributeSet" Should -Invoke -CommandName Update-MgBetaDirectoryAttributeSet -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -62,7 +69,7 @@ Describe "Set-EntraBetaAttributeSet" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaAttributeSet -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 -Debug } | Should -Not -Throw + { Set-EntraBetaAttributeSet -AttributeSetId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Description "Update AttributeSet" -MaxAttributesPerSet 22 -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 5a1fbdfcd3eba063bb709563e7764049cd204d46 Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 13:59:31 +0530 Subject: [PATCH 39/64] parameter updates (#1101) * added Integration test cases * added Integration Testing * added Integration test cases * added EntraBetaObjectSetting * parameter updates * updates * updates * updates * updated license * updated * update --------- Co-authored-by: Ashwini Karke Co-authored-by: v-akarke <142799789+v-akarke@users.noreply.github.com> Co-authored-by: Snehal Kotwal (Perennial Systems Inc) --- .../Set-EntraBetaServicePrincipal.ps1 | 15 ++--- ...EntraBetaServicePrincipalKeyCredential.ps1 | 13 +++- .../Get-EntraBetaServicePrincipalOwner.ps1 | 63 ++++++------------- ...BetaServicePrincipalPasswordCredential.ps1 | 2 +- ...BetaServicePrincipalPasswordCredential.ps1 | 25 ++++++-- ...BetaServicePrincipalPasswordCredential.ps1 | 29 +++++---- .../Add-EntraBetaServicePrincipalOwner.md | 10 +-- .../Get-EntraBetaServicePrincipal.md | 12 ++-- ...-EntraBetaServicePrincipalCreatedObject.md | 18 +++--- ...-EntraBetaServicePrincipalKeyCredential.md | 10 +-- ...Get-EntraBetaServicePrincipalMembership.md | 18 +++--- ...taServicePrincipalOAuth2PermissionGrant.md | 18 +++--- .../Get-EntraBetaServicePrincipalOwner.md | 18 +++--- ...aBetaServicePrincipalPasswordCredential.md | 10 +-- ...aBetaServicePrincipalPasswordCredential.md | 14 ++--- .../Remove-EntraBetaServicePrincipalOwner.md | 12 ++-- ...aBetaServicePrincipalPasswordCredential.md | 10 +-- .../Set-EntraBetaServicePrincipal.md | 32 +++++----- .../Get-EntraBetaServicePrincipal.Tests.ps1 | 37 +++++++---- .../Set-EntraBetaServicePrincipal.Tests.ps1 | 21 ++++--- 20 files changed, 201 insertions(+), 186 deletions(-) diff --git a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaServicePrincipal.ps1 b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaServicePrincipal.ps1 index 3d350f6de..ab75cc3ab 100644 --- a/module/EntraBeta/AdditionalFunctions/Set-EntraBetaServicePrincipal.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Set-EntraBetaServicePrincipal.ps1 @@ -32,7 +32,8 @@ function Set-EntraBetaServicePrincipal { [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.Collections.Generic.List`1[System.String]] $Tags, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, + [Alias("ObjectId")] + [System.String] $ServicePrincipalId, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] [System.Collections.Generic.List`1[Microsoft.Open.AzureAD.Model.PasswordCredential]] $PasswordCredentials, [Parameter(ParameterSetName = "InvokeByDynamicParameters")] @@ -65,10 +66,6 @@ function Set-EntraBetaServicePrincipal { { $body["tags"] = $PSBoundParameters["Tags"] } - if($PSBoundParameters.ContainsKey("Verbose")) - { - $params["Verbose"] = $Null - } if($null -ne $PSBoundParameters["DisplayName"]) { $body["displayName"] = $PSBoundParameters["DisplayName"] @@ -77,10 +74,6 @@ function Set-EntraBetaServicePrincipal { { $body["appId"] = $PSBoundParameters["AppId"] } - if($PSBoundParameters.ContainsKey("Debug")) - { - $params["Debug"] = $Null - } if($null -ne $PSBoundParameters["ErrorUrl"]) { $body["ErrorUrl"] = $PSBoundParameters["ErrorUrl"] @@ -107,9 +100,9 @@ function Set-EntraBetaServicePrincipal { { $body["replyUrls"] = $PSBoundParameters["ReplyUrls"] } - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ServicePrincipalId"]) { - $params["Uri"] += "/$ObjectId" + $params["Uri"] += "/$ServicePrincipalId" } if($null -ne $PSBoundParameters["LogoutUrl"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalKeyCredential.ps1 b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalKeyCredential.ps1 index 46efc9e37..6d5a64453 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalKeyCredential.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalKeyCredential.ps1 @@ -7,14 +7,23 @@ Parameters = $null Outputs = $null CustomScript = @' + function Get-EntraBetaServicePrincipalKeyCredential { + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $ServicePrincipalId + ) + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - $response = (Get-MgBetaServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"]).KeyCredentials + $response = (Get-MgBetaServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"]).KeyCredentials $response | ForEach-Object { if($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name StartDate -Value StartDateTime Add-Member -InputObject $_ -MemberType AliasProperty -Name EndDate -Value EndDateTime } } - $response + $response +} '@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 index 42ab0e7b9..fb0567b4e 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 @@ -7,17 +7,27 @@ Parameters = $null Outputs = $null CustomScript = @' + function Get-EntraBetaServicePrincipalOwner { + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $ServicePrincipalId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - - if($PSBoundParameters.ContainsKey("Verbose")) - { - $params["Verbose"] = $PSBoundParameters["Verbose"] - } - if($null -ne $PSBoundParameters["ObjectId"]) + + if($null -ne $PSBoundParameters["ServicePrincipalId"]) { - $params["ServicePrincipalId"] = $PSBoundParameters["ObjectId"] + $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] } if($null -ne $PSBoundParameters["All"]) { @@ -33,42 +43,6 @@ if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] - } - if($null -ne $PSBoundParameters["WarningVariable"]) - { - $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] - } - if($null -ne $PSBoundParameters["InformationVariable"]) - { - $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] - } - if($null -ne $PSBoundParameters["InformationAction"]) - { - $params["InformationAction"] = $PSBoundParameters["InformationAction"] - } - if($null -ne $PSBoundParameters["OutVariable"]) - { - $params["OutVariable"] = $PSBoundParameters["OutVariable"] - } - if($null -ne $PSBoundParameters["OutBuffer"]) - { - $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] - } - if($null -ne $PSBoundParameters["ErrorVariable"]) - { - $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] - } - if($null -ne $PSBoundParameters["PipelineVariable"]) - { - $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] - } - if($null -ne $PSBoundParameters["ErrorAction"]) - { - $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] - } - if($null -ne $PSBoundParameters["WarningAction"]) - { - $params["WarningAction"] = $PSBoundParameters["WarningAction"] } if($null -ne $PSBoundParameters["Property"]) { @@ -94,6 +68,7 @@ } } $response - } + } +} '@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalPasswordCredential.ps1 b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalPasswordCredential.ps1 index 5649b5913..69bdfc950 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalPasswordCredential.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalPasswordCredential.ps1 @@ -8,7 +8,7 @@ Outputs = $null CustomScript = @' $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - $response = (Get-MgBetaServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ObjectId"]).PasswordCredentials + $response = (Get-MgBetaServicePrincipal -Headers $customHeaders -ServicePrincipalId $PSBoundParameters["ServicePrincipalId"]).PasswordCredentials $response | ForEach-Object { if($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name StartDate -Value StartDateTime diff --git a/module/EntraBeta/customizations/New-EntraBetaServicePrincipalPasswordCredential.ps1 b/module/EntraBeta/customizations/New-EntraBetaServicePrincipalPasswordCredential.ps1 index affba0485..532a4e606 100644 --- a/module/EntraBeta/customizations/New-EntraBetaServicePrincipalPasswordCredential.ps1 +++ b/module/EntraBeta/customizations/New-EntraBetaServicePrincipalPasswordCredential.ps1 @@ -7,18 +7,34 @@ Parameters = $null Outputs = $null CustomScript = @' + function New-EntraBetaServicePrincipalPasswordCredential { + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $CustomKeyIdentifier, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $StartDate, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $ServicePrincipalId, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Value, + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.DateTime]] $EndDate + ) + PROCESS{ $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/beta/servicePrincipals' $Method = "POST" - if($null -ne $PSBoundParameters["ObjectId"]) + if($null -ne $PSBoundParameters["ServicePrincipalId"]) { - $params["ObjectId"] = $PSBoundParameters["ObjectId"] + $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] $params["StartDate"] = $PSBoundParameters["StartDate"] $params["EndDate"] = $PSBoundParameters["EndDate"] - $URI = "$baseUri/$($params.ObjectId)/addPassword" + $URI = "$baseUri/$($params.ServicePrincipalId)/addPassword" $body = @{ passwordCredential = @{ startDateTime = $PSBoundParameters["StartDate"]; @@ -52,6 +68,7 @@ $targetTypeList += $target } $targetTypeList - } + } +} '@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 b/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 index e9d99be45..dc6b0d500 100644 --- a/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 +++ b/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 @@ -7,32 +7,35 @@ Parameters = $null Outputs = $null CustomScript = @' + function Remove-EntraBetaServicePrincipalPasswordCredential { + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $KeyId, + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $ServicePrincipalId + ) + PROCESS{ $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/beta/servicePrincipals' - $Method = "POST" - if($PSBoundParameters.ContainsKey("Verbose")) + $Method = "POST" + if($null -ne $PSBoundParameters["ServicePrincipalId"] -and $null -ne $PSBoundParameters["KeyId"]) { - $params["Verbose"] = $PSBoundParameters["Verbose"] - } - if($null -ne $PSBoundParameters["ObjectId"] -and $null -ne $PSBoundParameters["KeyId"]) - { - $params["ObjectId"] = $PSBoundParameters["ObjectId"] + $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] $params["KeyId"] = $PSBoundParameters["KeyId"] - $URI = "$baseUri/$($params.ObjectId)/removePassword" + $URI = "$baseUri/$($params.ServicePrincipalId)/removePassword" $body = @{ "keyId" = $($params.KeyId) } } - if($PSBoundParameters.ContainsKey("Debug")) - { - $params["Debug"] = $PSBoundParameters["Debug"] - } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") (Invoke-GraphRequest -Headers $customHeaders -Uri $URI -Method $Method -Body $body) - } + } +} '@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaServicePrincipalOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaServicePrincipalOwner.md index 5f6e2600c..d961ad459 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaServicePrincipalOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaServicePrincipalOwner.md @@ -25,7 +25,7 @@ Adds an owner to a service principal. ```powershell Add-EntraBetaServicePrincipalOwner - -ObjectId + -ServicePrincipalId -RefObjectId [] ``` @@ -43,7 +43,7 @@ Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy $ServicePrincipalId = (Get-EntraBetaServicePrincipal -Top 1).ObjectId $OwnerId = (Get-EntraBetaUser -Top 1).ObjectId $Params = @{ - ObjectId = $ServicePrincipalId + ServicePrincipalId = $ServicePrincipalId RefObjectId = $OwnerId } Add-EntraBetaServicePrincipalOwner @Params @@ -51,19 +51,19 @@ Add-EntraBetaServicePrincipalOwner @Params This example demonstrates how to add an owner to a service principal. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. - `-RefObjectId` parameter specifies the user object Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipal.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipal.md index 558ad2c2d..d843d2b49 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipal.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipal.md @@ -49,7 +49,7 @@ Get-EntraBetaServicePrincipal ```powershell Get-EntraBetaServicePrincipal - -ObjectId + -ServicePrincipalId [-All] [-Property ] [] @@ -78,11 +78,11 @@ ProvisioningPowerBi cccccccc-2222-3333-4444-dddddddddddd 2222333 This example retrieves all service principals from the directory. -### Example 2: Retrieve a service principal by ObjectId +### Example 2: Retrieve a service principal by ServicePrincipalId ```powershell Connect-Entra -Scopes 'Application.Read.All' -Get-EntraBetaServicePrincipal -ObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraBetaServicePrincipal -ServicePrincipalId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -93,7 +93,7 @@ M365 License Manager aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb 0000111 This command retrieves specific service principal. -- `-ObjectId` Parameter specifies the ID of a service principal. +- `-ServicePrincipalId` Parameter specifies the ID of a service principal. ### Example 3: Retrieve all service principals from the directory @@ -255,14 +255,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: GetById -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalCreatedObject.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalCreatedObject.md index 543951ab9..be7c919fe 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalCreatedObject.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalCreatedObject.md @@ -27,7 +27,7 @@ Get objects created by a service principal. ```powershell Get-EntraBetaServicePrincipalCreatedObject - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -45,36 +45,36 @@ The `Get-EntraBetaServicePrincipalCreatedObject` cmdlet gets an object created b ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId ``` This example gets objects created by the service principal identified by $ServicePrincipalId. You can use the command `Get-EntraBetaServicePrincipal` to get service principal ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 2: Retrieve the all objects created by a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraBetaServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` This example demonstrates how to get the all object created by a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 3: Retrieve the top two objects created by a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalCreatedObject -ObjectId $ServicePrincipal.ObjectId -Top 2 +Get-EntraBetaServicePrincipalCreatedObject -ServicePrincipalId $ServicePrincipal.ObjectId -Top 2 ``` This example demonstrates how to get the top two object created by a specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ## Parameters @@ -94,14 +94,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalKeyCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalKeyCredential.md index 592aa30d6..fced1101a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalKeyCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalKeyCredential.md @@ -27,7 +27,7 @@ Get key credentials for a service principal. ```powershell Get-EntraBetaServicePrincipalKeyCredential - -ObjectId + -ServicePrincipalId [] ``` @@ -42,7 +42,7 @@ The `Get-EntraBetaServicePrincipalKeyCredential` cmdlet gets the key credentials ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalKeyCredential -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalKeyCredential -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -53,18 +53,18 @@ CustomKeyIdentifier DisplayName EndDateTime Key KeyId This example retrieves the key credentials for specified service principal in Microsoft Entra ID. You can use the command `Get-EntraBetaServicePrincipal` to get a service principal object Id. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of the application for which to get the password credential. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalMembership.md index c2e984202..beaa7a099 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalMembership.md @@ -27,7 +27,7 @@ Get a service principal membership. ```powershell Get-EntraBetaServicePrincipalMembership - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -45,7 +45,7 @@ The `Get-EntraBetaServicePrincipalMembership` cmdlet gets the memberships of a s ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -56,14 +56,14 @@ Id DeletedDateTime This cmdlet retrieves a specified service principal memberships in Microsoft Entra ID. You can use the command `Get-EntraBetaServicePrincipal` to get service principal ID. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 2: Retrieve all memberships of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraBetaServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -76,14 +76,14 @@ Id DeletedDateTime This command gets all memberships of a specified service principal. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ### Example 3: Retrieve top two memberships of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalMembership -ObjectId $ServicePrincipal.ObjectId -Top 2 +Get-EntraBetaServicePrincipalMembership -ServicePrincipalId $ServicePrincipal.ObjectId -Top 2 ``` ```Output @@ -96,7 +96,7 @@ Id DeletedDateTime This command gets top two memberships of a specified service principal. -- `-ObjectId` parameter specifies the service principal ID. +- `-ServicePrincipalId` parameter specifies the service principal ID. ## Parameters @@ -116,14 +116,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOAuth2PermissionGrant.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOAuth2PermissionGrant.md index 7246eda49..555ebda85 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOAuth2PermissionGrant.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOAuth2PermissionGrant.md @@ -27,7 +27,7 @@ Gets an OAuth2PermissionGrant object. ```powershell Get-EntraBetaServicePrincipalOAuth2PermissionGrant - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -45,7 +45,7 @@ The `Get-EntraBetaServicePrincipalOAuth2PermissionGrant` cmdlet gets an OAuth2Pe ```powershell Connect-Entra -Scopes 'Directory.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -56,14 +56,14 @@ A1bC2dE3f... 00001111-aaaa-2222-bbbb-3333cccc4444 AllPrinci This cmdlet retrieves a OAuth2PermissionGrant object for a service principal in Microsoft Entra ID. You can use the command `Get-EntraBetaServicePrincipal` to get service principal Id. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 2: Get all OAuth2 permission grants of a service principal ```powershell Connect-Entra -Scopes 'Directory.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ObjectId $ServicePrincipal.ObjectId -All +Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ServicePrincipalId $ServicePrincipal.ObjectId -All ``` ```Output @@ -76,14 +76,14 @@ A1bC2dE3f... 00001111-aaaa-2222-bbbb-3333cccc4444 Principal This example demonstrates how to get all OAuth2PermissionGrant objects for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 3: Get two OAuth2 permission grants of a service principal ```powershell Connect-Entra -Scopes 'Directory.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ObjectId $ServicePrincipal.ObjectId -Top 2 +Get-EntraBetaServicePrincipalOAuth2PermissionGrant -ServicePrincipalId $ServicePrincipal.ObjectId -Top 2 ``` ```Output @@ -95,7 +95,7 @@ A1bC2dE3f... 00001111-aaaa-2222-bbbb-3333cccc4444 Principal This example demonstrates how to get top two OAuth2PermissionGrant objects for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ## Parameters @@ -115,14 +115,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwner.md index 0816d5a8f..ed2ff89ad 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalOwner.md @@ -25,7 +25,7 @@ Get the owner of a service principal. ```powershell Get-EntraBetaServicePrincipalOwner - -ObjectId + -ServicePrincipalId [-All] [-Top ] [-Property ] @@ -43,7 +43,7 @@ The `Get-EntraBetaServicePrincipalOwner` cmdlet gets the owners of a service pri ```powershell Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId +Get-EntraBetaServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId ``` ```Output @@ -56,14 +56,14 @@ cccccccc-2222-3333-4444-dddddddddddd This example gets the owners of a specified service principal. You can use the comand `Get-EntraBetaServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 2: Retrieve all the owners of a service principal ```powershell Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId -All +Get-EntraBetaServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId -All ``` ```Output @@ -76,7 +76,7 @@ cccccccc-2222-3333-4444-dddddddddddd This command gets all the owners of a service principal. You can use the comand `Get-EntraBetaServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 3: Retrieve top two owners of a service principal @@ -95,7 +95,7 @@ bbbbbbbb-1111-2222-3333-cccccccccccc This command gets top two owners of a service principal. You can use the comand `Get-EntraBetaServicePrincipal` to get service principal object Id. -- `-ObjectId` parameter specifies the unique identifier of a service principal. +- `-ServicePrincipalId` parameter specifies the unique identifier of a service principal. ### Example 4: Retrieve service principal owner details @@ -103,7 +103,7 @@ This command gets top two owners of a service principal. You can use the comand Connect-Entra -Scopes 'Application.Read.All' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" # Get the owners of the service principal -$owners = Get-EntraBetaServicePrincipalOwner -ObjectId $servicePrincipal.ObjectId -All +$owners = Get-EntraBetaServicePrincipalOwner -ServicePrincipalId $servicePrincipal.ObjectId -All $result = @() # Loop through each owner and get their UserPrincipalName and DisplayName @@ -149,14 +149,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalPasswordCredential.md index 77e219f5a..b390e6da6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaServicePrincipalPasswordCredential.md @@ -27,7 +27,7 @@ Get credentials for a service principal. ```powershell Get-EntraBetaServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId [] ``` @@ -42,7 +42,7 @@ The `Get-EntraBetaServicePrincipalPasswordCredential` cmdlet gets the password c ```powershell Connect-Entra -Scopes 'Application.Read.All' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -Get-EntraBetaServicePrincipalPasswordCredential -ObjectId $ServicePrincipal.ObjectId +Get-EntraBetaServicePrincipalPasswordCredential -ServicePrincipalId $ServicePrincipal.ObjectId ``` ```Output @@ -55,18 +55,18 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This example retrieves the password credentials for specified service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the object ID of a service principal. You can use the command `Get-EntraBetaServicePrincipal` to get a service principal Id. +- `-ServicePrincipalId` parameter specifies the object ID of a service principal. You can use the command `Get-EntraBetaServicePrincipal` to get a service principal Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of the service principal for which to get password credentials. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaServicePrincipalPasswordCredential.md index f174efc8a..05dc67fc4 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaServicePrincipalPasswordCredential.md @@ -27,7 +27,7 @@ Creates a password credential for a service principal. ```powershell New-EntraBetaServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId [-EndDate ] [-StartDate ] [] @@ -45,7 +45,7 @@ The `New-EntraBetaServicePrincipalPasswordCredential` cmdlet creates a password Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId StartDate = '2024-04-21T14:14:14Z' } New-EntraBetaServicePrincipalPasswordCredential @Params @@ -67,7 +67,7 @@ EndDate : 08-08-2026 10:30:00 This example demonstrates how to create a password credential with StartDate for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-StarteDate` parameter specifies the date and time at which the password becomes valid. ### Example 2: Create a password credential with EndtDate @@ -76,7 +76,7 @@ This example demonstrates how to create a password credential with StartDate for Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId EndDate = '2030-03-21T14:14:14Z' } New-EntraBetaServicePrincipalPasswordCredential @Params @@ -98,7 +98,7 @@ EndDate : 08-08-2026 10:30:00 This example demonstrates how to create a password credential with EndDate for a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-EndDate` parameter specifies the date and time at which the password expires represented using ISO 8601 format and is always in UTC time. ## Parameters @@ -119,14 +119,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of the service principal. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalOwner.md index 27d32e6c8..97d6d0798 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalOwner.md @@ -26,7 +26,7 @@ Removes an owner from a service principal. ```powershell Remove-EntraBetaServicePrincipalOwner -OwnerId - -ObjectId + -ServicePrincipalId [] ``` @@ -41,10 +41,10 @@ The `Remove-EntraBetaServicePrincipalOwner` cmdlet removes an owner from a servi ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" -$owner = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +$owner = Get-EntraBetaUser -UserId 'SawyerM@contoso.com' $params= @{ - ObjectId = $servicePrincipal.Id + ServicePrincipalId = $servicePrincipal.Id OwnerId = $owner.Id } Remove-EntraBetaServicePrincipalOwner @params @@ -52,19 +52,19 @@ Remove-EntraBetaServicePrincipalOwner @params This example demonstrates how to remove an owner from a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the service principal Id. +- `-ServicePrincipalId` parameter specifies the service principal Id. - `-OwnerId` parameter specifies the service principal owner Id. ## Parameters -### -ObjectId +### -ServicePrincipalId Specifies the ID of a service principal. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalPasswordCredential.md index 67802a6a8..013e8b373 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaServicePrincipalPasswordCredential.md @@ -25,7 +25,7 @@ Removes a password credential from a service principal. ```powershell Remove-EntraBetaServicePrincipalPasswordCredential - -ObjectId + -ServicePrincipalId -KeyId [] ``` @@ -42,7 +42,7 @@ The `Remove-EntraBetaServicePrincipalPasswordCredential` cmdlet removes a passwo Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $ServicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq ''" $Params = @{ - ObjectId = $ServicePrincipal.ObjectId + ServicePrincipalId = $ServicePrincipal.ObjectId KeyId = 'bbbbbbbb-1c1c-2d2d-3e3e-444444444444' } Remove-EntraBetaServicePrincipalPasswordCredential @Params @@ -50,7 +50,7 @@ Remove-EntraBetaServicePrincipalPasswordCredential @Params This example demonstrates how to remove a password credential from a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ObjectId of a specified Service Principal Password Credential. +- `-ServicePrincipalId` parameter specifies the ObjectId of a specified Service Principal Password Credential. - `-KeyId` parameter specifies the unique identifier of a Password Credential. ## Parameters @@ -71,14 +71,14 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Specifies the ID of an application in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaServicePrincipal.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaServicePrincipal.md index 545849010..a0c98ba05 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaServicePrincipal.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaServicePrincipal.md @@ -26,7 +26,7 @@ Updates a service principal. ```powershell Set-EntraBetaServicePrincipal - -ObjectId + -ServicePrincipalId [-KeyCredentials ] [-Homepage ] [-AppId ] @@ -56,7 +56,7 @@ The `Set-EntraBetaServicePrincipal` cmdlet updates a service principal in Micros Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AccountEnabled = $False } Set-EntraBetaServicePrincipal @params @@ -64,7 +64,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update `AccountEnabled` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-AccountEnabled` parameter specifies indicates whether the account is enabled. ### Example 2: Update AppId and Homepage of a service principal @@ -73,7 +73,7 @@ This example demonstrates how to update `AccountEnabled` of a service principal Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AppId = '22223333-cccc-4444-dddd-5555eeee6666' Homepage = 'https://*.e-days.com/SSO/SAML2/SP/AssertionConsumer.aspx?metadata=e-days|ISV9.2|primary|z' } @@ -82,7 +82,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update `AppId` and Homepage of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-AppId` parameter specifies the application ID. - `-Homepage` parameter specifies the home page or landing page of the application. @@ -92,7 +92,7 @@ This example demonstrates how to update `AppId` and Homepage of a service princi Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId AlternativeNames = 'Service Principal Demo' DisplayName = 'NewName' } @@ -101,7 +101,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update AlternativeNames and DisplayName of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. ### Example 4: Update LogoutUrl and ReplyUrls of a service principal @@ -109,7 +109,7 @@ This example demonstrates how to update AlternativeNames and DisplayName of a se Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId LogoutUrl = 'https://securescore.office.com/SignOut' ReplyUrls = 'https://admin.contoso.com' } @@ -118,7 +118,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update LogoutUrl and ReplyUrls of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-LogoutUrl` parameter specifies the sign out URL. - `-ReplyUrls` parameter specifies the URLs that user tokens are sent to for sign in with the associated application. @@ -128,7 +128,7 @@ This example demonstrates how to update LogoutUrl and ReplyUrls of a service pri Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId ServicePrincipalType = 'Application' AppRoleAssignmentRequired = $True } @@ -137,7 +137,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update `ServicePrincipalType` and `AppRoleAssignmentRequired` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-ServicePrincipalType` parameter specifies the service principal type. - `-AppRoleAssignmentRequired` parameter specifies indicates whether an application role assignment is required. @@ -154,7 +154,7 @@ $creds.Type = 'Symmetric' $creds.Usage = 'Sign' $creds.Value = [System.Text.Encoding]::UTF8.GetBytes('A') $creds.EndDate = Get-Date -Year 2025 -Month 12 -Day 20 -Set-EntraBetaServicePrincipal -ObjectId $servicePrincipal.ObjectId -KeyCredentials $creds +Set-EntraBetaServicePrincipal -ServicePrincipalId $servicePrincipal.ObjectId -KeyCredentials $creds ``` This example demonstrates how to update KeyCredentials of a service principal in Microsoft Entra ID. @@ -167,7 +167,7 @@ Use the `New-EntraBetaServicePrincipalPasswordCredential` and `Remove-EntraBetaS Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy' $servicePrincipal = Get-EntraBetaServicePrincipal -Filter "DisplayName eq 'Entra PowerShell Service Principal'" $params = @{ - ObjectId = $servicePrincipal.ObjectId + ServicePrincipalId = $servicePrincipal.ObjectId PreferredSingleSignOnMode = 'saml' } Set-EntraBetaServicePrincipal @params @@ -175,7 +175,7 @@ Set-EntraBetaServicePrincipal @params This example demonstrates how to update `PreferredSingleSignOnMode` of a service principal in Microsoft Entra ID. -- `-ObjectId` parameter specifies the ID of a service principal. +- `-ServicePrincipalId` parameter specifies the ID of a service principal. - `-PreferredSingleSignOnMode` parameter specifies the single sign-on mode configured for this application. ## Parameters @@ -308,14 +308,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ObjectId +### -ServicePrincipalId Species the ID of a service principal in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/test/module/EntraBeta/Get-EntraBetaServicePrincipal.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaServicePrincipal.Tests.ps1 index 676adf0c1..6086ece11 100644 --- a/test/module/EntraBeta/Get-EntraBetaServicePrincipal.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaServicePrincipal.Tests.ps1 @@ -88,6 +88,19 @@ Describe "Get-EntraBetaServicePrincipal" { Should -Invoke -CommandName Get-MgBetaServicePrincipal -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } + It "Should execute successfully with Alias" { + $result = Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result.ServicePrincipalNames | Should -Be @('bbbbbbbb-1111-2222-3333-cccccccccc55') + $result.DisplayName | Should -Be "demo1" + $result.AppId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc55" + $result.AppOwnerOrganizationId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc56" + $result.SignInAudience | Should -Be "AzureADMyOrg" + $result.ServicePrincipalType | Should -Be "Application" + + Should -Invoke -CommandName Get-MgBetaServicePrincipal -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } It "Should get all service principal" { $result = Get-EntraBetaServicePrincipal -All @@ -101,7 +114,7 @@ Describe "Get-EntraBetaServicePrincipal" { } It "Should get service principal by ObjectId" { - $result = Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result = Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc59" $result.ServicePrincipalNames | Should -Be @('bbbbbbbb-1111-2222-3333-cccccccccc55') @@ -114,12 +127,12 @@ Describe "Get-EntraBetaServicePrincipal" { Should -Invoke -CommandName Get-MgBetaServicePrincipal -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaServicePrincipal -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraBetaServicePrincipal -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } - It "Should fail when ObjectId is Invalid" { - { Get-EntraBetaServicePrincipal -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when ServicePrincipalId is Invalid" { + { Get-EntraBetaServicePrincipal -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." } It "Should get top service principal" { @@ -185,12 +198,12 @@ Describe "Get-EntraBetaServicePrincipal" { } It "Should contain ObjectId in result" { - $result = Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result = Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" $result.ObjectId | should -Be "bbbbbbbb-1111-2222-3333-cccccccccc59" } It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { - $result = Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result = Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" $params = Get-Parameters -data $result.Parameters $params.ServicePrincipalId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccc59" @@ -198,7 +211,7 @@ Describe "Get-EntraBetaServicePrincipal" { } It "Should contain filter in parameters when passed SearchString to it" { - $result = Get-EntraBetaServicePrincipal -SearchString "demo1" + $result = Get-EntraBetaServicePrincipal -SearchString "demo1" $params = Get-Parameters -data $result.Parameters $params.Filter | Should -Be "publisherName eq 'demo1' or (displayName eq 'demo1' or startswith(displayName,'demo1'))" @@ -207,7 +220,7 @@ Describe "Get-EntraBetaServicePrincipal" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaServicePrincipal" - $result= Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" + $result= Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaServicePrincipal" Should -Invoke -CommandName Get-MgBetaServicePrincipal -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -217,10 +230,10 @@ Describe "Get-EntraBetaServicePrincipal" { } It "Should fail when Property is empty" { - { Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Property parameter should work" { - $result = Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Property AppDisplayName + $result = Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Property AppDisplayName $result | Should -Not -BeNullOrEmpty $result.AppDisplayName | Should -Be 'demo1' @@ -234,7 +247,7 @@ Describe "Get-EntraBetaServicePrincipal" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaServicePrincipal -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Debug } | Should -Not -Throw + { Get-EntraBetaServicePrincipal -ServicePrincipalId "bbbbbbbb-1111-2222-3333-cccccccccc59" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Set-EntraBetaServicePrincipal.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaServicePrincipal.Tests.ps1 index 5ddefa317..8cb3b211f 100644 --- a/test/module/EntraBeta/Set-EntraBetaServicePrincipal.Tests.ps1 +++ b/test/module/EntraBeta/Set-EntraBetaServicePrincipal.Tests.ps1 @@ -14,21 +14,26 @@ BeforeAll { Describe "Set-EntraBetaServicePrincipal"{ Context "Test for Set-EntraBetaServicePrincipal" { It "Should return empty object"{ - $result = Set-EntraBetaServicePrincipal -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" + $result = Set-EntraBetaServicePrincipal -ServicePrincipalId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is invalid" { - { Set-EntraBetaServicePrincipal -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should return empty object with Alias" { + $result = Set-EntraBetaServicePrincipal -ServicePrincipalId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Set-EntraBetaServicePrincipal -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ServicePrincipalId is invalid" { + { Set-EntraBetaServicePrincipal -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." + } + It "Should fail when ServicePrincipalId is empty" { + { Set-EntraBetaServicePrincipal -ServicePrincipalId } | Should -Throw "Missing an argument for parameter 'ServicePrincipalId'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaServicePrincipal" - - Set-EntraBetaServicePrincipal -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc | Out-Null + Set-EntraBetaServicePrincipal -ServicePrincipalId bbbbbbbb-1111-2222-3333-cccccccccccc | Out-Null $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaServicePrincipal" Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { $Headers.'User-Agent' | Should -Be $userAgentHeaderValue @@ -42,7 +47,7 @@ Describe "Set-EntraBetaServicePrincipal"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Set-EntraBetaServicePrincipal -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -Debug } | Should -Not -Throw + { Set-EntraBetaServicePrincipal -ServicePrincipalId bbbbbbbb-1111-2222-3333-cccccccccccc -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 8bee96b24af5884cd3b77f87fe6f226ed5a1549c Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 17:10:19 +0530 Subject: [PATCH 40/64] Paramters update 20240926 (#1114) * parameter updates * updates --- .../Add-EntraBetaLifecyclePolicyGroup.md | 10 +++--- .../Get-EntraBetaLifecyclePolicyGroup.md | 12 +++---- .../Remove-EntraBetaLifecyclePolicyGroup.md | 10 +++--- .../Add-EntraLifecyclePolicyGroup.md | 10 +++--- .../Get-EntraLifecyclePolicyGroup.md | 12 +++---- .../Remove-EntraLifecyclePolicyGroup.md | 10 +++--- .../Add-EntraLifecyclePolicyGroup.Tests.ps1 | 25 +++++++++------ .../Get-EntraDeletedDirectoryObject.Tests.ps1 | 26 ++++++++------- .../Get-EntraLifecyclePolicyGroup.Tests.ps1 | 32 +++++++++++++------ ...Remove-EntraLifecyclePolicyGroup.Tests.ps1 | 29 ++++++++++------- 10 files changed, 103 insertions(+), 73 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaLifecyclePolicyGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaLifecyclePolicyGroup.md index 1e83e119f..f2251328a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaLifecyclePolicyGroup.md @@ -27,7 +27,7 @@ Adds a group to a lifecycle policy. ```powershell Add-EntraBetaLifecyclePolicyGroup - -Id + -GroupLifecyclePolicyId -GroupId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'Office365 group'" $policy = Get-EntraBetaGroupLifecyclePolicy | Select-Object -First 1 $params = @{ - Id = $policy.Id + GroupLifecyclePolicyId = $policy.Id groupId = $group.ObjectId } Add-EntraBetaLifecyclePolicyGroup @params @@ -53,7 +53,7 @@ Add-EntraBetaLifecyclePolicyGroup @params This example adds a group to the lifecycle policy. -- `-Id` parameter specifies the ID of the Lifecycle Policy add to the group. +- `-GroupLifecyclePolicyId` parameter specifies the ID of the Lifecycle Policy add to the group. - `-GroupId` parameter specifies the ID of the group add to the Lifecycle Policy. ## Parameters @@ -74,14 +74,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the lifecycle policy object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaLifecyclePolicyGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaLifecyclePolicyGroup.md index 6444dce42..f74aea62f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaLifecyclePolicyGroup.md @@ -27,14 +27,14 @@ Retrieves the lifecycle policy object to which a group belongs. ```powershell Get-EntraBetaLifecyclePolicyGroup - -Id + -GroupId [-Property ] [] ``` ## Description -The `Get-EntraBetaLifecyclePolicyGroup` retrieves the lifecycle policy object to which a group belongs. Specify the `-Id` parameter to get the lifecycle policy object to which a group belongs. +The `Get-EntraBetaLifecyclePolicyGroup` retrieves the lifecycle policy object to which a group belongs. Specify the `-GroupId` parameter to get the lifecycle policy object to which a group belongs. ## Examples @@ -42,7 +42,7 @@ The `Get-EntraBetaLifecyclePolicyGroup` retrieves the lifecycle policy object to ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraBetaLifecyclePolicyGroup -Id 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraBetaLifecyclePolicyGroup -GroupId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -53,18 +53,18 @@ bbbbbbbb-1111-2222-3333-cccccccccccc admingroup@contoso.com 200 This example demonstrates how to retrieve lifecycle policy object by Id in Microsoft Entra ID. -- `-Id` - specifies the ID of a group. +- `-GroupId` - specifies the ID of a group. ## Parameters -### -Id +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaLifecyclePolicyGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaLifecyclePolicyGroup.md index ada9c0fe2..28de46525 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaLifecyclePolicyGroup.md @@ -27,7 +27,7 @@ Removes a group from a lifecycle policy. ```powershell Remove-EntraBetaLifecyclePolicyGroup - -Id + -GroupLifecyclePolicyId -GroupId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'Office365 group'" $policy = Get-EntraBetaLifecyclePolicyGroup -Id $group.ObjectId $params = @{ - Id = $policy.Id + GroupLifecyclePolicyId = $policy.Id GroupId = $group.ObjectId } Remove-EntraBetaLifecyclePolicyGroup @params @@ -59,7 +59,7 @@ True This example demonstrates how to remove a group from a lifecycle policy in Microsoft Entra ID with specified Id and groupId. -- `-Id` parameter specifies the lifecycle policy object ID. +- `-GroupLifecyclePolicyId` parameter specifies the lifecycle policy object ID. - `-GroupId` parameter specifies the ID of Office365 group. ## Parameters @@ -80,14 +80,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the lifecycle policy object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraLifecyclePolicyGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraLifecyclePolicyGroup.md index cfc915234..e47865efb 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraLifecyclePolicyGroup.md @@ -28,7 +28,7 @@ Adds a group to a lifecycle policy. ```powershell Add-EntraLifecyclePolicyGroup -GroupId - -Id + -GroupLifecyclePolicyId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraGroup -Filter "DisplayName eq 'Office365 group'" $policy = Get-EntraGroupLifecyclePolicy | Select-Object -First 1 $params = @{ - Id = $policy.Id + GroupLifecyclePolicyId = $policy.Id groupId = $group.ObjectId } Add-EntraLifecyclePolicyGroup @params @@ -53,7 +53,7 @@ Add-EntraLifecyclePolicyGroup @params This example adds a group to the lifecycle policy. -- `-Id` parameter specifies the ID of the Lifecycle Policy add to the group. +- `-GroupLifecyclePolicyId` parameter specifies the ID of the Lifecycle Policy add to the group. - `-GroupId` parameter specifies the ID of the group add to the Lifecycle Policy. ## Parameters @@ -74,14 +74,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the lifecycle policy object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraLifecyclePolicyGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraLifecyclePolicyGroup.md index 3cf5cac68..155549657 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraLifecyclePolicyGroup.md @@ -26,14 +26,14 @@ Retrieves the lifecycle policy object to which a group belongs. ```powershell Get-EntraLifecyclePolicyGroup - -Id + -GroupId [-Property ] [] ``` ## Description -The `Get-EntraLifecyclePolicyGroup` retrieves the lifecycle policy object to which a group belongs. Specify the `-Id` parameter to get the lifecycle policy object to which a group belongs. +The `Get-EntraLifecyclePolicyGroup` retrieves the lifecycle policy object to which a group belongs. Specify the `-GroupId` parameter to get the lifecycle policy object to which a group belongs. ## Examples @@ -41,7 +41,7 @@ The `Get-EntraLifecyclePolicyGroup` retrieves the lifecycle policy object to whi ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraLifecyclePolicyGroup -Id 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Get-EntraLifecyclePolicyGroup -GroupId 'bbbbbbbb-1111-2222-3333-cccccccccccc' ``` ```Output @@ -52,18 +52,18 @@ bbbbbbbb-1111-2222-3333-cccccccccccc admingroup@contoso.com 200 This example demonstrates how to retrieve lifecycle policy object by Id in Microsoft Entra ID. -- `-Id` - specifies the ID of a group. +- `-GroupId` - specifies the ID of a group. ## Parameters -### -Id +### -GroupId Specifies the ID of a group in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraLifecyclePolicyGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraLifecyclePolicyGroup.md index be1231965..3f1916664 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraLifecyclePolicyGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraLifecyclePolicyGroup.md @@ -28,7 +28,7 @@ Removes a group from a lifecycle policy. ```powershell Remove-EntraLifecyclePolicyGroup -GroupId - -Id + -GroupLifecyclePolicyId [] ``` @@ -45,7 +45,7 @@ Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraGroup -Filter "DisplayName eq 'Office365 group'" $policy = Get-EntraLifecyclePolicyGroup -Id $group.ObjectId $params = @{ - Id = $policy.Id + GroupLifecyclePolicyId = $policy.Id GroupId = $group.ObjectId } Remove-EntraLifecyclePolicyGroup @params @@ -59,7 +59,7 @@ True This example demonstrates how to remove a group from a lifecycle policy in Microsoft Entra ID with specified Id and groupId. -- `-Id` parameter specifies the lifecycle policy object ID. +- `-GroupLifecyclePolicyId` parameter specifies the lifecycle policy object ID. - `-GroupId` parameter specifies the ID of Office365 group. ## Parameters @@ -80,14 +80,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id +### -GroupLifecyclePolicyId Specifies the ID of the lifecycle policy object in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named diff --git a/test/module/Entra/Add-EntraLifecyclePolicyGroup.Tests.ps1 b/test/module/Entra/Add-EntraLifecyclePolicyGroup.Tests.ps1 index ed2bfc30d..fe01b7397 100644 --- a/test/module/Entra/Add-EntraLifecyclePolicyGroup.Tests.ps1 +++ b/test/module/Entra/Add-EntraLifecyclePolicyGroup.Tests.ps1 @@ -11,7 +11,7 @@ BeforeAll { return @( [PSCustomObject]@{ "Value" = "True" - "AdditionalProperties" = "{[@odata.context, https://graph.microsoft.com/v1.0/$metadata#Edm.Boolean]}" + "AdditionalProperties" = "{[@odata.context, https://graph.microsoft.com/v1.0/`$metadata#Edm.Boolean]}" "Parameters" = $args } ) @@ -23,28 +23,35 @@ BeforeAll { Describe "Add-EntraLifecyclePolicyGroup" { Context "Test for Add-EntraLifecyclePolicyGroup" { It "Should return created LifecyclePolicyGroup" { + $result = Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff + $result | Should -Not -BeNullOrEmpty" + $result.Value | should -Be "True" + + Should -Invoke -CommandName Add-MgGroupToLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return created LifecyclePolicyGroup with alias" { $result = Add-EntraLifecyclePolicyGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff $result | Should -Not -BeNullOrEmpty" $result.Value | should -Be "True" Should -Invoke -CommandName Add-MgGroupToLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is invalid" { - { Add-EntraLifecyclePolicyGroup -Id "" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string.*" + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string.*" } - It "Should fail when Id is empty" { - { Add-EntraLifecyclePolicyGroup -Id -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Missing an argument for parameter 'Id'.*" + It "Should fail when GroupLifecyclePolicyId is empty" { + { Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'.*" } It "Should fail when GroupId is invalid" { - { Add-EntraLifecyclePolicyGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string.*" + { Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string.*" } It "Should fail when GroupId is empty" { - { Add-EntraLifecyclePolicyGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'.*" + { Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'.*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraLifecyclePolicyGroup" - Add-EntraLifecyclePolicyGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" + Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraLifecyclePolicyGroup" @@ -60,7 +67,7 @@ Describe "Add-EntraLifecyclePolicyGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraLifecyclePolicyGroup -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Debug } | Should -Not -Throw + { Add-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraDeletedDirectoryObject.Tests.ps1 b/test/module/Entra/Get-EntraDeletedDirectoryObject.Tests.ps1 index bc05403bc..637d7026f 100644 --- a/test/module/Entra/Get-EntraDeletedDirectoryObject.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeletedDirectoryObject.Tests.ps1 @@ -22,26 +22,30 @@ BeforeAll { } Describe "Get-EntraDeletedDirectoryObject"{ - It "Should fail when Id is empty" { - { Get-EntraDeletedDirectoryObject -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id'*" + It "Result should return DeletedDirectoryObject using alias" { + $result = Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should fail when DirectoryObjectId is empty" { + { Get-EntraDeletedDirectoryObject -DirectoryObjectId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId'*" } - It "Should fail when Id is null" { - { Get-EntraDeletedDirectoryObject -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when DirectoryObjectId is null" { + { Get-EntraDeletedDirectoryObject -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" } It "Should fail when invalid parameter is passed" { { Get-EntraDeletedDirectoryObject -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" } It "Result should Contain ObjectId" { - $result = Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.ObjectId | should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" - } + } It "Should contain DirectoryObjectId in parameters when passed Id to it" { - $result = Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.DirectoryObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "Property parameter should work" { - $result = Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id + $result = Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" @@ -49,11 +53,11 @@ Describe "Get-EntraDeletedDirectoryObject"{ } It "Should fail when Property is empty" { - {Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + {Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedDirectoryObject" - $result = Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedDirectoryObject" Should -Invoke -CommandName Get-MgDirectoryDeletedItem -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -68,7 +72,7 @@ Describe "Get-EntraDeletedDirectoryObject"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDeletedDirectoryObject -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDeletedDirectoryObject -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Get-EntraLifecyclePolicyGroup.Tests.ps1 b/test/module/Entra/Get-EntraLifecyclePolicyGroup.Tests.ps1 index 1265ce02f..db7f87444 100644 --- a/test/module/Entra/Get-EntraLifecyclePolicyGroup.Tests.ps1 +++ b/test/module/Entra/Get-EntraLifecyclePolicyGroup.Tests.ps1 @@ -25,6 +25,18 @@ BeforeAll { Describe "Get-EntraLifecyclePolicyGroup" { Context "Test for Get-EntraLifecyclePolicyGroup" { It "Retrieve lifecycle policy object" { + $result = Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" + $result | Should -Not -BeNullOrEmpty + $result.ObjectId | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + $result.GroupLifetimeInDays | Should -Be 200 + $result.AlternateNotificationEmails | Should -Be "admingroup@contoso.com" + $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result.ManagedGroupTypes | Should -Be "All" + + Should -Invoke -CommandName Get-MgGroupLifecyclePolicyByGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Retrieve lifecycle policy object with alias" { $result = Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" $result | Should -Not -BeNullOrEmpty $result.ObjectId | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' @@ -36,22 +48,22 @@ Describe "Get-EntraLifecyclePolicyGroup" { Should -Invoke -CommandName Get-MgGroupLifecyclePolicyByGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Get-EntraLifecyclePolicyGroup -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupId is empty" { + { Get-EntraLifecyclePolicyGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when Id is invalid" { - { Get-EntraLifecyclePolicyGroup -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraLifecyclePolicyGroup -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - It "Should contain GroupId in parameters when passed Id to it" { - $result = Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" + It "Should contain GroupId in parameters when passed GroupId to it" { + $result = Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" } It "Property parameter should work" { - $result = Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Property Id + $result = Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Property Id $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" @@ -59,13 +71,13 @@ Describe "Get-EntraLifecyclePolicyGroup" { } It "Should fail when Property is empty" { - { Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraLifecyclePolicyGroup" - $result = Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" + $result = Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraLifecyclePolicyGroup" @@ -83,7 +95,7 @@ Describe "Get-EntraLifecyclePolicyGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraLifecyclePolicyGroup -Id "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Debug } | Should -Not -Throw + { Get-EntraLifecyclePolicyGroup -GroupId "11bb11bb-cc22-dd33-ee44-55ff55ff55ff" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraLifecyclePolicyGroup.Tests.ps1 b/test/module/Entra/Remove-EntraLifecyclePolicyGroup.Tests.ps1 index 141e40cc2..1b06b4cd8 100644 --- a/test/module/Entra/Remove-EntraLifecyclePolicyGroup.Tests.ps1 +++ b/test/module/Entra/Remove-EntraLifecyclePolicyGroup.Tests.ps1 @@ -21,36 +21,43 @@ BeforeAll { Describe "Remove-EntraLifecyclePolicyGroup" { Context "Test for Remove-EntraLifecyclePolicyGroup" { It "Should remove a group from a lifecycle policy" { + $result = Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" + $result.Value | Should -Be $true + + Should -Invoke -CommandName Remove-MgGroupFromLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should remove a group from a lifecycle policy with alias" { $result = Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" $result.Value | Should -Be $true Should -Invoke -CommandName Remove-MgGroupFromLifecyclePolicy -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Id is empty" { - { Remove-EntraLifecyclePolicyGroup -Id -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" } | Should -Throw "Missing an argument for parameter 'Id'*" + It "Should fail when GroupLifecyclePolicyId is empty" { + { Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'*" } - It "Should fail when Id is invalid" { - { Remove-EntraLifecyclePolicyGroup -Id "" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string." } It "Should fail when GroupId is empty" { - { Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" + { Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } It "Should fail when GroupId is invalid" { - { Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." + { Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } - It "Should contain GroupLifecyclePolicyId in parameters when passed Id to it" { - $result = Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "bea81df1-91cb-4b6e-aa79-b40888fe0b8b" + It "Should contain GroupLifecyclePolicyId in parameters when passed GroupLifecyclePolicyId to it" { + $result = Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "bea81df1-91cb-4b6e-aa79-b40888fe0b8b" $params = Get-Parameters -data $result.Parameters $params.GroupLifecyclePolicyId | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" } It "Should contain GroupId in parameters when passed GroupId to it" { - $result = Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" + $result = Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "ccccdddd-2222-eeee-3333-ffff4444aaaa" } @@ -58,7 +65,7 @@ Describe "Remove-EntraLifecyclePolicyGroup" { It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraLifecyclePolicyGroup" - Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" + Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraLifecyclePolicyGroup" @@ -74,7 +81,7 @@ Describe "Remove-EntraLifecyclePolicyGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraLifecyclePolicyGroup -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" -Debug } | Should -Not -Throw + { Remove-EntraLifecyclePolicyGroup -GroupLifecyclePolicyId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -GroupId "ccccdddd-2222-eeee-3333-ffff4444aaaa" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From 2a33e8469662b1aa5b65a793bc0cf70bdd98382d Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Thu, 26 Sep 2024 22:47:02 +0530 Subject: [PATCH 41/64] Beta_UT_ 20240926 (#1116) * added unit test cases * updates * updates * updates --- src/CompatibilityAdapterBuilder.ps1 | 1 + ...d-EntraBetaDeviceRegisteredOwner.Tests.ps1 | 85 ++++++++++ ...dd-EntraBetaDeviceRegisteredUser.Tests.ps1 | 87 ++++++++++ .../Get-EntraBetaDeletedGroup.Tests.ps1 | 149 ++++++++++++++++++ ...t-EntraBetaDeviceRegisteredOwner.Tests.ps1 | 124 +++++++++++++++ ...et-EntraBetaDeviceRegisteredUser.Tests.ps1 | 129 +++++++++++++++ ...-EntraBetaGroupAppRoleAssignment.Tests.ps1 | 133 ++++++++++++++++ ...et-EntraBetaGroupLifecyclePolicy.Tests.ps1 | 106 +++++++++++++ .../Get-EntraBetaGroupMember.Tests.ps1 | 105 ++++++++++++ ...-EntraBetaGroupAppRoleAssignment.Tests.ps1 | 111 +++++++++++++ .../Remove-EntraBetaDevice.Tests.ps1 | 64 ++++++++ ...e-EntraBetaDeviceRegisteredOwner.Tests.ps1 | 81 ++++++++++ ...ve-EntraBetaDeviceRegisteredUser.Tests.ps1 | 81 ++++++++++ ...-EntraBetaGroupAppRoleAssignment.Tests.ps1 | 69 ++++++++ .../EntraBeta/Set-EntraBetaDevice.Tests.ps1 | 64 ++++++++ ...et-EntraBetaGroupLifecyclePolicy.Tests.ps1 | 87 ++++++++++ 16 files changed, 1476 insertions(+) create mode 100644 test/module/EntraBeta/Add-EntraBetaDeviceRegisteredOwner.Tests.ps1 create mode 100644 test/module/EntraBeta/Add-EntraBetaDeviceRegisteredUser.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaDeviceRegisteredOwner.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaDeviceRegisteredUser.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaGroupAppRoleAssignment.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaGroupLifecyclePolicy.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaGroupMember.Tests.ps1 create mode 100644 test/module/EntraBeta/New-EntraBetaGroupAppRoleAssignment.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaDevice.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredOwner.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredUser.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaGroupAppRoleAssignment.Tests.ps1 create mode 100644 test/module/EntraBeta/Set-EntraBetaDevice.Tests.ps1 create mode 100644 test/module/EntraBeta/Set-EntraBetaGroupLifecyclePolicy.Tests.ps1 diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index edd8c6764..7569fd65c 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -739,6 +739,7 @@ $($Command.CustomScript) "Get-EntraApplication", "Get-EntraDeletedApplication", "Get-EntraDeletedGroup", + "Get-EntraBetaDeletedGroup", "Get-EntraRoleAssignment", "Get-EntraContact", "Get-EntraRoleDefinition", diff --git a/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredOwner.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredOwner.Tests.ps1 new file mode 100644 index 000000000..0a27c6b75 --- /dev/null +++ b/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredOwner.Tests.ps1 @@ -0,0 +1,85 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName New-MgBetaDeviceRegisteredOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Add-EntraBetaDeviceRegisteredOwner" { + Context "Test for Add-EntraBetaDeviceRegisteredOwner" { + It "Should return empty object" { + $result = Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Add-EntraBetaDeviceRegisteredOwner -DeviceId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DeviceId'.*" + } + It "Should fail when DeviceId is invalid" { + { Add-EntraBetaDeviceRegisteredOwner -DeviceId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." + } + It "Should fail when RefObjectId is empty" { + { Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + } + It "Should fail when RefObjectId is invalid" { + { Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + } + It "Should contain DeviceId in parameters when passed ObjectId to it" { + Mock -CommandName New-MgBetaDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain BodyParameter in parameters when passed RefObjectId to it" { + Mock -CommandName New-MgBetaDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $value = @{ + "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbbbbb-1111-2222-3333-cccccccccccc"} + Should -Invoke -CommandName New-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $BodyParameter.AdditionalProperties.'@odata.id' | Should -Be $value.'@odata.id' + Write-Host $BodyParameter.AdditionalProperties.'@odata.id' + $true + } + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaDeviceRegisteredOwner" + + Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaDeviceRegisteredOwner" + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + {Add-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredUser.Tests.ps1 b/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredUser.Tests.ps1 new file mode 100644 index 000000000..7cb909094 --- /dev/null +++ b/test/module/EntraBeta/Add-EntraBetaDeviceRegisteredUser.Tests.ps1 @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName New-MgBetaDeviceRegisteredUserByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Add-EntraBetaDeviceRegisteredUser" { + Context "Test for Add-EntraBetaDeviceRegisteredUser" { + It "Should return empty object" { + $result = Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Add-EntraBetaDeviceRegisteredUser -DeviceId -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'DeviceId'.*" + } + It "Should fail when DeviceId is invalid" { + { Add-EntraBetaDeviceRegisteredUser -DeviceId "" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." + } + It "Should fail when RefObjectId is empty" { + { Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" + } + It "Should fail when RefObjectId is invalid" { + { Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." + } + It "Should execute successfully with Alias" { + $result = Add-EntraBetaDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should contain DeviceId in parameters when passed DeviceId to it" { + Mock -CommandName New-MgBetaDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain BodyParameter in parameters when passed RefObjectId to it" { + Mock -CommandName New-MgBetaDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $value = @{ + "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbbbbb-1111-2222-3333-cccccccccccc"} + Should -Invoke -CommandName New-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $BodyParameter.AdditionalProperties.'@odata.id' | Should -Be $value.'@odata.id' + Write-Host $BodyParameter.AdditionalProperties.'@odata.id' + $true + } + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaDeviceRegisteredUser" + + Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaDeviceRegisteredUser" + + Should -Invoke -CommandName New-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Add-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + + } + +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 new file mode 100644 index 000000000..feabb79f0 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 @@ -0,0 +1,149 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + "DeletedDateTime" = "10-05-2024 04:27:17" + "CreatedDateTime" = "07-07-2023 14:31:41" + "DisplayName" = "Mock-App" + "MailNickname" = "Demo-Mock-App" + "GroupTypes" = "Unified" + "SecurityEnabled" = $False + "MailEnabled" = $True + "Visibility" = "Public" + "AdditionalProperties" = @{"@odata.context" = "https://graph.microsoft.com/beta/`$metadata#groups/`$entity"} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaDeletedGroup" { +Context "Test for Get-EntraBetaDeletedGroup" { + It "Should return specific Deleted Group" { + $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-App" + $result.GroupTypes | Should -Be "Unified" + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific Deleted Group with alias" { + $result = Get-EntraBetaDeletedGroup -Id "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-App" + $result.GroupTypes | Should -Be "Unified" + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DirectoryObjectId is empty" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" + } + It "Should fail when DirectoryObjectId is invalid" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId ""} | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId' because it is an empty string." + } + It "Should return All deleted groups" { + $result = Get-EntraBetaDeletedGroup -All + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when All is invalid" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + } + It "Should return top 1 deleted group" { + $result = Get-EntraBetaDeletedGroup -Top 1 + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-App" + $result.GroupTypes | Should -Be "Unified" + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when Top is empty" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when Top is invalid" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + } + It "Should return specific deleted group by filter" { + $result = Get-EntraBetaDeletedGroup -Filter "DisplayName eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.DisplayName | Should -Be "Mock-App" + $result.GroupTypes | Should -Be "Unified" + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when filter is empty" { + { Get-EntraBetaDeletedGroup -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" + } + It "Should return specific deleted groupn by SearchString" { + $result = Get-EntraBetaDeletedGroup -SearchString "Demo-Mock-App" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.MailNickname | Should -Be "Demo-Mock-App" + $result.DisplayName | Should -Be "Mock-App" + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when searchstring is empty" { + { Get-EntraBetaDeletedGroup -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" + } + It "Property parameter should work" { + $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | Should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when Property is empty" { + { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + It "Should contain DirectoryObjectId in parameters when passed Id to it" { + $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params = Get-Parameters -data $result.Parameters + $params.DirectoryObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraBetaDeletedGroup -SearchString "Demo-Mock-App" + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeletedGroup" + $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeletedGroup" + Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredOwner.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredOwner.Tests.ps1 new file mode 100644 index 000000000..3797194d1 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredOwner.Tests.ps1 @@ -0,0 +1,124 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null) { + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $PSScriptRoot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @{ + "Id" = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + "BusinessPhones" = @("425-555-0100") + "onPremisesImmutableId" = $null + "deletedDateTime" = $null + "onPremisesSyncEnabled" = $null + "OnPremisesLastSyncDateTime" = $null + "onPremisesProvisioningErrors" = @{} + "mobilePhone" = "425-555-0100" + "ExternalUserState" = $null + "ExternalUserStateChangeDateTime" = $null + "Parameters" = $args + "AdditionalProperties" = @{ + "DisplayName" = "demo" + } + } + } + + + Mock -CommandName Get-MgBetaDeviceRegisteredOwner -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaDeviceRegisteredOwner" { + Context "Test for Get-EntraBetaDeviceRegisteredOwner" { + It "Should return specific device registered owner" { + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific device registered owner with alias" { + $result = Get-EntraBetaDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" + } + It "Should fail when DeviceId is invalid" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" + } + It "Should return all device registered owner" { + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when All is invalid" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All XY } | Should -Throw "A positional parameter cannot be found that accepts argument 'xy'.*" + } + It "Should return top device registered owner" { + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when top is empty" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when top is invalid" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + } + It "Should contain DeviceId in parameters when passed Name to it" { + + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params = Get-Parameters -data $result.Parameters + $para= $params | ConvertTo-json | ConvertFrom-Json + $para.DeviceId | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeviceRegisteredOwner" + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Property parameter should work" { + $result = Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property mobilePhone + $result | Should -Not -BeNullOrEmpty + $result.mobilePhone | Should -Be '425-555-0100' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredOwner -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when Property is empty" { + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } + +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredUser.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredUser.Tests.ps1 new file mode 100644 index 000000000..75162ee24 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaDeviceRegisteredUser.Tests.ps1 @@ -0,0 +1,129 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null) { + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $PSScriptRoot "..\Common-Functions.ps1") -Force + + + $scriptblock = { + @{ + "Id" = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + "onPremisesImmutableId" = $null + "deletedDateTime" = $null + "onPremisesSyncEnabled" = $null + "OnPremisesLastSyncDateTime" = $null + "onPremisesProvisioningErrors" = @{} + "mobilePhone" = "425-555-0100" + "BusinessPhones" = @("425-555-0100") + "ExternalUserState" = $null + "ExternalUserStateChangeDateTime" = $null + "Parameters" = $args + "AdditionalProperties" = @{ + "DisplayName" = "Demo" + } + } + } + + Mock -CommandName Get-MgBetaDeviceRegisteredUser -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + + + +Describe "Get-EntraBetaDeviceRegisteredUser" { + Context "Test for Get-EntraBetaDeviceRegisteredUser" { + It "Should return specific device registered User" { + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "8542ebd1-3d49-4073-9dce-30f197c67755" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific device registered User with alias" { + $result = Get-EntraBetaDeviceRegisteredUser -ObjectId "8542ebd1-3d49-4073-9dce-30f197c67755" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Get-EntraBetaDeviceRegisteredUser -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" + } + It "Should fail when DeviceId is invalid" { + { Get-EntraBetaDeviceRegisteredUser -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" + } + It "Should return all device registered owner" { + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should return top device registered owner" { + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when top is empty" { + { Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when top is invalid" { + { Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + } + It "Should contain DeviceId in parameters when passed Name to it" { + + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params = Get-Parameters -data $result.Parameters + $Para= $params | ConvertTo-json | ConvertFrom-Json + $para.DeviceId | Should -Match "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeviceRegisteredUser" + + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params = Get-Parameters -data $result.Parameters + $a= $params | ConvertTo-json | ConvertFrom-Json + $a.headers.'User-Agent' | Should -Be $userAgentHeaderValue + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeviceRegisteredUser" + + $result = Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeviceRegisteredUser" + + Should -Invoke -CommandName Get-MgBetaDeviceRegisteredUser -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should fail when Property is empty" { + { Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + + + } + +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaGroupAppRoleAssignment.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaGroupAppRoleAssignment.Tests.ps1 new file mode 100644 index 000000000..62bc494fe --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaGroupAppRoleAssignment.Tests.ps1 @@ -0,0 +1,133 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + "AppRoleId" = "00001111-aaaa-2222-bbbb-3333cccc4444" + "CreatedDateTime" = "06-05-2024 05:42:01" + "DeletedDateTime" = $null + "PrincipalDisplayName" = "Mock-Group" + "PrincipalId" = "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + "ResourceId" = "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + "ResourceDisplayName" = "Mock-Group" + "PrincipalType" = "PrincipalType" + "AdditionalProperties" = @{} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgBetaGroupAppRoleAssignment -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaGroupAppRoleAssignment" { +Context "Test for Get-EntraBetaGroupAppRoleAssignment" { + It "Should return specific Group AppRole Assignment" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific Group AppRole Assignment with alias" { + $result = Get-EntraBetaGroupAppRoleAssignment -objectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectlId is empty" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" + } + It "Should fail when ObjectlId is invalid" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId ""} | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." + } + It "Should return All Group AppRole Assignment" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when All is invalid" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + } + It "Should return top 1 Group AppRole Assignment" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top 1 + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + $result.ResourceId | Should -Be "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when Top is empty" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + It "Should fail when Top is invalid" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + } + It "Property parameter should work" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result | Should -Not -BeNullOrEmpty + $result.PrincipalDisplayName | Should -Be 'Mock-Group' + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when Property is empty" { + { Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + It "Result should Contain GroupId" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.ObjectId | should -Be "c1NLUiFxZk6cP6Nj0RoIyGV2homdrcZNnMeMGgMswmU" + } + It "Should contain GroupId in parameters when passed Id to it" { + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $params = Get-Parameters -data $result.Parameters + $params.GroupId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroupAppRoleAssignment" + $result = Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + + } +} + \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaGroupLifecyclePolicy.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaGroupLifecyclePolicy.Tests.ps1 new file mode 100644 index 000000000..117669427 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaGroupLifecyclePolicy.Tests.ps1 @@ -0,0 +1,106 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "AlternateNotificationEmails" = "admingroup@contoso.com" + "GroupLifetimeInDays" = 200 + "Id" = "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + "ManagedGroupTypes" = "All" + "AdditionalProperties" = @{} + "Parameters" = $args + } + ) + } + Mock -CommandName Get-MgBetaGroupLifecyclePolicy -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaGroupLifecyclePolicy" { + Context "Test for Get-EntraBetaGroupLifecyclePolicy" { + It "Retrieve all groupLifecyclePolicies" { + $result = Get-EntraBetaGroupLifecyclePolicy + $result | Should -Not -BeNullOrEmpty + $result.GroupLifetimeInDays | Should -Be 200 + $result.AlternateNotificationEmails | Should -Be "admingroup@contoso.com" + $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result.ManagedGroupTypes | Should -Be "All" + + Should -Invoke -CommandName Get-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Get-EntraBetaGroupLifecyclePolicy -Id "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.GroupLifetimeInDays | Should -Be 200 + } + + It "Retrieve properties of an groupLifecyclePolicy" { + $result = Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + $result.ObjectId | should -Be '00aa00aa-bb11-cc22-dd33-44ee44ee44ee' + $result.GroupLifetimeInDays | Should -Be 200 + $result.AlternateNotificationEmails | Should -Be "admingroup@contoso.com" + $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result.ManagedGroupTypes | Should -Be "All" + + Should -Invoke -CommandName Get-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when GroupLifecyclePolicyId is empty" { + { Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'*" + } + + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string." + } + + It "Should contain GroupLifecyclePolicyId in parameters when passed GroupLifecyclePolicyId to it" { + $result = Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $params = Get-Parameters -data $result.Parameters + $params.GroupLifecyclePolicyId | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + } + + It "Property parameter should work" { + $result = Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property Id + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + + Should -Invoke -CommandName Get-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when Property is empty" { + { Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroupLifecyclePolicy" + $result = Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaGroupMember.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaGroupMember.Tests.ps1 new file mode 100644 index 000000000..d9ec4c7c1 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaGroupMember.Tests.ps1 @@ -0,0 +1,105 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ + +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null) { + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "bbbbbbbb-1111-2222-3333-cccccccccccc" + "@odata.type" = "#microsoft.graph.user" + "Description" = "test" + "AdditionalProperties" = @{ + "DisplayName" = "demo" + } + } + ) + } + + Mock -CommandName Get-MgBetaGroupMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaGroupMember" { + Context "Test for Get-EntraBetaGroupMember" { + It "Should return specific group" { + $result = Get-EntraBetaGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Contain 'bbbbbbbb-1111-2222-3333-cccccccccccc' + + Should -Invoke -CommandName Get-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when GroupId is invalid" { + { Get-EntraBetaGroupMember -GroupId "" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." + } + It "Should fail when GroupId is empty" { + { Get-EntraBetaGroupMember -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" + } + + It "Should fail when Top is empty" { + { Get-EntraBetaGroupMember -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + } + + It "Should fail when Top is invalid" { + { Get-EntraBetaGroupMember -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + } + + It "Should return all group" { + $result = Get-EntraBetaGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when All has an argument" { + { Get-EntraBetaGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'.*" + } + It "Should return top group" { + $result = @(Get-EntraBetaGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top 1) + $result | Should -Not -BeNullOrEmpty + $result | Should -HaveCount 1 + + Should -Invoke -CommandName Get-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Property parameter should work" { + $result = Get-EntraBetaGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -top 1 -Property Id + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName Get-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when Property is empty" { + { Get-EntraBetaGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaGroupMember" + $result = Get-EntraBetaGroupMember -GroupId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgBetaGroupMember -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Get-EntraBetaGroupMember -ObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/New-EntraBetaGroupAppRoleAssignment.Tests.ps1 b/test/module/EntraBeta/New-EntraBetaGroupAppRoleAssignment.Tests.ps1 new file mode 100644 index 000000000..e89b86f51 --- /dev/null +++ b/test/module/EntraBeta/New-EntraBetaGroupAppRoleAssignment.Tests.ps1 @@ -0,0 +1,111 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "00001111-aaaa-2222-bbbb-3333cccc4444" + "AppRoleId" = "bbbbbbbb-1111-2222-3333-cccccccccccc" + "CreatedDateTime" = "06-05-2024 05:42:01" + "DeletedDateTime" = $null + "PrincipalDisplayName" = "Mock-Group" + "PrincipalId" = "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + "ResourceId" = "aaaaaaaa-bbbb-cccc-1111-222222222222" + "ResourceDisplayName" = "Mock-Group" + "PrincipalType" = "PrincipalType" + "AdditionalProperties" = @{"@odata.context" = "https://graph.microsoft.com/v1.0/`$metadata#groups('aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb')/appRoleAssignments/`$entity"} + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgBetaGroupAppRoleAssignment -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "New-EntraBetaGroupAppRoleAssignment" { +Context "Test for New-EntraBetaGroupAppRoleAssignment" { + It "Should return created Group AppRole Assignment" { + $result = New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.ResourceId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName New-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return created Group AppRole Assignment with alias" { + $result = New-EntraBetaGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + $result.ResourceId | Should -Be "aaaaaaaa-bbbb-cccc-1111-222222222222" + $result.PrincipalId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result.AppRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName New-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectlId is empty" { + { New-EntraBetaGroupAppRoleAssignment -GroupId -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'GroupId'*" + } + It "Should fail when ObjectlId is invalid" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." + } + It "Should fail when PrincipalId is empty" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'PrincipalId'*" + } + It "Should fail when PrincipalId is invalid" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'PrincipalId' because it is an empty string." + } + It "Should fail when ResourceId is empty" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Missing an argument for parameter 'ResourceId'*" + } + It "Should fail when ResourceId is invalid" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" } | Should -Throw "Cannot bind argument to parameter 'ResourceId' because it is an empty string." + } + It "Should fail when Id is empty" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -AppRoleId } | Should -Throw "Missing an argument for parameter 'AppRoleId'*" + } + It "Should fail when Id is invalid" { + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -AppRoleId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleId' because it is an empty string." + } + It "Result should Contain GroupId" { + $result = New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result.ObjectId | should -Be "00001111-aaaa-2222-bbbb-3333cccc4444" + } + It "Should contain AppRoleId in parameters when passed Id to it" { + $result = New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result.Parameters + $params.AppRoleId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaGroupAppRoleAssignment" + $result = New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName New-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { New-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PrincipalId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -ResourceId "aaaaaaaa-bbbb-cccc-1111-222222222222" -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaDevice.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaDevice.Tests.ps1 new file mode 100644 index 000000000..84f7580f0 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaDevice.Tests.ps1 @@ -0,0 +1,64 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ + +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgBetaDevice -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaDevice" { + Context "Test for Remove-EntraBetaDevice" { + It "Should return empty object" { + $result = Remove-EntraBetaDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Remove-EntraBetaDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is invalid" { + { Remove-EntraBetaDevice -DeviceId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string." + } + It "Should fail when DeviceId is empty" { + { Remove-EntraBetaDevice -DeviceId } | Should -Throw "Missing an argument for parameter 'DeviceId'*" + } + It "Should contain DeviceId in parameters when passed DeviceId to it" { + Mock -CommandName Remove-MgBetaDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaDevice -DeviceId bbbbbbbb-1111-2222-3333-cccccccccccc + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaDevice" + Remove-EntraBetaDevice -DeviceId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName Remove-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Remove-EntraBetaDevice -DeviceId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredOwner.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredOwner.Tests.ps1 new file mode 100644 index 000000000..86f912b28 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredOwner.Tests.ps1 @@ -0,0 +1,81 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaDeviceRegisteredOwner" { + Context "Test for Remove-EntraBetaDeviceRegisteredOwner" { + It "Should return empty object" { + $result = Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Remove-EntraBetaDeviceRegisteredOwner -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Remove-EntraBetaDeviceRegisteredOwner -DeviceId -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'DeviceId'*" } + } + It "Should fail when DeviceId is invalid" { + { Remove-EntraBetaDeviceRegisteredOwner -DeviceId "" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } + } + It "Should fail when OwnerId is empty" { + { Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId | Should -Throw "Missing an argument for parameter 'OwnerId'*" } + } + It "Should fail when OwnerId is invalid" { + { Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "" | Should -Throw "Cannot bind argument to parameter 'OwnerId' because it is an empty string.*" } + } + It "Should contain DeviceId in parameters when passed OwnerId to it" { + Mock -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain DirectoryObjectId in parameters when passed OwnerId to it" { + Mock -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result + $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaDeviceRegisteredOwner" + + $result = Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaDeviceRegisteredOwner" + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredOwnerByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Remove-EntraBetaDeviceRegisteredOwner -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -OwnerId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredUser.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredUser.Tests.ps1 new file mode 100644 index 000000000..3fa83d4e0 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaDeviceRegisteredUser.Tests.ps1 @@ -0,0 +1,81 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgBetaDeviceRegisteredUserByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaDeviceRegisteredUser" { + Context "Test for Remove-EntraBetaDeviceRegisteredUser" { + It "Should return empty object" { + $result = Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Remove-EntraBetaDeviceRegisteredUser -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceId is empty" { + { Remove-EntraBetaDeviceRegisteredUser -DeviceId -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Missing an argument for parameter 'DeviceId'*" } + } + It "Should fail when DeviceId is invalid" { + { Remove-EntraBetaDeviceRegisteredUser -DeviceId "" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Should -Throw "Cannot bind argument to parameter 'DeviceId' because it is an empty string.*" } + } + It "Should fail when UserId is empty" { + { Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId | Should -Throw "Missing an argument for parameter 'UserId'*" } + } + It "Should fail when UserId is invalid" { + { Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "" | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string.*" } + } + It "Should contain DeviceId in parameters when passed UserId to it" { + Mock -CommandName Remove-MgBetaDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain DirectoryObjectId in parameters when passed UserId to it" { + Mock -CommandName Remove-MgBetaDeviceRegisteredUserByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $params = Get-Parameters -data $result + $params.DirectoryObjectId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaDeviceRegisteredUser" + + Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaDeviceRegisteredUser" + + Should -Invoke -CommandName Remove-MgBetaDeviceRegisteredUserByRef -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Remove-EntraBetaDeviceRegisteredUser -DeviceId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaGroupAppRoleAssignment.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaGroupAppRoleAssignment.Tests.ps1 new file mode 100644 index 000000000..56e3f7972 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaGroupAppRoleAssignment.Tests.ps1 @@ -0,0 +1,69 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgBetaGroupAppRoleAssignment -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaGroupAppRoleAssignment" { + Context "Test for Remove-EntraBetaGroupAppRoleAssignment" { + It "Should return empty object" { + $result = Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return empty object with Alias" { + $result = Remove-EntraBetaGroupAppRoleAssignment -ObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when GroupId is empty" { + { Remove-EntraBetaGroupAppRoleAssignment -GroupId -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Missing an argument for parameter 'GroupId'*" + } + It "Should fail when GroupId is invalid" { + { Remove-EntraBetaGroupAppRoleAssignment -GroupId "" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" } | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." + } + It "Should fail when AppRoleAssignmentId is empty" { + { Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId } | Should -Throw "Missing an argument for parameter 'AppRoleAssignmentId'*" + } + It "Should fail when AppRoleAssignmentId is invalid" { + { Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "" } | Should -Throw "Cannot bind argument to parameter 'AppRoleAssignmentId' because it is an empty string." + } + It "Should contain GroupId in parameters when passed GroupId to it" { + Mock -CommandName Remove-MgBetaGroupAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + $params = Get-Parameters -data $result + $params.GroupId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaGroupAppRoleAssignment" + Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" + + Should -Invoke -CommandName Remove-MgBetaGroupAppRoleAssignment -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Remove-EntraBetaGroupAppRoleAssignment -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -AppRoleAssignmentId "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Set-EntraBetaDevice.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaDevice.Tests.ps1 new file mode 100644 index 000000000..15ac91997 --- /dev/null +++ b/test/module/EntraBeta/Set-EntraBetaDevice.Tests.ps1 @@ -0,0 +1,64 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ + +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Update-MgBetaDevice -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Set-EntraBetaDevice"{ + Context "Test for Set-EntraBetaDevice" { + It "Should return empty object"{ + $result = Set-EntraBetaDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Set-EntraBetaDevice -ObjectId bbbbbbbb-1111-2222-3333-cccccccccccc -DisplayName "Mock-App" -AccountEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DeviceObjectId is invalid" { + { Set-EntraBetaDevice -DeviceObjectId "" } | Should -Throw "Cannot bind argument to parameter 'DeviceObjectId' because it is an empty string." + } + It "Should fail when DeviceObjectId is empty" { + { Set-EntraBetaDevice -DeviceObjectId } | Should -Throw "Missing an argument for parameter 'DeviceObjectId'*" + } + It "Should contain DeviceId in parameters when passed DeviceObjectId to it" { + Mock -CommandName Update-MgBetaDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + + $result = Set-EntraBetaDevice -DeviceObjectId bbbbbbbb-1111-2222-3333-cccccccccccc + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaDevice" + Set-EntraBetaDevice -DeviceObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + + Should -Invoke -CommandName Update-MgBetaDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Set-EntraBetaDevice -DeviceObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Set-EntraBetaGroupLifecyclePolicy.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaGroupLifecyclePolicy.Tests.ps1 new file mode 100644 index 000000000..b68e04219 --- /dev/null +++ b/test/module/EntraBeta/Set-EntraBetaGroupLifecyclePolicy.Tests.ps1 @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +# ------------------------------------------------------------------------------ +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null) { + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" + "AlternateNotificationEmails" = "admingroup@contoso.com" + "GroupLifetimeInDays" = "100" + "ManagedGroupTypes" = "All" + "Parameters" = $args + } + ) + } + + Mock -CommandName Update-MgBetaGroupLifecyclePolicy -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Set-EntraBetaGroupLifecyclePolicy" { + Context "Test for Set-EntraBetaGroupLifecyclePolicy" { + It "Should return updated GroupLifecyclePolicy" { + $result = Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" + $result.GroupLifetimeInDays | should -Be "100" + $result.ManagedGroupTypes | should -Be "All" + $result.AlternateNotificationEmails | should -Be "admingroup@contoso.com" + + Should -Invoke -CommandName Update-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should execute successfully with Alias" { + $result = Set-EntraBetaGroupLifecyclePolicy -Id "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result | Should -Not -BeNullOrEmpty + } + It "Should fail when GroupLifecyclePolicyId is invalid" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot bind argument to parameter 'GroupLifecyclePolicyId' because it is an empty string.*" + } + It "Should fail when GroupLifecyclePolicyId is empty" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'GroupLifecyclePolicyId'.*" + } + It "Should fail when GroupLifetimeInDays is invalid" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays a -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Cannot process argument transformation on parameter 'GroupLifetimeInDays'.*" + } + It "Should fail when GroupLifetimeInDays is empty" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays -ManagedGroupTypes "Selected" -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'GroupLifetimeInDays'.*" + } + It "Should fail when ManagedGroupTypes is empty" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes -AlternateNotificationEmails "example@contoso.com" } | Should -Throw "Missing an argument for parameter 'ManagedGroupTypes'.*" + } + It "Should fail when AlternateNotificationEmails is empty" { + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 99 -ManagedGroupTypes "Selected" -AlternateNotificationEmails } | Should -Throw "Missing an argument for parameter 'AlternateNotificationEmails'.*" + } + It "Result should Contain ObjectId" { + $result = Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result.ObjectId | should -Be "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaGroupLifecyclePolicy" + $result = Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "a47d4510-08c8-4437-99e9-71ca88e7af0f" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgBetaGroupLifecyclePolicy -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + It "Should execute successfully without throwing an error" { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { Set-EntraBetaGroupLifecyclePolicy -GroupLifecyclePolicyId "22cc22cc-dd33-ee44-ff55-66aa66aa66aa" -GroupLifetimeInDays 200 -AlternateNotificationEmails "admingroup@contoso.com" -ManagedGroupTypes "All" -Debug } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file From b1ca0ff28161592d77c168e7823be193e03d4c36 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Fri, 27 Sep 2024 10:25:26 +0530 Subject: [PATCH 42/64] updated doc --- .../Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md index f9ca99482..477009401 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeletedDirectoryObject.md @@ -66,7 +66,7 @@ The DirectoryObjectId of the directory object that is permanently deleted. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: Id Required: True Position: Named From 286e11ed62f7d95f1c81423e9b5c29a9a2e2ef0e Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 27 Sep 2024 15:51:20 +0530 Subject: [PATCH 43/64] alias fixes --- .../Get-EntraBetaGroupMember.ps1 | 8 ++++--- src/CompatibilityAdapterBuilder.ps1 | 18 +++++++++++--- ...dd-EntraAdministrativeUnitMember.Tests.ps1 | 19 ++++++++------- .../Get-EntraApplicationModule.Tests.ps1 | 2 +- .../New-EntraApplicationPassword.Tests.ps1 | 24 +++++++++---------- .../Get-EntraBetaUserManager.Tests.ps1 | 2 +- .../Get-EntraBetaUserOwnedDevice.Tests.ps1 | 10 ++++---- ...et-EntraBetaUserRegisteredDevice.Tests.ps1 | 10 ++++---- 8 files changed, 54 insertions(+), 39 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 index bb5fa6d52..e1ca74d67 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 @@ -96,10 +96,12 @@ if ($null -ne $_) { Add-Member -InputObject $_ -NotePropertyMembers $_.AdditionalProperties Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id - $propsToConvert = @('assignedLicenses','assignedPlans','provisionedPlans','identities') + $propsToConvert = @('assignedLicenses','assignedPlans','provisionedPlans','identities') foreach ($prop in $propsToConvert) { - $value = $_.$prop | ConvertTo-Json | ConvertFrom-Json - $_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force + if ($null -ne $_.PSObject.Properties[$prop]) { + $value = $_.$prop | ConvertTo-Json | ConvertFrom-Json + $_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force + } } } } diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 7569fd65c..1b5cd8558 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -60,6 +60,18 @@ class CompatibilityAdapterBuilder { 'Remove-EntraDeletedApplication', 'Select-EntraGroupIdsUserIsMemberOf', 'Add-EntraBetaServicePrincipalPolicy', + 'Get-EntraApplicationKeyCredential', + 'Get-EntraPermissionGrantConditionSet', + 'Get-EntraPermissionGrantConditionSet', + 'New-EntraNamedLocationPolicy', + 'New-EntraServicePrincipalAppRoleAssignment', + 'Restore-EntraDeletedDirectoryObject', + 'Restore-EntraBetaDeletedDirectoryObject', + 'New-EntraBetaServicePrincipalAppRoleAssignment', + 'New-EntraBetaNamedLocationPolicy', + 'Get-EntraBetaPermissionGrantConditionSet', + 'Get-EntraBetaPermissionGrantConditionSet', + 'Get-EntraBetaApplicationKeyCredential', 'Get-EntraBetaPrivilegedRoleDefinition', 'Get-EntraBetaFeatureRolloutPolicy', 'Set-EntraBetaPermissionGrantPolicy', @@ -85,7 +97,7 @@ class CompatibilityAdapterBuilder { 'New-EntraBetaUserAppRoleAssignment', 'Get-EntraBetaTrustFrameworkPolicy', 'Remove-EntraBetaObjectSetting', - 'Add-EntraBetacustomSecurityAttributeDefinitionAllowedValues', + 'Add-EntraBetacustomSecurityAttributeDefinitionAllowedValue', 'Get-EntraBetaUserOAuth2PermissionGrant', 'New-EntraBetaApplicationKey', 'Get-EntraBetaPolicy', @@ -705,7 +717,7 @@ Set-Variable -name MISSING_CMDS -value @('$($this.ModuleMap.MissingCommandsList $parameterDefinitions = $this.GetParametersDefinitions($Command) $ParamterTransformations = $this.GetParametersTransformations($Command) $OutputTransformations = $this.GetOutputTransformations($Command) - if (($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and $parameterDefinitions.Contains('$ObjectId') -or $parameterDefinitions.Contains('$Id')) { + if (($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and ($parameterDefinitions.Contains('$ObjectId') -or $parameterDefinitions.Contains('$Id'))) { $function = @" function $($Command.Generate) { $($Command.CustomScript) @@ -947,7 +959,7 @@ $OutputTransformations $paramBlock = $this.GetParameterTransformationName($param.Name, $param.Name) } elseif([TransformationTypes]::Name -eq $param.ConversionType){ - if(($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $param.TargetName){ + if(($this.cmdtoSkipNameconverssion -notcontains $Command.Generate) -and ($param.Name -eq 'ObjectId' -or $param.Name -eq 'Id') -and $null -ne $param.TargetName){ $paramBlock = $this.GetParameterTransformationName($param.TargetName, $param.TargetName) }else{ $paramBlock = $this.GetParameterTransformationName($param.Name, $param.TargetName) diff --git a/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 index 724b1dc81..df380af32 100644 --- a/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Add-EntraAdministrativeUnitMember.Tests.ps1 @@ -21,11 +21,11 @@ Describe "Add-EntraAdministrativeUnitMember tests"{ $result | Should -BeNullOrEmpty Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty"{ - { Add-EntraAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is empty"{ + { Add-EntraAdministrativeUnitMember -AdministrativeUnitId "" } | Should -Throw "Cannot bind argument to parameter 'AdministrativeUnitId'*" } - It "Should fail when ObjectId is null"{ - { Add-EntraAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when AdministrativeUnitId is null"{ + { Add-EntraAdministrativeUnitMember -AdministrativeUnitId } | Should -Throw "Missing an argument for parameter 'AdministrativeUnitId'*" } It "Should fail when RefObjectId is empty"{ { Add-EntraAdministrativeUnitMember -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId'*" @@ -36,13 +36,14 @@ Describe "Add-EntraAdministrativeUnitMember tests"{ It "Should fail when invalid paramter is passed"{ { Add-EntraAdministrativeUnitMember -Demo } | Should -Throw "A parameter cannot be found that matches parameter name 'Demo'*" } - It "Should contain 'User-Agent' header" { + It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraAdministrativeUnitMember" - Add-EntraAdministrativeUnitMember -ObjectId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" + Add-EntraAdministrativeUnitMember -AdministrativeUnitId "aaaaaaaa-1111-2222-3333-cccccccccccc" -RefObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraAdministrativeUnitMember" - $result = Add-EntraAdministrativeUnitMember -AdministrativeUnitId "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } } It "Should execute successfully without throwing an error " { # Disable confirmation prompts diff --git a/test/module/Entra/Get-EntraApplicationModule.Tests.ps1 b/test/module/Entra/Get-EntraApplicationModule.Tests.ps1 index f38ee7ef8..c6236d2ff 100644 --- a/test/module/Entra/Get-EntraApplicationModule.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationModule.Tests.ps1 @@ -33,7 +33,7 @@ Describe "Get-EntraApplication" { It 'Should have Get parameterSet' { $GetAzureADApplication = Get-Command Get-EntraApplication $GetParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetById" - $GetParameterSet.Parameters.Name | Should -Contain ObjectId + $GetParameterSet.Parameters.Name | Should -Contain ApplicationId } It 'Should have GetViaIdentity parameterSet' { diff --git a/test/module/Entra/New-EntraApplicationPassword.Tests.ps1 b/test/module/Entra/New-EntraApplicationPassword.Tests.ps1 index 5495c2e9e..372dd5b2e 100644 --- a/test/module/Entra/New-EntraApplicationPassword.Tests.ps1 +++ b/test/module/Entra/New-EntraApplicationPassword.Tests.ps1 @@ -26,37 +26,37 @@ BeforeAll { } Describe "New-EntraApplicationPassword"{ It "Should return created password credential"{ - $result = New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json + $result = New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty $result.KeyId | should -Be "aaaaaaaa-0b0b-1c1c-2d2d-333333333333" $result.SecretText | Should -Be "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when ObjectId is empty" { - { New-EntraApplicationPassword -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + It "Should fail when ApplicationId is empty" { + { New-EntraApplicationPassword -ApplicationId "" } | Should -Throw "Cannot bind argument to parameter 'ApplicationId'*" } - It "Should fail when ObjectId is null" { - { New-EntraApplicationPassword -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when ApplicationId is null" { + { New-EntraApplicationPassword -ApplicationId } | Should -Throw "Missing an argument for parameter 'ApplicationId'*" } It "Should fail when PasswordCredential is null" { { New-EntraApplicationPassword -PasswordCredential } | Should -Throw "Missing an argument for parameter 'PasswordCredential'*" } It "Should fail when StartDate is empty" { - { New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ StartDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" + { New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ StartDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" } It "Should fail when EndDate is empty" { - { New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ EndDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" + { New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ EndDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" } It "Should fail when invalid parameter is passed" { { New-EntraApplicationPassword -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } + It "Should contain ApplicationId in parameters when passed ApplicationId to it" { + $result = New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } It "should contain password credential parameters in body parameter when passed PasswordCredential to it"{ - $result = New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ DisplayName = "mypassword"; Hint = "123"; StartDateTime=(get-date).AddYears(0); EndDateTime=(get-date).AddYears(2) } + $result = New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ DisplayName = "mypassword"; Hint = "123"; StartDateTime=(get-date).AddYears(0); EndDateTime=(get-date).AddYears(2) } $params = Get-Parameters -data $result.Parameters $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json $a.DisplayName | Should -Be "mypassword" @@ -66,7 +66,7 @@ Describe "New-EntraApplicationPassword"{ } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationPassword" - $result = New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json + $result = New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationPassword" Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -81,7 +81,7 @@ Describe "New-EntraApplicationPassword"{ try { # Act & Assert: Ensure the function doesn't throw an exception - { New-EntraApplicationPassword -ObjectID "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json -Debug } | Should -Not -Throw + { New-EntraApplicationPassword -ApplicationId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 index 898e29c6f..d54335ca8 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserManager.Tests.ps1 @@ -107,7 +107,7 @@ Describe "Get-EntraBetaUserManager" { } It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + { Get-EntraBetaUserManager -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should fail when invalid parameter is passed" { diff --git a/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 index 9592314f8..db52434cb 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserOwnedDevice.Tests.ps1 @@ -46,11 +46,11 @@ Describe "Get-EntraBetaUserOwnedDevice" { Should -Invoke -CommandName Get-MgBetaUserOwnedDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectId is empty" { - { Get-EntraBetaUserOwnedDevice -UserId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraBetaUserOwnedDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectId is invalid" { - { Get-EntraBetaUserOwnedDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is invalid" { + { Get-EntraBetaUserOwnedDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return All user registered devices" { $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All @@ -76,7 +76,7 @@ Describe "Get-EntraBetaUserOwnedDevice" { It "Should fail when Top is invalid" { { Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { $result = Get-EntraBetaUserOwnedDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" diff --git a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 index 4e6a5be26..7e60e3e60 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 @@ -46,11 +46,11 @@ Describe "Get-EntraBetaUserRegisteredDevice" { Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when ObjectlId is empty" { - { Get-EntraBetaUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + It "Should fail when UserId is empty" { + { Get-EntraBetaUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } - It "Should fail when ObjectlId is invalid" { - { Get-EntraBetaUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + It "Should fail when UserId is invalid" { + { Get-EntraBetaUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return All user registered devices" { $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All @@ -76,7 +76,7 @@ Describe "Get-EntraBetaUserRegisteredDevice" { It "Should fail when Top is invalid" { { Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } - It "Should contain UserId in parameters when passed ObjectId to it" { + It "Should contain UserId in parameters when passed UserId to it" { $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" $params = Get-Parameters -data $result.Parameters $params.UserId | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" From 57e28455c1b37a9d3123d55a0075a7a1d19f9173 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 27 Sep 2024 16:39:54 +0530 Subject: [PATCH 44/64] alias changes --- .../EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 index 7e60e3e60..6fb67c742 100644 --- a/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaUserRegisteredDevice.Tests.ps1 @@ -47,10 +47,10 @@ Describe "Get-EntraBetaUserRegisteredDevice" { Should -Invoke -CommandName Get-MgBetaUserRegisteredDevice -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when UserId is empty" { - { Get-EntraBetaUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" + { Get-EntraBetaUserRegisteredDevice -UserId } | Should -Throw "Missing an argument for parameter 'UserId'*" } It "Should fail when UserId is invalid" { - { Get-EntraBetaUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." + { Get-EntraBetaUserRegisteredDevice -UserId ""} | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." } It "Should return All user registered devices" { $result = Get-EntraBetaUserRegisteredDevice -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -All @@ -117,5 +117,4 @@ Describe "Get-EntraBetaUserRegisteredDevice" { } } } -} - \ No newline at end of file +} \ No newline at end of file From 0c8b4cb64abf2e4d0baa5d3906aca9d911ba0c7d Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Mon, 30 Sep 2024 06:20:12 +0000 Subject: [PATCH 45/64] Enriching examples. --- .../Get-EntraBetaAdministrativeUnitMember.md | 6 +++--- .../Get-EntraAdministrativeUnitMember.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md index 79ae52af6..68bb562f1 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaAdministrativeUnitMember.md @@ -51,7 +51,7 @@ In delegated scenarios with work or school accounts, the signed-in user must eit ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id ``` ```Output @@ -73,7 +73,7 @@ This example returns the list of administrative unit members from specified admi ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -All +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id -All ``` ```Output @@ -95,7 +95,7 @@ This example returns the list of all administrative unit members from specified ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraBetaAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -Top 3 +Get-EntraBetaAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id -Top 3 ``` ```Output diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md index 89c854462..2c53b4d71 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraAdministrativeUnitMember.md @@ -51,7 +51,7 @@ In delegated scenarios with work or school accounts, the signed-in user must eit ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id ``` ```Output @@ -73,7 +73,7 @@ This example returns the list of administrative unit members from specified admi ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -All +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id -All ``` ```Output @@ -95,7 +95,7 @@ This example returns the list of all administrative unit members from specified ```powershell Connect-Entra -Scopes 'AdministrativeUnit.ReadWrite.All' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" -Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.ObjectId -Top 3 +Get-EntraAdministrativeUnitMember -AdministrativeUnitId $AdministrativeUnit.Id -Top 3 ``` ```Output From 5d7c6483a2e8f3585fe322949684ad105e87374a Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:12:18 +0000 Subject: [PATCH 46/64] ApplicationExtensionProperty example fixes --- .../Get-EntraBetaApplicationExtensionProperty.md | 2 +- .../Get-EntraApplicationExtensionProperty.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md index 93eac437f..5dcbbd7af 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaApplicationExtensionProperty.md @@ -42,7 +42,7 @@ The `Get-EntraBetaApplicationExtensionProperty` cmdlet gets application extensio ```powershell Connect-Entra -Scopes 'Application.Read.All' $Application = Get-EntraBetaApplication -SearchString '' -Get-EntraBetaApplicationExtensionProperty -ApplicationId $Application.ObjectId +Get-EntraBetaApplicationExtensionProperty -ApplicationId $Application.Id ``` ```Output diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md index 0ea6cc82b..63bce77e9 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraApplicationExtensionProperty.md @@ -42,7 +42,7 @@ The `Get-EntraApplicationExtensionProperty` cmdlet gets application extension pr ```powershell Connect-Entra -Scopes 'Application.Read.All' $Application = Get-EntraApplication -SearchString '' -Get-EntraApplicationExtensionProperty -ApplicationId $Application.ObjectId +Get-EntraApplicationExtensionProperty -ApplicationId $Application.Id ``` ```Output From bd1584c7f733d995d5ef442223452f205fdd3112 Mon Sep 17 00:00:00 2001 From: v-varshamane <142500640+v-varshamane@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:55:10 +0530 Subject: [PATCH 47/64] Update Get-EntraDirectoryRoleDefinition.ps1 --- .../customizations/Get-EntraDirectoryRoleDefinition.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 index b221639b5..781a5e7e2 100644 --- a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 +++ b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 @@ -19,7 +19,7 @@ [System.Nullable`1[System.Int32]] $Top, [Alias('Id')] [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $DirectoryRoleId, + [System.String] $UnifiedRoleDefinitionId, [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [System.String[]] $Property ) @@ -27,9 +27,9 @@ $params = @{} $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $keysChanged = @{SearchString = "Filter"} - if($null -ne $PSBoundParameters["DirectoryRoleId"]) + if($null -ne $PSBoundParameters["UnifiedRoleDefinitionId"]) { - $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["DirectoryRoleId"] + $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["UnifiedRoleDefinitionId"] } if($null -ne $PSBoundParameters["Filter"]) { @@ -126,4 +126,4 @@ $response } '@ -} \ No newline at end of file +} From 2d108769c125c68c5eae72fb5d9f3f803d5a76f4 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:42:41 +0000 Subject: [PATCH 48/64] Adding required roles. --- .../Get-EntraServicePrincipalAppRoleAssignment.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md index f5f413180..971849856 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraServicePrincipalAppRoleAssignment.md @@ -37,6 +37,16 @@ Get-EntraServicePrincipalAppRoleAssignment The `Get-EntraServicePrincipalAppRoleAssignment` cmdlet gets a role assignment for a service principal application in Microsoft Entra ID. +For delegated scenarios, the calling user needs at least one of the following Microsoft Entra roles. +- Directory Synchronization Accounts +- Directory Writer +- Hybrid Identity Administrator +- Identity Governance Administrator +- Privileged Role Administrator +- User Administrator +- Application Administrator +- Cloud Application Administrator + ## Examples ### Example 1: Retrieve the application role assignments for a service principal From 717bc64e0d3305104b12ce5db43c6e504c78ed1d Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:38:24 +0300 Subject: [PATCH 49/64] Update module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md --- .../Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md index d96d2cdf3..2683fe433 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md @@ -44,7 +44,7 @@ This operation is usually performed by the user or an administrator if the user' ```powershell Connect-Entra -Scopes 'User.RevokeSessions.All' -Revoke-EntraUserAllRefreshToken -UserId 'bbbbbbbb-1111-2222-3333-cccccccccccc' +Revoke-EntraUserAllRefreshToken -UserId 'SawyerM@contoso.com' ``` This example demonstrates how to revoke the tokens for the specified user. From 93906c6be1049c29cdae689de63f69c4cd762f59 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:42:08 +0000 Subject: [PATCH 50/64] Formatting outputs. --- .../Revoke-EntraUserAllRefreshToken.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md index 2683fe433..c6dfb4904 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Revoke-EntraUserAllRefreshToken.md @@ -47,6 +47,12 @@ Connect-Entra -Scopes 'User.RevokeSessions.All' Revoke-EntraUserAllRefreshToken -UserId 'SawyerM@contoso.com' ``` +```Output +Value +----- +True +``` + This example demonstrates how to revoke the tokens for the specified user. - `-UserId` parameter specifies the unique identifier of a user. From 5416ba17f790b6f9aef0d3319fca0ac69a601481 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:43:48 +0000 Subject: [PATCH 51/64] Adding UserId --- .../Revoke-EntraBetaUserAllRefreshToken.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md index 9bfc171bc..417563fe4 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Revoke-EntraBetaUserAllRefreshToken.md @@ -44,7 +44,7 @@ This operation is usually performed by the user or an administrator if the user' ```powershell Connect-Entra -Scopes 'User.RevokeSessions.All' -Revoke-EntraBetaUserAllRefreshToken -UserId 'eeeeeeee-4444-5555-6666-ffffffffffff' +Revoke-EntraBetaUserAllRefreshToken -UserId 'SawyerM@contoso.com' ``` ```Output From 041f2ae008209eacaefd833ecbedc9157b814d8e Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:54:39 +0000 Subject: [PATCH 52/64] Fixing application look up. --- .../Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md index b837a3a8d..a50c62f30 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaApplicationLogo.md @@ -59,7 +59,8 @@ The `Set-EntraBetaApplicationLogo` cmdlet is used to set the logo for an applica ```powershell Connect-Entra -Scopes 'Application.ReadWrite.All' -Set-EntraBetaApplicationLogo -ApplicationId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' -FilePath 'D:\applogo.jpg' +$application = Get-EntraBetaApplication -Filter "DisplayName eq 'Demo Application'" +Set-EntraBetaApplicationLogo -ApplicationId $application.Id -FilePath 'D:\applogo.jpg' ``` This cmdlet sets the application logo for the application specified by the `-ApplicationId` parameter to the image specified with the `-FilePath` parameter. From a59ba59a5d069910ceac96688e68e6e72a226a52 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:59:54 +0000 Subject: [PATCH 53/64] Updated description for set attribute set commands --- .../Set-EntraBetaAttributeSet.md | 8 +++++--- .../Microsoft.Graph.Entra/Set-EntraAttributeSet.md | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md index d242398d1..bbf3b5250 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaAttributeSet.md @@ -34,11 +34,13 @@ Set-EntraBetaAttributeSet ## Description -Updates a Microsoft Entra ID attribute set object identified by ID. Specify `AttributeSetId` parameter to update an attribute set. +The `Set-EntraBetaAttributeSet` cmdlet updates a Microsoft Entra ID attribute set object specified by its ID. Specify `AttributeSetId` parameter to Update a Microsoft Entra ID attribute set object. -You can only update the `description` and `maxAttributesPerSet` properties. +In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. + +Note: Only the Attribute Definition Administrator role is supported for this operation. Ensure the signed-in user is assigned this role. -In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with the necessary permissions. The Attribute Definition Administrator is the only privileged role supported for this operation. +You can only update the `description` and `maxAttributesPerSet` properties. ## Examples diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md index 1ccf1dfd3..3e5f38487 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraAttributeSet.md @@ -42,8 +42,6 @@ Note: Only the Attribute Definition Administrator role is supported for this ope You can only update the `description` and `maxAttributesPerSet` properties. -In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with the necessary permissions. The Attribute Definition Administrator is the only privileged role supported for this operation. - ## Examples ### Example 1: Update an attribute set From 91ecebe3442b1ffd5f16e44181d59ca7ab377e56 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:08:31 +0000 Subject: [PATCH 54/64] Updating role definition lookup values. --- .../Set-EntraBetaDirectoryRoleDefinition.md | 66 ++++++++++--------- .../Set-EntraDirectoryRoleDefinition.md | 42 ++++++------ 2 files changed, 58 insertions(+), 50 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md index b6392aefb..f85d4d183 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaDirectoryRoleDefinition.md @@ -47,12 +47,13 @@ Updates a Microsoft Entra roleDefinition object identified by ID. You can't upda ### Example 1: Update an roleDefinition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - $params = @{ - UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' - DisplayName = 'UpdatedDisplayName' - } - Set-EntraBetaDirectoryRoleDefinition @params +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" +$params = @{ + UnifiedRoleDefinitionId = $roleDefinition.Id + DisplayName = 'UpdatedDisplayName' +} +Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the specified role definition in Microsoft Entra ID. @@ -63,12 +64,13 @@ This example updates the specified role definition in Microsoft Entra ID. ### Example 2: Update an roleDefinition with Description ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - $params = @{ - UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' - Description = 'MYROLEUPDATE1S' - } - Set-EntraBetaDirectoryRoleDefinition @params +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" +$params = @{ + UnifiedRoleDefinitionId = $roleDefinition.Id + Description = 'MYROLEUPDATE1S' +} +Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the Description of specified role definition in Microsoft Entra ID. @@ -79,12 +81,13 @@ This example updates the Description of specified role definition in Microsoft E ### Example 3: Update an roleDefinition with IsEnabled ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - $params = @{ - UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' - IsEnabled = $true - } - Set-EntraBetaDirectoryRoleDefinition @params +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" +$params = @{ + UnifiedRoleDefinitionId = $roleDefinition.Id + IsEnabled = $true +} +Set-EntraBetaDirectoryRoleDefinition @params ``` This example updates the IsEnabled of specified role definition in Microsoft Entra ID. @@ -95,19 +98,20 @@ This example updates the IsEnabled of specified role definition in Microsoft Ent ### Example 4: Update an roleDefinition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission - $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") - $params = @{ - UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' - Description = 'Update' - DisplayName = 'Update' - ResourceScopes = '/' - IsEnabled = $false - RolePermissions = $RolePermissions - TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' - Version = 2 - } +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraBetaDirectoryRoleDefinition -Filter "DisplayName eq ''" +$RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission +$RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") +$params = @{ + UnifiedRoleDefinitionId = $roleDefinition.Id + Description = 'Update' + DisplayName = 'Update' + ResourceScopes = '/' + IsEnabled = $false + RolePermissions = $RolePermissions + TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' + Version = 2 +} Set-EntraBetaDirectoryRoleDefinition @params ``` diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md index f84bac18f..096b18904 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraDirectoryRoleDefinition.md @@ -46,8 +46,9 @@ Updates a Microsoft Entra roleDefinition object identified by ID. You can't upda ### Example 1: Update an roleDefinition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -DisplayName 'UpdatedDisplayName' +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" +Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId $roleDefinition.Id -DisplayName 'UpdatedDisplayName' ``` This example updates the specified role definition in Microsoft Entra ID. @@ -58,8 +59,9 @@ This example updates the specified role definition in Microsoft Entra ID. ### Example 2: Update an roleDefinition with Description ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -Description 'MYROLEUPDATE1S' +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" +Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId $roleDefinition.Id -Description 'MYROLEUPDATE1S' ``` This example updates the Description of specified role definition in Microsoft Entra ID. @@ -70,8 +72,9 @@ This example updates the Description of specified role definition in Microsoft E ### Example 3: Update an roleDefinition with IsEnabled ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 -IsEnabled $true +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" +Set-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId $roleDefinition.Id -IsEnabled $true ``` This example updates the IsEnabled of specified role definition in Microsoft Entra ID. @@ -82,19 +85,20 @@ This example updates the IsEnabled of specified role definition in Microsoft Ent ### Example 4: Update an roleDefinition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - $RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission - $RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") - $params = @{ - UnifiedRoleDefinitionId = 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' - Description = 'Update' - DisplayName = 'Update' - ResourceScopes = '/' - IsEnabled = $false - RolePermissions = $RolePermissions - TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' - Version = 2 - } +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +$roleDefinition = Get-EntraDirectoryRoleDefinition -Filter "DisplayName eq ''" +$RolePermissions = New-object Microsoft.Open.MSGraph.Model.RolePermission +$RolePermissions.AllowedResourceActions = @("microsoft.directory/applications/standard/read") +$params = @{ + UnifiedRoleDefinitionId = $roleDefinition.Id + Description = 'Update' + DisplayName = 'Update' + ResourceScopes = '/' + IsEnabled = $false + RolePermissions = $RolePermissions + TemplateId = '54d418b2-4cc0-47ee-9b39-e8f84ed8e073' + Version = 2 +} Set-EntraDirectoryRoleDefinition @params ``` From 9ac752a78609435d8115c5f7d72fad39c81994af Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:24:43 +0000 Subject: [PATCH 55/64] Set-EntraUser fixes --- .../Microsoft.Graph.Entra/Set-EntraUser.md | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md index b3140db1e..5955988e3 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUser.md @@ -60,55 +60,82 @@ Set-EntraUser ## Description -The `Set-EntraUser` cmdlet updates a user in Microsoft Entra ID. Specify the `ObjectId` parameter to update a user in Microsoft Entra ID. +The `Set-EntraUser` cmdlet updates a user in Microsoft Entra ID. Specify the `UserId` parameter to update a user in Microsoft Entra ID. ## Examples ### Example 1: Update a user ```powershell -PS C:\> $user = Get-EntraUser -UserId TestUser@example.com -PS C:\> $user.DisplayName = 'YetAnotherTestUser' -PS C:\> Set-EntraUser -UserId TestUser@example.com -Displayname $user.Displayname +Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' +$user = Get-EntraUser -UserId 'SawyerM@contoso.com' +$params = @{ + UserId = $user.Id + DisplayName = 'Updated user Name' +} +Set-EntraUser @params ``` This example updates the specified user's Display name parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. ### Example 2: Set the specified user's AccountEnabled parameter ```powershell -PS C:\> Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -AccountEnabled $true +Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' +$params = @{ + UserId = 'SawyerM@contoso.com' + AccountEnabled = $true +} +Set-EntraUser @params ``` This example updates the specified user's AccountEnabled parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-AccountEnabled` Specifies whether the account is enabled. ### Example 3: Set all but specified users as minors with parental consent ```powershell -PS C:\>Get-EntraUser -All | -Where-Object -FilterScript { $_.DisplayName -notmatch '(George|James|Education)' } | +Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' +Get-EntraUser -All | Where-Object -FilterScript { $_.DisplayName -notmatch '(George|James|Education)' } | ForEach-Object { Set-EntraUser -UserId $($_.ObjectId) -AgeGroup 'minor' -ConsentProvidedForMinor 'granted' } ``` This example updates the specified user's as minors with parental consent. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-ConsentProvidedForMinor` Sets whether consent has to obtained for minors. Allowed values: null, granted, denied, and notRequired. ### Example 4: Set the specified user's property ```powershell -PS C:\>Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -City "Add city name" -CompanyName "Microsoft" -ConsentProvidedForMinor Granted -Country 'Add country name' -Department "Add department name" -GivenName "Mircosoft" -ImmutableId "#1" -JobTitle "Manager" -MailNickName "Add mailnickname" -Mobile "9984534564" -OtherMails "test12@M365x99297270.OnMicrosoft.com" -PasswordPolicies "DisableStrongPassword" -State "UP" -StreetAddress "Add address" -UserType "Member" +Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' +$params = @{ + UserId = 'SawyerM@contoso.com' + City = 'Add city name' + CompanyName = 'Microsoft' + Country = 'Add country name' + Department = 'Add department name' + GivenName = 'Mircosoft' + ImmutableId = '#1' + JobTitle = 'Manager' + MailNickName = 'Add mailnickname' + Mobile = '9984534564' + OtherMails = 'test12@M365x99297270.OnMicrosoft.com' + PasswordPolicies = 'DisableStrongPassword' + State = 'UP' + StreetAddress = 'Add address' + UserType = 'Member' +} +Set-EntraUser @params ``` This example updates the specified user's property. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-UserType` classify user types in your directory, such as "Member" and "Guest." - `-PasswordPolicies` Specifies password policies for the user. - `-OtherMails` Specifies other email addresses for the user @@ -118,18 +145,19 @@ This example updates the specified user's property. ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $params= @{ -ObjectId = 'SawyerM@contoso.com' +UserId = 'SawyerM@contoso.com' PasswordProfile = @{ Password= '*****' ForceChangePasswordNextLogin = $true EnforceChangePasswordPolicy = $false } -PS C:\> Set-EntraUser -UserId 1139c016-f606-45f0-83f7-40eb2a552a6f -PasswordProfile $a +} +Set-EntraUser @params ``` This example updates the specified user's PasswordProfile parameter. -- `-ObjectId` Specifies the ID as a user principal name (UPN) or ObjectId. +- `-UserId` Specifies the ID as a user principal name (UPN) or UserId. - `-PasswordProfile` specifies the user's password profile. ## Parameters From d2947078758356c38ac7167e6f702cc26ee490b3 Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:41:52 +0000 Subject: [PATCH 56/64] Enriching beta example --- .../Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md index 12c5e366a..15369894e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUser.md @@ -68,7 +68,7 @@ The `Set-EntraBetaUser` cmdlet updates a user in Microsoft Entra ID. Specify the ```powershell Connect-Entra -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All' -$user = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +$user = Get-EntraBetaUser -UserId 'SawyerM@contoso.com' $params = @{ UserId = $user.ObjectId DisplayName = 'Updated user Name' @@ -145,7 +145,7 @@ This example updates the specified user's property. ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $params= @{ -UserId = $user.UserId +UserId = 'SawyerM@contoso.com' PasswordProfile = @{ Password= '*****' ForceChangePasswordNextLogin = $true From 3e7d35bc3b6cd2033db37a77d0e06cc413f698db Mon Sep 17 00:00:00 2001 From: Steve Mutungi <132555836+SteveMutungi254@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:44:23 +0000 Subject: [PATCH 57/64] User Manager fixes --- .../Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md | 2 +- .../Microsoft.Graph.Entra/Set-EntraUserManager.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md index 81d40fa30..8d5210a36 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Set-EntraBetaUserManager.md @@ -40,7 +40,7 @@ The `Set-EntraBetaUserManager` cmdlet update the manager for a user in Microsoft ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$manager = Get-EntraBetaUser -ObjectId 'Manager@contoso.com' +$manager = Get-EntraBetaUser -UserId 'Manager@contoso.com' $params = @{ UserId = 'bbbbbbbb-1111-2222-3333-cccccccccccc' RefObjectId = '55ff55ff-aa66-bb77-cc88-99dd99dd99dd' diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md index 86fffa11a..4b64ccd4e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Set-EntraUserManager.md @@ -40,7 +40,7 @@ The `Set-EntraUserManager` cmdlet update the manager for a user in Microsoft Ent ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$manager = Get-EntraUser -ObjectId 'Manager@contoso.com' +$manager = Get-EntraUser -UserId 'Manager@contoso.com' $params = @{ UserId = 'SawyerM@contoso.com' RefObjectId = $manager.ObjectId From ba7e3eb4c976379a05245e96ebd98f8297cb5c34 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 1 Oct 2024 17:27:52 +0530 Subject: [PATCH 58/64] comment fix --- .../Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md | 2 +- .../Remove-EntraBetaGroupOwner.md | 2 +- .../Remove-EntraBetaScopedRoleMembership.md | 2 +- .../Remove-EntraBetaUserManager.md | 2 +- .../Remove-EntraDeviceRegisteredOwner.md | 2 +- .../Remove-EntraGroupAppRoleAssignment.md | 3 ++- .../Microsoft.Graph.Entra/Remove-EntraGroupMember.md | 3 ++- .../Microsoft.Graph.Entra/Remove-EntraGroupOwner.md | 3 ++- .../Remove-EntraScopedRoleMembership.md | 2 +- .../Remove-EntraServicePrincipalAppRoleAssignment.md | 6 +++--- .../Microsoft.Graph.Entra/Remove-EntraUser.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraUserManager.md | 4 ++-- 12 files changed, 18 insertions(+), 15 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md index b9c39d6a2..558c6723c 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaGroupOwner.md @@ -46,7 +46,7 @@ The `Add-EntraBetaGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$user = Get-EntraBetaUser -GroupId 'SawyerM@contoso.com' +$user = Get-EntraBetaUser -UserId 'SawyerM@contoso.com' $params = @{ GroupId = $group.ObjectId RefObjectId = $user.ObjectId diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md index 83d497d0e..2b942f2a6 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupOwner.md @@ -43,7 +43,7 @@ The `Remove-EntraBetaGroupOwner` cmdlet removes an owner from a group in Microso Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $params = @{ - GroupId = 'qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh' + GroupId = $group.Id OwnerId = 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' } diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md index b33b39725..0d7fc3566 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaScopedRoleMembership.md @@ -53,7 +53,7 @@ Remove-EntraBetaScopedRoleMembership @params This cmdlet removes a specific scoped role membership from Microsoft Entra ID. You can use the command `Get-EntraBetaAdministrativeUnit` to get administrative unit Id. - `-AdministrativeUnitId` parameter specifies the ID of an administrative unit. -- `-ScopedRoleMembershipId` parameter specifies the ID of the scoped role membership to remove. To obtain the details of a scoped role membership, you can use the `Get-EntraScopedRoleMembership` command. +- `-ScopedRoleMembershipId` parameter specifies the ID of the scoped role membership to remove. To obtain the details of a scoped role membership, you can use the `Get-EntraBetaScopedRoleMembership` command. ## Parameters diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md index 7f76cf8cc..756fc1b1f 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaUserManager.md @@ -40,7 +40,7 @@ The `Remove-EntraBetaUserManager` cmdlet removes a user's manager in Microsoft E ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$User = Get-EntraBetaUser -Top 1 +$User = Get-EntraBetaUser -UserId 'SawyerM@Contoso.com' Remove-EntraBetaUserManager -UserId $User.ObjectId ``` diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md index ab1b09767..531f2187e 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredOwner.md @@ -42,7 +42,7 @@ The `Remove-EntraDeviceRegisteredOwner` cmdlet removes the registered owner of a ```powershell Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraDevice -Top 1 -$Owner = Get-EntraDeviceRegisteredOwner -ObjectId $Device.ObjectId +$Owner = Get-EntraDeviceRegisteredOwner -DeviceId $Device.ObjectId Remove-EntraDeviceRegisteredOwner -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId ``` diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md index 5e5079156..8066aa68b 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupAppRoleAssignment.md @@ -40,7 +40,8 @@ The `Remove-EntraGroupAppRoleAssignment` cmdlet removes a group application role ```powershell Connect-Entra -Scopes 'Directory.ReadWrite.All' -Remove-AzureADGroupAppRoleAssignment -GroupId 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' -AppRoleAssignmentId 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' +$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" +Remove-EntraGroupAppRoleAssignment -GroupId $group.Id -AppRoleAssignmentId 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' ``` This example demonstrates how to remove the specified group application role assignment. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md index a0b915c88..690d5fac8 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupMember.md @@ -41,7 +41,8 @@ The `Remove-EntraGroupMember` cmdlet removes a member from a group in Microsoft ```powershell Connect-Entra -Scopes 'GroupMember.ReadWrite.All' -Remove-EntraGroupMember -GroupId 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' -MemberId 'zzzzzzzz-6666-8888-9999-pppppppppppp' +$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" +Remove-EntraGroupMember -GroupId $group.Id -MemberId 'zzzzzzzz-6666-8888-9999-pppppppppppp' ``` This command removes the specified member from the specified group. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md index 3452e25b5..8d3a14308 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraGroupOwner.md @@ -40,7 +40,8 @@ The `Remove-EntraGroupOwner` cmdlet removes an owner from a group in Microsoft E ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' -Remove-EntraGroupOwner -GroupId 'qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh' -OwnerId 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' +$group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" +Remove-EntraGroupOwner -GroupId $group.Id -OwnerId 'xxxxxxxx-8888-5555-9999-bbbbbbbbbbbb' ``` This example demonstrates how to remove an owner from a group in Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md index 49e2fd174..556bfcb16 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md @@ -34,7 +34,7 @@ Remove-EntraScopedRoleMembership ## Description -The `Remove-EntraScopedRoleMembership` cmdlet removes a scoped role membership from Microsoft Entra ID. Specify `ObjectId` and `ScopedRoleMembershipId` parameter to remove a scoped role membership. +The `Remove-EntraScopedRoleMembership` cmdlet removes a scoped role membership from Microsoft Entra ID. Specify `AdministrativeUnitId` and `ScopedRoleMembershipId` parameter to remove a scoped role membership. ## Examples diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md index 56525891a..1b82b8dd3 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraServicePrincipalAppRoleAssignment.md @@ -55,13 +55,13 @@ For delegated scenarios, the calling user needs at least one of the following Mi ```powershell Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' -Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId '11112222-bbbb-3333-cccc-4444dddd5555' -AppRoleAssignmentId '2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6' +$servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq ''" +Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId $servicePrincipal.Id -AppRoleAssignmentId '2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6' ``` This example demonstrates how to remove a service principal application role assignment in Microsoft Entra ID. -- `-ServicePrincipalId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. In this example, `11112222-bbbb-3333-cccc-4444dddd5555` is the Object ID of the target service principal or user. - +- `-ServicePrincipalId` - specifies the unique identifier (Object ID) of the service principal or user from which you want to remove an app role assignment. - `-AppRoleAssignmentId` - specifies the unique identifier (ID) of the app role assignment that you want to remove. The value `2bbbbbb2-3cc3-4dd4-5ee5-6ffffffffff6` represents the ID of the specific app role assignment to be removed. ## Parameters diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md index 705a8a1ed..694ce77e7 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md @@ -32,7 +32,7 @@ Remove-EntraUser ## Description -The Remove-EntraUser cmdlet removes a user in Microsoft Entra ID. Specify the `ObjectId` parameter to remove the specified user in Microsoft Entra ID. +The Remove-EntraUser cmdlet removes a user in Microsoft Entra ID. Specify the `UserId` parameter to remove the specified user in Microsoft Entra ID. The calling user must be assigned at least one of the following Microsoft Entra roles: diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md index 1f780a231..3c4d6d988 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUserManager.md @@ -31,7 +31,7 @@ Remove-EntraUserManager ## Description -The `Remove-EntraUserManager` cmdlet removes a user's manager in Microsoft Entra ID. Specify the `ObjectId` parameter to remove the manager for a user in Microsoft Entra ID. +The `Remove-EntraUserManager` cmdlet removes a user's manager in Microsoft Entra ID. Specify the `UserId` parameter to remove the manager for a user in Microsoft Entra ID. ## Examples @@ -39,7 +39,7 @@ The `Remove-EntraUserManager` cmdlet removes a user's manager in Microsoft Entra ```powershell Connect-Entra -Scopes 'User.ReadWrite.All' -$User = Get-EntraUser -Top 1 +$User = Get-EntraUser -UserId 'SawyerM@Contoso.com' Remove-EntraUserManager -UserId $User.ObjectId ``` From beeecfdf3de4608efc3bd0036817df3f1db8052c Mon Sep 17 00:00:00 2001 From: v-pughosh Date: Tue, 1 Oct 2024 21:26:28 +0530 Subject: [PATCH 59/64] Get-UserExtension (#1126) * Get-UserExtension * updates * updates * added doc * updated o/p properties * updated * Updated Get-EntraBetaUserExtension * updated beta do output * updated --------- Co-authored-by: Snehal Kotwal (Perennial Systems Inc) Co-authored-by: Ashwini Karke Co-authored-by: v-akarke <142799789+v-akarke@users.noreply.github.com> --- .../customizations/Get-EntraUserExtension.ps1 | 49 ++++++++--- .../Get-EntraBetaUserExtension.ps1 | 51 +++++++++--- .../Get-EntraBetaGroupMember.md | 2 +- .../Get-EntraBetaUserExtension.md | 10 ++- .../Get-EntraBetaUserOAuth2PermissionGrant.md | 2 +- .../Get-EntraUserExtension.md | 9 ++- .../Entra/Get-EntraUserExtension.Tests.ps1 | 81 +++++++++++++++++++ .../Get-EntraBetaUserExtension.Tests.ps1 | 81 +++++++++++++++++++ 8 files changed, 258 insertions(+), 27 deletions(-) create mode 100644 test/module/Entra/Get-EntraUserExtension.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaUserExtension.Tests.ps1 diff --git a/module/Entra/customizations/Get-EntraUserExtension.ps1 b/module/Entra/customizations/Get-EntraUserExtension.ps1 index 7944b3864..e486037de 100644 --- a/module/Entra/customizations/Get-EntraUserExtension.ps1 +++ b/module/Entra/customizations/Get-EntraUserExtension.ps1 @@ -3,14 +3,45 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Get-AzureADUserExtension" - TargetName = "Get-MgUserExtension" - Parameters = @( - @{ - SourceName = "ObjectId" - TargetName = "UserId" - ConversionType = "Name" - SpecialMapping = $null - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $UserId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + $baseUri = "https://graph.microsoft.com/v1.0/users/$UserId" + $properties = '$select=Identities,OnPremisesDistinguishedName,EmployeeId,CreatedDateTime' + $params["Uri"] = "$baseUri/?$properties" + + if($null -ne $PSBoundParameters["Property"]) + { + $params["Property"] = $PSBoundParameters["Property"] + $selectProperties = $PSBoundParameters["Property"] + $selectProperties = $selectProperties -Join ',' + $properties = "`$select=$($selectProperties)" + $params["Uri"] = "$baseUri/?$properties" + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $data = Invoke-GraphRequest -Uri $($params.Uri) -Method GET -Headers $customHeaders | Convertto-json | convertfrom-json + $data | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name userIdentities -Value identities + } + } + $data + } +'@ } diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 index 13b421f7e..5bd7c3eb3 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 @@ -3,14 +3,45 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Get-AzureADUserExtension" - TargetName = "Get-MgBetaUserExtension" - Parameters = @( - @{ - SourceName = "ObjectId" - TargetName = "UserId" - ConversionType = "Name" - SpecialMapping = $null - } - ) + TargetName = $null + Parameters = $null Outputs = $null -} \ No newline at end of file + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = '')] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias("ObjectId")] + [System.String] $UserId, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + PROCESS { + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + $baseUri = "https://graph.microsoft.com/beta/users/$UserId" + $properties = '$select=Identities,OnPremisesDistinguishedName,EmployeeId,CreatedDateTime' + $params["Uri"] = "$baseUri/?$properties" + + if($null -ne $PSBoundParameters["Property"]) + { + $params["Property"] = $PSBoundParameters["Property"] + $selectProperties = $PSBoundParameters["Property"] + $selectProperties = $selectProperties -Join ',' + $properties = "`$select=$($selectProperties)" + $params["Uri"] = "$baseUri/?$properties" + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $data = Invoke-GraphRequest -Uri $($params.Uri) -Method GET -Headers $customHeaders | Convertto-json | convertfrom-json + $data | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name userIdentities -Value identities + } + } + $data + } +'@ +} diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md index 03a5b8652..765718a58 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaGroupMember.md @@ -115,7 +115,7 @@ This example retrieves all members within a group by group ID. ```powershell Connect-Entra -Scopes 'GroupMember.Read.All' -Get-EntraGroupMember -GroupId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' +Get-EntraBetaGroupMember -GroupId 'tttttttt-0000-2222-0000-aaaaaaaaaaaa' | Select-Object DisplayName, '@odata.type' ``` ```Output diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md index c9a0b0cbb..2774efafd 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserExtension.md @@ -46,9 +46,13 @@ Get-EntraBetaUserExtension -UserId $UserId ``` ```Output -Id --- -com.contoso.roamingSettings +onPremisesDistinguishedName : +@odata.context : https://graph.microsoft.com/beta/$metadata#users(identities,onPremisesDistinguishedName,employeeId,createdDateTime)/$entity +identities : {@{issuer=SawyerM@contoso.com; signInType=userPrincipalName; issuerAssignedId=SawyerM@contoso.com}} +employeeId : +id : 00aa00aa-bb11-cc22-dd33-44ee44ee44ee +createdDateTime : 18/07/2024 05:13:40 +userIdentities : {@{issuer=SawyerM@contoso.com; signInType=userPrincipalName; issuerAssignedId=SawyerM@contoso.com}} ``` This example shows how to retrieve the extension attributes for a specified user. You can use the command `Get-EntraBetaUser` to get user object Id. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md index 85f43e817..71433e536 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaUserOAuth2PermissionGrant.md @@ -72,7 +72,7 @@ This example retrieves the OAuth2 permission grants for a user using the ObjectI ```powershell Connect-Entra -Scopes 'Directory.Read.All' -Get-EntraUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' +Get-EntraBetaUserOAuth2PermissionGrant -UserId 'SawyerM@contoso.com' ``` ```Output diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md index 7456df898..96b66cd87 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraUserExtension.md @@ -46,9 +46,12 @@ Get-EntraUserExtension -UserId $UserId ``` ```Output -Id --- -com.contoso.roamingSettings +onPremisesDistinguishedName : +@odata.context : https://graph.microsoft.com/v1.0/$metadata#users(identities,onPremisesDistinguishedName,employeeId,createdDateTime)/$entity +createdDateTime : 18/07/2024 05:13:40 +employeeId : +identities : {@{signInType=userPrincipalName; issuerAssignedId=SawyerM@contoso.com; issuer=SawyerM@contoso.com}} +userIdentities : {@{signInType=userPrincipalName; issuerAssignedId=SawyerM@contoso.com; issuer=SawyerM@contoso.com}} ``` This example shows how to retrieve the extension attributes for a specified user. You can use the command `Get-EntraUser` to get user object Id. diff --git a/test/module/Entra/Get-EntraUserExtension.Tests.ps1 b/test/module/Entra/Get-EntraUserExtension.Tests.ps1 new file mode 100644 index 000000000..bc64546e0 --- /dev/null +++ b/test/module/Entra/Get-EntraUserExtension.Tests.ps1 @@ -0,0 +1,81 @@ +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra) -eq $null) { + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $PSScriptRoot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @{ + "employeeId" = $null + "createdDateTime" = $null + "onPremisesDistinguishedName" = $null + "identities" = @("testuser@contoso.com") + "Parameters" = $args + } + } + + Mock -CommandName Invoke-GraphRequest -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraUserExtension" { + Context "Test for Get-EntraUserExtension" { + It "Should return user extensions" { + $result = Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should execute successfully with Alias" { + $result = Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraUserExtension" + $result = Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should fail when UserId is empty string value" { + { Get-EntraUserExtension -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." + } + + It "Should fail when UserId is empty" { + { Get-EntraUserExtension -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." + } + + It "Property parameter should work" { + $result = Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property DisplayName + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + + It "Should fail when Property is empty" { + { Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" + } + + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { + Get-EntraUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug + } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaUserExtension.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaUserExtension.Tests.ps1 new file mode 100644 index 000000000..43263c7a2 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaUserExtension.Tests.ps1 @@ -0,0 +1,81 @@ +BeforeAll { + if ((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null) { + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $PSScriptRoot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @{ + "employeeId" = $null + "createdDateTime" = $null + "onPremisesDistinguishedName" = $null + "identities" = @("testuser@contoso.com") + "Parameters" = $args + } + } + + Mock -CommandName Invoke-GraphRequest -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} +Describe "Get-EntraBetaUserExtension" { + Context "Test for Get-EntraBetaUserExtension" { + It "Should return user extensions" { + $result = Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should execute successfully with Alias" { + $result = Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaUserExtension" + $result = Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } + } + + It "Should fail when UserId is empty string value" { + { Get-EntraBetaUserExtension -UserId "" } | Should -Throw "Cannot bind argument to parameter 'UserId' because it is an empty string." + } + + It "Should fail when UserId is empty" { + { Get-EntraBetaUserExtension -UserId } | Should -Throw "Missing an argument for parameter 'UserId'. Specify a parameter of type 'System.String' and try again." + } + + It "Property parameter should work" { + $result = Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property DisplayName + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + + It "Should fail when Property is empty" { + { Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Property } | Should -Throw "Missing an argument for parameter 'Property'.*" + } + + It "Should execute successfully without throwing an error " { + # Disable confirmation prompts + $originalDebugPreference = $DebugPreference + $DebugPreference = 'Continue' + + try { + # Act & Assert: Ensure the function doesn't throw an exception + { + Get-EntraBetaUserExtension -UserId "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug + } | Should -Not -Throw + } finally { + # Restore original confirmation preference + $DebugPreference = $originalDebugPreference + } + } + } +} \ No newline at end of file From 9bbbff84da6183d91d7cde69d64830057cf461ca Mon Sep 17 00:00:00 2001 From: varsha Date: Tue, 1 Oct 2024 22:22:24 +0530 Subject: [PATCH 60/64] resolved comments --- .../Add-EntraBetaDeviceRegisteredUser.md | 2 +- .../Remove-EntraBetaGroupAppRoleAssignment.md | 2 +- .../Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md | 2 +- .../Microsoft.Graph.Entra/Add-EntraGroupOwner.md | 2 +- .../Microsoft.Graph.Entra/Remove-EntraUser.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md index 6882839af..fbf985e7e 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Add-EntraBetaDeviceRegisteredUser.md @@ -42,7 +42,7 @@ The `Add-EntraBetaDeviceRegisteredUser` cmdlet adds a registered user for a Micr ```powershell Connect-Entra -Scopes 'Device.ReadWrite.All' -$User = Get-EntraBetaUser -ObjectId 'SawyerM@contoso.com' +$User = Get-EntraBetaUser -UserId 'SawyerM@contoso.com' $Device = Get-EntraBetaDevice -SearchString '' $params = @{ DeviceId = $Device.ObjectId diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md index 4ea7391c7..3b36a45c9 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaGroupAppRoleAssignment.md @@ -41,7 +41,7 @@ The `Remove-EntraBetaGroupAppRoleAssignment` cmdlet removes a group application Connect-Entra -Scopes 'Directory.ReadWrite.All' $group = Get-EntraBetaGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" $params = @{ - GroupId = 'hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq' + GroupId = $group.Id AppRoleAssignmentId = 'CcDdEeFfGgHhIiJjKkLlMmNnOoPpQq3' } Remove-EntraBetaGroupAppRoleAssignment @params diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md index 8ca18f41e..231fb03b1 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraDeviceRegisteredUser.md @@ -42,7 +42,7 @@ The `Add-EntraDeviceRegisteredUser` cmdlet adds a registered user for a Microsof ```powershell Connect-Entra -Scopes 'Device.ReadWrite.All' -$User = Get-EntraUser -ObjectId 'SawyerM@contoso.com' +$User = Get-EntraUser -UserId 'SawyerM@contoso.com' $Device = Get-EntraDevice -SearchString '' $params = @{ DeviceId = $Device.ObjectId diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md index 597beff6f..39513fd99 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Add-EntraGroupOwner.md @@ -46,7 +46,7 @@ The `Add-EntraGroupOwner` cmdlet adds an owner to a Microsoft Entra ID group. Sp ```powershell Connect-Entra -Scopes 'Group.ReadWrite.All' $group = Get-EntraGroup -Filter "DisplayName eq 'HelpDesk Team Leaders'" -$user = Get-EntraUser -ObjectId 'SawyerM@contoso.com' +$user = Get-EntraUser -UserId 'SawyerM@contoso.com' $params = @{ GroupId = $group.ObjectId RefObjectId = $user.ObjectId diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md index 694ce77e7..43290dbaa 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraUser.md @@ -32,7 +32,7 @@ Remove-EntraUser ## Description -The Remove-EntraUser cmdlet removes a user in Microsoft Entra ID. Specify the `UserId` parameter to remove the specified user in Microsoft Entra ID. +The `Remove-EntraUser` cmdlet removes a user in Microsoft Entra ID. Specify the `UserId` parameter to remove the specified user in Microsoft Entra ID. The calling user must be assigned at least one of the following Microsoft Entra roles: From 6807c2f914da183a9b0838441ad31b58ea60d1c7 Mon Sep 17 00:00:00 2001 From: varsha Date: Tue, 1 Oct 2024 22:36:08 +0530 Subject: [PATCH 61/64] resolved comments --- .../Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md index 556bfcb16..c4677b7e8 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraScopedRoleMembership.md @@ -44,7 +44,7 @@ The `Remove-EntraScopedRoleMembership` cmdlet removes a scoped role membership f Connect-Entra -Scopes 'RoleManagement.Read.Directory' $AdministrativeUnit = Get-EntraAdministrativeUnit -Filter "DisplayName eq ''" $params = @{ - AdministrativeUnitId = $AdministrativeUnit.ObjectId + AdministrativeUnitId = $AdministrativeUnit.AdministrativeUnitId ScopedRoleMembershipId = 'dddddddddddd-bbbb-aaaa-bbbb-cccccccccccc' } Remove-EntraScopedRoleMembership @params From b05413f5081ce6437dfa5932d07d9119b7801da3 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 2 Oct 2024 11:29:43 +0530 Subject: [PATCH 62/64] resolved PR comments --- .../Get-EntraBetaDirectoryRoleDefinition.ps1 | 4 ++-- .../EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 | 2 +- ...Remove-EntraBetaServicePrincipalPasswordCredential.ps1 | 6 ++---- .../customizations/Set-EntraBetaAttributeSet.ps1 | 2 +- .../Get-EntraBetaDeletedGroup.md | 2 +- .../New-EntraBetaApplicationPasswordCredential.md | 8 ++++---- .../Microsoft.Graph.Entra.Beta/Remove-EntraBetaContact.md | 8 ++++---- .../Remove-EntraBetaDeviceRegisteredUser.md | 2 +- .../Remove-EntraBetaDirectoryRoleAssignment.md | 5 ++--- .../Remove-EntraBetaDirectoryRoleDefinition.md | 4 ++-- .../Microsoft.Graph.Entra/Get-EntraDeletedGroup.md | 2 +- .../Get-EntraGroupAppRoleAssignment.md | 8 ++++---- .../New-EntraApplicationPasswordCredential.md | 8 ++++---- .../New-EntraGroupAppRoleAssignment.md | 2 +- .../Remove-EntraDeviceRegisteredUser.md | 2 +- .../Remove-EntraDirectoryRoleAssignment.md | 5 ++--- .../Remove-EntraDirectoryRoleDefinition.md | 4 ++-- 17 files changed, 35 insertions(+), 39 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 index 25b307ba5..2a93abdc9 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 @@ -27,9 +27,9 @@ $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $keysChanged = @{SearchString = "Filter"} - if($null -ne $PSBoundParameters["Id"]) + if($null -ne $PSBoundParameters["UnifiedRoleDefinitionId"]) { - $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["Id"] + $params["UnifiedRoleDefinitionId"] = $PSBoundParameters["UnifiedRoleDefinitionId"] } if($null -ne $PSBoundParameters["Filter"]) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 index e1ca74d67..e5ae20240 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 @@ -96,7 +96,7 @@ if ($null -ne $_) { Add-Member -InputObject $_ -NotePropertyMembers $_.AdditionalProperties Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id - $propsToConvert = @('assignedLicenses','assignedPlans','provisionedPlans','identities') + $propsToConvert = @('assignedLicenses','assignedPlans','provisionedPlans','identities') foreach ($prop in $propsToConvert) { if ($null -ne $_.PSObject.Properties[$prop]) { $value = $_.$prop | ConvertTo-Json | ConvertFrom-Json diff --git a/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 b/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 index dc6b0d500..bbeb0d237 100644 --- a/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 +++ b/module/EntraBeta/customizations/Remove-EntraBetaServicePrincipalPasswordCredential.ps1 @@ -7,7 +7,6 @@ Parameters = $null Outputs = $null CustomScript = @' - function Remove-EntraBetaServicePrincipalPasswordCredential { [CmdletBinding(DefaultParameterSetName = '')] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -21,7 +20,7 @@ $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $baseUri = 'https://graph.microsoft.com/beta/servicePrincipals' - $Method = "POST" + $Method = "POST" if($null -ne $PSBoundParameters["ServicePrincipalId"] -and $null -ne $PSBoundParameters["KeyId"]) { $params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"] @@ -35,7 +34,6 @@ $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") (Invoke-GraphRequest -Headers $customHeaders -Uri $URI -Method $Method -Body $body) - } -} + } '@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 b/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 index 7641ebb7e..636eb66fd 100644 --- a/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 +++ b/module/EntraBeta/customizations/Set-EntraBetaAttributeSet.ps1 @@ -19,7 +19,7 @@ ) PROCESS { $params = @{} - $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand if ($null -ne $PSBoundParameters["AttributeSetId"]) { diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md index 554ce613c..a3f211b9b 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Get-EntraBetaDeletedGroup.md @@ -79,7 +79,7 @@ test23 cccccccc-2222-3333-4444-dddddddddddd test23 desc3 {Unifi test24 dddddddd-3333-4444-5555-eeeeeeeeeeee test24 desc4 {Unified, DynamicMembership} ``` -This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra GroupId. +This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra ID. ### Example 2: Get deleted groups in the directory using All parameter diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md index 189ca0108..cb2c9ba98 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/New-EntraBetaApplicationPasswordCredential.md @@ -55,7 +55,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. ### Example 2: Create a password credential using CustomKeyIdentifier parameter @@ -78,7 +78,7 @@ CustomKeyIdentifier DisplayName EndDateTime This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-CustomKeyIdentifier` Speicifies unique binary identifier. ### Example 3: Create a password credential using StartDate parameter @@ -103,7 +103,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-StartDate` Speicifies the date and time at which the password becomes valid. ### Example 4: Create a password credential using EndDate parameter @@ -128,7 +128,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-EndDate` Speicifies The date and time at which the password expires. ## Parameters diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaContact.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaContact.md index d2ada0eca..d611cd079 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaContact.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaContact.md @@ -27,7 +27,7 @@ Removes a contact. ```powershell Remove-EntraBetaContact - -ObjectId + -OrgContactId [] ``` @@ -42,21 +42,21 @@ The `Remove-EntraBetaContact` removes a contact from Microsoft Entra ID. ```powershell Connect-Entra -Scopes 'OrgContact.Read.All' $Contact = Get-EntraBetaContact -Filter "DisplayName eq 'Contoso Contact'" -Remove-EntraBetaContact -ObjectId $Contact.ObjectId +Remove-EntraBetaContact -OrgContactId $Contact.ObjectId ``` The example shows how to remove a contact. ## Parameters -### -ObjectId +### -OrgContactId Specifies the object ID of a contact in Microsoft Entra ID. ```yaml Type: System.String Parameter Sets: (All) -Aliases: +Aliases: ObjectId Required: True Position: Named diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md index 910e0ff37..9b23da22a 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDeviceRegisteredUser.md @@ -44,7 +44,7 @@ The `Remove-EntraBetaDeviceRegisteredUser` cmdlet removes a registered user from Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraBetaDevice -Top 1 $User = Get-EntraBetaDeviceRegisteredUser -DeviceId $Device.ObjectId -Remove-EntraBetaDeviceRegisteredUser -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId +Remove-EntraBetaDeviceRegisteredUser -DeviceId $Device.ObjectId -UserId $User.ObjectId ``` This example shows how to remove the registered user from device. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md index 70467da70..358410f3d 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleAssignment.md @@ -39,9 +39,8 @@ The `Remove-EntraBetaDirectoryRoleAssignment` cmdlet removes a role assignment f ### Example 1: Remove a role assignment ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' #For the directory (Microsoft Entra ID) provider - Connect-Entra -Scopes 'EntitlementManagement.ReadWrite.All' #For the entitlement management provider - Remove-EntraBetaDirectoryRoleAssignment -UnifiedRoleAssignmentId 'Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1' +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory','EntitlementManagement.ReadWrite.All' +Remove-EntraBetaDirectoryRoleAssignment -UnifiedRoleAssignmentId 'Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1' ``` This example removes the specified role assignment from Microsoft Entra ID. diff --git a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md index aac13c062..4c5de3ec4 100644 --- a/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta/Remove-EntraBetaDirectoryRoleDefinition.md @@ -41,8 +41,8 @@ You can't delete built-in roles. This feature requires a Microsoft Entra ID P1 o ### Example 1: Remove a specified role definition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - Remove-EntraBetaDirectoryRoleDefinition -UnifiedRoleDefinitionId 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +Remove-EntraBetaDirectoryRoleDefinition -UnifiedRoleDefinitionId 'a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1' ``` This example demonstrates how to remove the specified role definition from Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md index 4ac745867..52d3fe53f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md @@ -89,7 +89,7 @@ test23 cccccccc-2222-3333-4444-dddddddddddd test23 desc3 {Unifi test24 dddddddd-3333-4444-5555-eeeeeeeeeeee test24 desc4 {Unified, DynamicMembership} ``` -This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra DirectoryObjectId. +This cmdlet retrieves all recoverable deleted groups in the Microsoft Entra ID. ### Example 2: Get deleted groups in the directory using All parameter diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md index 8591248ca..724b696ce 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraGroupAppRoleAssignment.md @@ -35,7 +35,7 @@ Get-EntraGroupAppRoleAssignment ## Description -The `Get-EntraGroupAppRoleAssignment` cmdlet gets a group application role assignment in Microsoft Entra ID. Specify the `ObjectId` parameter to get a group application role assignment. +The `Get-EntraGroupAppRoleAssignment` cmdlet gets a group application role assignment in Microsoft Entra ID. Specify the `GroupId` parameter to get a group application role assignment. ## Examples @@ -57,7 +57,7 @@ MSVrBV4APk--eAGnHqMKBDtEqPRvu8xLqWHDSXUhoTE M365 License Manager This example retrieves the application role assignments of a group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ### Example 2: Retrieve all application role assignments of a group @@ -76,7 +76,7 @@ MSVrBV4APk--eAGnHqMKBDtEqPRvu8xLqWHDSXUhoTE M365 License Manager This example retrieves all application role assignments of the specified group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ### Example 3: Retrieve top two application role assignments of a group @@ -94,7 +94,7 @@ MSVrBV4APk--eAGnHqMKBExhQK4StEFHidLvUymzo4I ProvisioningPowerBi This example retrieves top two application role assignments of the specified group. -- `-ObjectId` parameter specifies the ID of a group in Microsoft Entra ID. +- `-GroupId` parameter specifies the ID of a group in Microsoft Entra ID. ## Parameters diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md index e92bc799c..669aabe30 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraApplicationPasswordCredential.md @@ -56,7 +56,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. ### Example 2: Create a password credential using CustomKeyIdentifier parameter @@ -79,7 +79,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-CustomKeyIdentifier` Speicifies unique binary identifier. ### Example 3: Create a password credential using StartDate parameter @@ -104,7 +104,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-StartDate` Speicifies the date and time at which the password becomes valid. ### Example 4: Create a password credential using EndDate parameter @@ -129,7 +129,7 @@ CustomKeyIdentifier DisplayName EndDateTime Hint KeyId This command creates new password credential for specified application. -- `-ApplicationId` Specifies the ID of a user. +- `-ApplicationId` Specifies the ID of an application. - `-EndDate` Speicifies The date and time at which the password expires. ## Parameters diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md index 7fd9b7adb..d323d6f0f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/New-EntraGroupAppRoleAssignment.md @@ -47,7 +47,7 @@ Connect-Entra -Scopes 'AppRoleAssignment.ReadWrite.All' $appname = 'Box' $spo = Get-EntraServicePrincipal -Filter "Displayname eq '$appname'" $group = Get-EntraGroup -SearchString 'Contoso Team' -New-EntraGroupAppRoleAssignment -GroupId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -Id $spo.Approles[1].id +New-EntraGroupAppRoleAssignment -GroupId $group.ObjectId -PrincipalId $group.ObjectId -ResourceId $spo.ObjectId -AppRoleId $spo.Approles[1].id ``` ```Output diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md index 79e3631e7..c608af39f 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDeviceRegisteredUser.md @@ -43,7 +43,7 @@ The `Remove-EntraDeviceRegisteredUser` cmdlet removes a registered user from a M Connect-Entra -Scopes 'Directory.AccessAsUser.All' $Device = Get-EntraDevice -Top 1 $User = Get-EntraDeviceRegisteredUser -DeviceId $Device.ObjectId -Remove-EntraDeviceRegisteredOwner -DeviceId $Device.ObjectId -OwnerId $Owner.ObjectId +Remove-EntraDeviceRegisteredUser -DeviceId $Device.ObjectId -UserId $User.ObjectId ``` This example shows how to remove the registered user from device. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md index bee29b3b1..356342876 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleAssignment.md @@ -39,9 +39,8 @@ The `Remove-EntraDirectoryRoleAssignment` cmdlet removes a role assignment from ### Example 1: Remove a role assignment ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' #For the directory (Microsoft Entra ID) provider - Connect-Entra -Scopes 'EntitlementManagement.ReadWrite.All' #For the entitlement management provider - Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1 +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory','EntitlementManagement.ReadWrite.All' +Remove-EntraDirectoryRoleAssignment -UnifiedRoleAssignmentId Y1vFBcN4i0e3ngdNDocmngJAWGnAbFVAnJQyBBLv1lM-1 ``` This example removes the specified role assignment from Microsoft Entra ID. diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md index 49dd26d35..cd0fcae68 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Remove-EntraDirectoryRoleDefinition.md @@ -42,8 +42,8 @@ You can't delete built-in roles. This feature requires a Microsoft Entra ID P1 o ### Example 1: Remove a specified role definition ```powershell - Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' - Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 +Connect-Entra -Scopes 'RoleManagement.ReadWrite.Directory' +Remove-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1 ``` This example demonstrates how to remove the specified role definition from Microsoft Entra ID. From 85149cd122b4501c2f1b00844f8347565889bf25 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 2 Oct 2024 12:23:12 +0530 Subject: [PATCH 63/64] fixed PR comments --- .../customizations/Get-EntraDeletedGroup.ps1 | 136 ++++++++++++++++-- .../Get-EntraBetaDeletedGroup.ps1 | 136 ++++++++++++++++-- .../Get-EntraDeletedGroup.md | 14 +- .../Entra/Get-EntraDeletedGroup.Tests.ps1 | 28 ++-- .../Get-EntraBetaDeletedGroup.Tests.ps1 | 28 ++-- 5 files changed, 285 insertions(+), 57 deletions(-) diff --git a/module/Entra/customizations/Get-EntraDeletedGroup.ps1 b/module/Entra/customizations/Get-EntraDeletedGroup.ps1 index d35f0fc8b..de79e5f03 100644 --- a/module/Entra/customizations/Get-EntraDeletedGroup.ps1 +++ b/module/Entra/customizations/Get-EntraDeletedGroup.ps1 @@ -3,16 +3,130 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Get-AzureADMSDeletedGroup" - TargetName = "Get-MgDirectoryDeletedItemAsGroup" - Parameters = @( - @{ - SourceName = "SearchString" - TargetName = "Filter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $Value = "mailNickName eq '$TmpValue' or (mail eq '$TmpValue' or (displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')))" -'@ - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Alias('Id')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + $keysChanged = @{SearchString = "Filter"} + if ($null -ne $PSBoundParameters["PipelineVariable"]) + { + $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] + } + if ($null -ne $PSBoundParameters["ProgressAction"]) + { + $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + } + if($PSBoundParameters.ContainsKey("Debug")) + { + $params["Debug"] = $PSBoundParameters["Debug"] + } + if ($null -ne $PSBoundParameters["WarningAction"]) + { + $params["WarningAction"] = $PSBoundParameters["WarningAction"] + } + if ($null -ne $PSBoundParameters["ErrorVariable"]) + { + $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] + } + if($null -ne $PSBoundParameters["Filter"]) + { + $TmpValue = $PSBoundParameters["Filter"] + foreach($i in $keysChanged.GetEnumerator()){ + $TmpValue = $TmpValue.Replace($i.Key, $i.Value) + } + $Value = $TmpValue + $params["Filter"] = $Value + } + if($PSBoundParameters.ContainsKey("Verbose")) + { + $params["Verbose"] = $PSBoundParameters["Verbose"] + } + if ($null -ne $PSBoundParameters["ErrorAction"]) + { + $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] + } + if ($null -ne $PSBoundParameters["InformationAction"]) + { + $params["InformationAction"] = $PSBoundParameters["InformationAction"] + } + if($null -ne $PSBoundParameters["All"]) + { + if($PSBoundParameters["All"]) + { + $params["All"] = $PSBoundParameters["All"] + } + } + if ($null -ne $PSBoundParameters["WarningVariable"]) + { + $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] + } + if ($null -ne $PSBoundParameters["InformationVariable"]) + { + $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] + } + if($null -ne $PSBoundParameters["SearchString"]) + { + $TmpValue = $PSBoundParameters["SearchString"] + $Value = "mailNickName eq '$TmpValue' or (mail eq '$TmpValue' or (displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')))" + $params["Filter"] = $Value + } + if ($null -ne $PSBoundParameters["GroupId"]) + { + $params["DirectoryObjectId"] = $PSBoundParameters["GroupId"] + } + if ($null -ne $PSBoundParameters["OutBuffer"]) + { + $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] + } + if ($null -ne $PSBoundParameters["OutVariable"]) + { + $params["OutVariable"] = $PSBoundParameters["OutVariable"] + } + if ($PSBoundParameters.ContainsKey("Top")) + { + $params["Top"] = $PSBoundParameters["Top"] + } + if($null -ne $PSBoundParameters["Property"]) + { + $params["Property"] = $PSBoundParameters["Property"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = Get-MgDirectoryDeletedItemAsGroup @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + + } + } + $response + } +'@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeletedGroup.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeletedGroup.ps1 index afa6bb58a..7bfe3309a 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeletedGroup.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeletedGroup.ps1 @@ -3,16 +3,130 @@ # ------------------------------------------------------------------------------ @{ SourceName = "Get-AzureADMSDeletedGroup" - TargetName = "Get-MgBetaDirectoryDeletedItemAsGroup" - Parameters = @( - @{ - SourceName = "SearchString" - TargetName = "Filter" - ConversionType = "ScriptBlock" - SpecialMapping = @' - $Value = "mailNickName eq '$TmpValue' or (mail eq '$TmpValue' or (displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')))" -'@ - } - ) + TargetName = $null + Parameters = $null Outputs = $null + CustomScript = @' + [CmdletBinding(DefaultParameterSetName = 'GetQuery')] + param ( + + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.Nullable`1[System.Int32]] $Top, + [Alias('Id')] + [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $GroupId, + + [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [switch] $All, + + [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $Filter, + + [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [System.String] $SearchString, + [Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] + [System.String[]] $Property + ) + + PROCESS { + $params = @{} + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand + $keysChanged = @{SearchString = "Filter"} + if ($null -ne $PSBoundParameters["WarningAction"]) + { + $params["WarningAction"] = $PSBoundParameters["WarningAction"] + } + if ($PSBoundParameters.ContainsKey("Top")) + { + $params["Top"] = $PSBoundParameters["Top"] + } + if ($null -ne $PSBoundParameters["ProgressAction"]) + { + $params["ProgressAction"] = $PSBoundParameters["ProgressAction"] + } + if ($null -ne $PSBoundParameters["ErrorVariable"]) + { + $params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] + } + if ($null -ne $PSBoundParameters["InformationAction"]) + { + $params["InformationAction"] = $PSBoundParameters["InformationAction"] + } + if ($null -ne $PSBoundParameters["GroupId"]) + { + $params["DirectoryObjectId"] = $PSBoundParameters["GroupId"] + } + if ($null -ne $PSBoundParameters["OutBuffer"]) + { + $params["OutBuffer"] = $PSBoundParameters["OutBuffer"] + } + if ($null -ne $PSBoundParameters["OutVariable"]) + { + $params["OutVariable"] = $PSBoundParameters["OutVariable"] + } + if($PSBoundParameters.ContainsKey("Verbose")) + { + $params["Verbose"] = $PSBoundParameters["Verbose"] + } + if ($null -ne $PSBoundParameters["InformationVariable"]) + { + $params["InformationVariable"] = $PSBoundParameters["InformationVariable"] + } + if ($null -ne $PSBoundParameters["PipelineVariable"]) + { + $params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] + } + if($null -ne $PSBoundParameters["All"]) + { + if($PSBoundParameters["All"]) + { + $params["All"] = $PSBoundParameters["All"] + } + } + if ($null -ne $PSBoundParameters["ErrorAction"]) + { + $params["ErrorAction"] = $PSBoundParameters["ErrorAction"] + } + if ($null -ne $PSBoundParameters["WarningVariable"]) + { + $params["WarningVariable"] = $PSBoundParameters["WarningVariable"] + } + if($null -ne $PSBoundParameters["Filter"]) + { + $TmpValue = $PSBoundParameters["Filter"] + foreach($i in $keysChanged.GetEnumerator()){ + $TmpValue = $TmpValue.Replace($i.Key, $i.Value) + } + $Value = $TmpValue + $params["Filter"] = $Value + } + if($PSBoundParameters.ContainsKey("Debug")) + { + $params["Debug"] = $PSBoundParameters["Debug"] + } + if($null -ne $PSBoundParameters["SearchString"]) + { + $TmpValue = $PSBoundParameters["SearchString"] + $Value = "mailNickName eq '$TmpValue' or (mail eq '$TmpValue' or (displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')))" + $params["Filter"] = $Value + } + if($null -ne $PSBoundParameters["Property"]) + { + $params["Property"] = $PSBoundParameters["Property"] + } + + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = Get-MgBetaDirectoryDeletedItemAsGroup @params -Headers $customHeaders + $response | ForEach-Object { + if($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + + } + } + $response + } +'@ } \ No newline at end of file diff --git a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md index 52d3fe53f..f85a85737 100644 --- a/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md +++ b/module/docs/entra-powershell-v1.0/Microsoft.Graph.Entra/Get-EntraDeletedGroup.md @@ -49,7 +49,7 @@ Get-EntraDeletedGroup ```powershell Get-EntraDeletedGroup - -DirectoryObjectId + -GroupId [-All] [-Property ] [] @@ -158,11 +158,11 @@ test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unifi This cmdlet retrieves deleted groups in the directory, having the specified display name. -### Example 6: Get deleted group by DirectoryObjectId +### Example 6: Get deleted group by GroupId ```powershell Connect-Entra -Scopes 'Group.Read.All' -Get-EntraDeletedGroup -DirectoryObjectId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' +Get-EntraDeletedGroup -GroupId 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' ``` ```Output @@ -171,9 +171,9 @@ DisplayName Id MailNickname Description GroupT test21 aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb test21 desc1 {Unified, DynamicMembership} ``` -This cmdlet retrieves the deleted group specified by DirectoryObjectId. +This cmdlet retrieves the deleted group specified by GroupId. -- `-DirectoryObjectId` parameter specifies the deleted group DirectoryObjectId. +- `-GroupId` parameter specifies the deleted group GroupId. ## Parameters @@ -210,9 +210,9 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` -### -DirectoryObjectId +### -GroupId -The DirectoryObjectId of the deleted group to be retrieved. +The GroupId of the deleted group to be retrieved. ```yaml Type: System.String diff --git a/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 b/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 index 0b6fea711..4db95da6a 100644 --- a/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 +++ b/test/module/Entra/Get-EntraDeletedGroup.Tests.ps1 @@ -31,7 +31,7 @@ BeforeAll { Describe "Get-EntraDeletedGroup" { Context "Test for Get-EntraDeletedGroup" { It "Should return specific Deleted Group" { - $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.DisplayName | Should -Be "Mock-App" @@ -48,11 +48,11 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when DirectoryObjectId is empty" { - { Get-EntraDeletedGroup -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraDeletedGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when DirectoryObjectId is invalid" { - { Get-EntraDeletedGroup -DirectoryObjectId ""} | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraDeletedGroup -GroupId ""} | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should return All deleted groups" { $result = Get-EntraDeletedGroup -All @@ -61,7 +61,7 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when All is invalid" { - { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 deleted group" { $result = Get-EntraDeletedGroup -Top 1 @@ -73,10 +73,10 @@ Context "Test for Get-EntraDeletedGroup" { Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Top is empty" { - { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return specific deleted group by filter" { $result = Get-EntraDeletedGroup -Filter "DisplayName eq 'Mock-App'" @@ -103,17 +103,17 @@ Context "Test for Get-EntraDeletedGroup" { { Get-EntraDeletedGroup -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" } It "Property parameter should work" { - $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } - It "Should contain DirectoryObjectId in parameters when passed Id to it" { - $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain GroupId in parameters when passed Id to it" { + $result = Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.DirectoryObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -124,7 +124,7 @@ Context "Test for Get-EntraDeletedGroup" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedGroup" - $result = Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedGroup" Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { @@ -139,7 +139,7 @@ Context "Test for Get-EntraDeletedGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 index feabb79f0..db26961f4 100644 --- a/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 +++ b/test/module/EntraBeta/Get-EntraBetaDeletedGroup.Tests.ps1 @@ -31,7 +31,7 @@ BeforeAll { Describe "Get-EntraBetaDeletedGroup" { Context "Test for Get-EntraBetaDeletedGroup" { It "Should return specific Deleted Group" { - $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $result.Id | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result.DisplayName | Should -Be "Mock-App" @@ -48,11 +48,11 @@ Context "Test for Get-EntraBetaDeletedGroup" { Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } - It "Should fail when DirectoryObjectId is empty" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId } | Should -Throw "Missing an argument for parameter 'DirectoryObjectId'*" + It "Should fail when GroupId is empty" { + { Get-EntraBetaDeletedGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" } - It "Should fail when DirectoryObjectId is invalid" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId ""} | Should -Throw "Cannot bind argument to parameter 'DirectoryObjectId' because it is an empty string." + It "Should fail when GroupId is invalid" { + { Get-EntraBetaDeletedGroup -GroupId ""} | Should -Throw "Cannot bind argument to parameter 'GroupId' because it is an empty string." } It "Should return All deleted groups" { $result = Get-EntraBetaDeletedGroup -All @@ -61,7 +61,7 @@ Context "Test for Get-EntraBetaDeletedGroup" { Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when All is invalid" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" + { Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -All xyz } | Should -Throw "A positional parameter cannot be found that accepts argument 'xyz'.*" } It "Should return top 1 deleted group" { $result = Get-EntraBetaDeletedGroup -Top 1 @@ -73,10 +73,10 @@ Context "Test for Get-EntraBetaDeletedGroup" { Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Top is empty" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" + { Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" } It "Should fail when Top is invalid" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" + { Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Top xyz } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" } It "Should return specific deleted group by filter" { $result = Get-EntraBetaDeletedGroup -Filter "DisplayName eq 'Mock-App'" @@ -103,17 +103,17 @@ Context "Test for Get-EntraBetaDeletedGroup" { { Get-EntraBetaDeletedGroup -SearchString } | Should -Throw "Missing an argument for parameter 'SearchString'*" } It "Property parameter should work" { - $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName + $result = Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 } It "Should fail when Property is empty" { - { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } - It "Should contain DirectoryObjectId in parameters when passed Id to it" { - $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + It "Should contain GroupId in parameters when passed Id to it" { + $result = Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $params = Get-Parameters -data $result.Parameters $params.DirectoryObjectId | Should -Be "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" } @@ -124,7 +124,7 @@ Context "Test for Get-EntraBetaDeletedGroup" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeletedGroup" - $result = Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" + $result = Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" $result | Should -Not -BeNullOrEmpty $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaDeletedGroup" Should -Invoke -CommandName Get-MgBetaDirectoryDeletedItemAsGroup -ModuleName Microsoft.Graph.Entra.Beta -Times 1 -ParameterFilter { @@ -139,7 +139,7 @@ Context "Test for Get-EntraBetaDeletedGroup" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaDeletedGroup -DirectoryObjectId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw + { Get-EntraBetaDeletedGroup -GroupId "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference From ad0882669b0aed7e0780b8ab16d9cb7ff59052b7 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Wed, 2 Oct 2024 15:35:53 +0530 Subject: [PATCH 64/64] fixed build error --- .../Get-EntraBetaUserExtension.ps1 | 2 +- ...Get-EntraDirectoryRoleDefinition.Tests.ps1 | 20 +++++++++---------- ...ervicePrincipalAppRoleAssignment.Tests.ps1 | 8 +++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 index 5bd7c3eb3..ec3d33e3c 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserExtension.ps1 @@ -17,7 +17,7 @@ ) PROCESS { $params = @{} - $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand + $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand $baseUri = "https://graph.microsoft.com/beta/users/$UserId" $properties = '$select=Identities,OnPremisesDistinguishedName,EmployeeId,CreatedDateTime' $params["Uri"] = "$baseUri/?$properties" diff --git a/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 index 941d47518..8723cf56e 100644 --- a/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 +++ b/test/module/Entra/Get-EntraDirectoryRoleDefinition.Tests.ps1 @@ -35,7 +35,7 @@ BeforeAll { Describe "Get-EntraDirectoryRoleDefinition" { Context "Test for Get-EntraDirectoryRoleDefinition" { It "Should return specificrole Defination" { - $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" + $result = Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be "Mock-App" $result.Id | Should -Be "0000aaaa-11bb-cccc-dd22-eeeeee333333" @@ -50,11 +50,11 @@ Describe "Get-EntraDirectoryRoleDefinition" { Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when DirectoryRoleId is empty" { - { Get-EntraDirectoryRoleDefinition -DirectoryRoleId } | Should -Throw "Missing an argument for parameter 'DirectoryRoleId'*" + It "Should fail when UnifiedRoleDefinitionId is empty" { + { Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId } | Should -Throw "Missing an argument for parameter 'UnifiedRoleDefinitionId'*" } - It "Should fail when DirectoryRoleId is invalid" { - { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "" } | Should -Throw "Cannot bind argument to parameter 'DirectoryRoleId' because it is an empty string." + It "Should fail when UnifiedRoleDefinitionId is invalid" { + { Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "" } | Should -Throw "Cannot bind argument to parameter 'UnifiedRoleDefinitionId' because it is an empty string." } It "Should return all role assignments" { $result = Get-EntraDirectoryRoleDefinition -All @@ -98,7 +98,7 @@ Describe "Get-EntraDirectoryRoleDefinition" { { Get-EntraDirectoryRoleDefinition -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" } It "Result should Contain ObjectId" { - $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" + $result = Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" $result.ObjectId | should -Be "0000aaaa-11bb-cccc-dd22-eeeeee333333" } It "Should contain Filter in parameters when passed SearchString to it" { @@ -107,19 +107,19 @@ Describe "Get-EntraDirectoryRoleDefinition" { $params.Filter | Should -Match "Mock-App" } It "Property parameter should work" { - $result = Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property DisplayName + $result = Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property DisplayName $result | Should -Not -BeNullOrEmpty $result.DisplayName | Should -Be 'Mock-App' Should -Invoke -CommandName Get-MgRoleManagementDirectoryRoleDefinition -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when Property is empty" { - { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" + { Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Property } | Should -Throw "Missing an argument for parameter 'Property'*" } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleDefinition" - Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" + Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRoleDefinition" @@ -135,7 +135,7 @@ Describe "Get-EntraDirectoryRoleDefinition" { try { # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraDirectoryRoleDefinition -DirectoryRoleId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Debug } | Should -Not -Throw + { Get-EntraDirectoryRoleDefinition -UnifiedRoleDefinitionId "0000aaaa-11bb-cccc-dd22-eeeeee333333" -Debug } | Should -Not -Throw } finally { # Restore original confirmation preference $DebugPreference = $originalDebugPreference diff --git a/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 b/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 index 427112cd6..62046b874 100644 --- a/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 +++ b/test/module/Entra/Remove-EntraServicePrincipalAppRoleAssignment.Tests.ps1 @@ -44,9 +44,11 @@ Describe "Remove-EntraServicePrincipalAppRoleAssignment" { } It "Should contain 'User-Agent' header" { $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraServicePrincipalAppRoleAssignment" - $result = Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + Remove-EntraServicePrincipalAppRoleAssignment -ServicePrincipalId "cc7fcc82-ac1b-4785-af47-2ca3b7052886" -AppRoleAssignmentId "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" + Should -Invoke -CommandName Remove-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter { + $Headers.'User-Agent' | Should -Be $userAgentHeaderValue + $true + } } It "Should execute successfully without throwing an error" { # Disable confirmation prompts