diff --git a/module/Entra/AdditionalFunctions/Find-EntraPermission.ps1 b/module/Entra/AdditionalFunctions/Find-EntraPermission.ps1 index 9a02567fc..07b545c24 100644 --- a/module/Entra/AdditionalFunctions/Find-EntraPermission.ps1 +++ b/module/Entra/AdditionalFunctions/Find-EntraPermission.ps1 @@ -90,10 +90,6 @@ function Find-EntraPermission { { $params["WarningAction"] = $PSBoundParameters["WarningAction"] } - if($null -ne $PSBoundParameters["Top"]) - { - $params["Top"] = $PSBoundParameters["Top"] - } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug diff --git a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 index 079753c35..ad9673a5a 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnit.ps1 @@ -4,92 +4,84 @@ 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.Nullable`1[System.Int32]] $Top, - [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [switch] $All, - [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $Filter + [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 ) PROCESS { - $params = @{} - $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" - } - if($null -ne $PSBoundParameters["All"]) - { - $uri = $baseUri - } - if($null -ne $PSBoundParameters["Top"] -and (-not $PSBoundParameters.ContainsKey("All"))) - { - $topCount = $PSBoundParameters["Top"] - if ($topCount -gt 999) { - $params["Uri"] += "&`$top=999" + $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" } - else{ - $params["Uri"] += "&`$top=$topCount" + 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" } - } - if($null -ne $PSBoundParameters["Filter"]) - { - $params["Filter"] = $PSBoundParameters["Filter"] - $Filter = $PSBoundParameters["Filter"] - $f = '$' + 'Filter' - $params["Uri"] += "&$f=$Filter" - } - - Write-Debug("============================ TRANSFORMATIONS ============================") - $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug - Write-Debug("=========================================================================`n") - - $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $($params.Uri) -Method GET) - if($response.ContainsKey('value')){ - $response = $response.value - } - $data = $response | ConvertTo-Json -Depth 10 | ConvertFrom-Json + Write-Debug("============================ TRANSFORMATIONS ============================") + $params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug + Write-Debug("=========================================================================`n") + + $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $($params.Uri) -Method GET) + $data = $response | ConvertTo-Json -Depth 10 | ConvertFrom-Json - try { - $data = $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json - $all = $All.IsPresent - $increment = $topCount - $data.Count - while ($response.'@odata.nextLink' -and (($all) -or ($increment -gt 0 -and -not $all))) { - $URI = $response.'@odata.nextLink' - if (-not $all) { - $topValue = [Math]::Min($increment, 999) - $URI = $URI.Replace('$top=999', "`$top=$topValue") - $increment -= $topValue + try { + $data = $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json + $all = $All.IsPresent + $increment = $topCount - $data.Count + while (($response.'@odata.nextLink' -and (($all -and ($increment -lt 0)) -or $increment -gt 0))) { + $params["Uri"] = $response.'@odata.nextLink' + if ($increment -gt 0) { + $topValue = [Math]::Min($increment, 999) + $params["Uri"] = $params["Uri"].Replace('$top=999', "`$top=$topValue") + $increment -= $topValue + } + $response = Invoke-GraphRequest @params + $data += $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json } - $response = Invoke-GraphRequest -Uri $URI -Method $Method - $data += $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json } - } catch {} - $data | ForEach-Object { - if($null -ne $_) { - Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id - Add-Member -InputObject $_ -MemberType AliasProperty -Name DeletionTimeStamp -Value deletedDateTime + catch {} + $data | ForEach-Object { + if ($null -ne $_) { + Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id + Add-Member -InputObject $_ -MemberType AliasProperty -Name DeletionTimeStamp -Value deletedDateTime + } } - } - - $aulist = @() - foreach($item in $data){ - $auType = New-Object Microsoft.Graph.PowerShell.Models.MicrosoftGraphAdministrativeUnit - $item.PSObject.Properties | ForEach-Object { - $propertyName = $_.Name.Substring(0,1).ToUpper() + $_.Name.Substring(1) - $propertyValue = $_.Value - $auType | Add-Member -MemberType NoteProperty -Name $propertyName -Value $propertyValue -Force + + if ($data) { + $aulist = @() + foreach ($item in $data) { + $auType = New-Object Microsoft.Graph.PowerShell.Models.MicrosoftGraphAdministrativeUnit + $item.PSObject.Properties | ForEach-Object { + $propertyName = $_.Name.Substring(0, 1).ToUpper() + $_.Name.Substring(1) + $propertyValue = $_.Value + $auType | Add-Member -MemberType NoteProperty -Name $propertyName -Value $propertyValue -Force + } + $aulist += $auType + } + $aulist } - $aulist += $auType - } - $aulist } } \ No newline at end of file diff --git a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 index e5d2f211c..0007a082d 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAdministrativeUnitMember.ps1 @@ -4,70 +4,68 @@ function Get-EntraAdministrativeUnitMember { [CmdletBinding(DefaultParameterSetName = 'GetQuery')] param ( - [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.String] $ObjectId, - [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [switch] $All + [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 ) PROCESS { $params = @{} + $topCount = $null $customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand $baseUri = "/v1.0/directory/administrativeUnits/$ObjectId/members?`$select=*" $params["Uri"] = "$baseUri" - if($null -ne $PSBoundParameters["ObjectId"]) - { + if ($null -ne $PSBoundParameters["ObjectId"]) { $params["AdministrativeUnitId"] = $PSBoundParameters["ObjectId"] } - if($null -ne $PSBoundParameters["All"]) - { - $uri = $baseUri - } - if($null -ne $PSBoundParameters["Top"] -and (-not $PSBoundParameters.ContainsKey("All"))) - { + if ($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { + $minTop = 999 $params["Uri"] += "&`$top=999" } - else{ + else { $params["Uri"] += "&`$top=$topCount" } } Write-Debug("============================ TRANSFORMATIONS ============================") - $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug + $params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $($params.Uri) -Method GET) - if($response.ContainsKey('value')){ - $response = $response.value - } - $data = $response | ConvertTo-Json -Depth 10 | ConvertFrom-Json try { $data = $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json $all = $All.IsPresent $increment = $topCount - $data.Count - while ($response.'@odata.nextLink' -and (($all) -or ($increment -gt 0 -and -not $all))) { - $URI = $response.'@odata.nextLink' - if (-not $all) { + while (($response.'@odata.nextLink' -and (($all -and ($increment -lt 0)) -or $increment -gt 0))) { + $params["Uri"] = $response.'@odata.nextLink' + if ($increment -gt 0) { $topValue = [Math]::Min($increment, 999) - $URI = $URI.Replace('$top=999', "`$top=$topValue") + if ($minTop) { + $params["Uri"] = $params["Uri"].Replace("`$top=$minTop", "`$top=$topValue") + } + else { + $params["Uri"] = $params["Uri"].Replace("`$top=$topCount", "`$top=$topValue") + } $increment -= $topValue } - $response = Invoke-GraphRequest -Uri $URI -Method $Method + $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $($params.Uri) -Method GET) $data += $response.value | ConvertTo-Json -Depth 10 | ConvertFrom-Json } - } catch {} + } + catch {} $data | ForEach-Object { - if($null -ne $_) { + if ($null -ne $_) { Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id } } - if($data){ + if ($data) { $memberList = @() foreach ($response in $data) { $memberType = New-Object Microsoft.Graph.PowerShell.Models.MicrosoftGraphDirectoryObject diff --git a/module/Entra/AdditionalFunctions/Get-EntraApplicationTemplate.ps1 b/module/Entra/AdditionalFunctions/Get-EntraApplicationTemplate.ps1 index 69bb25a01..851b890fa 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraApplicationTemplate.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraApplicationTemplate.ps1 @@ -7,7 +7,7 @@ function Get-EntraApplicationTemplate { [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Id, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [switch] $All, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -30,7 +30,7 @@ function Get-EntraApplicationTemplate { $selectProperties = $selectProperties -Join ',' $params["Uri"] = $uri+"?`$select=$($selectProperties)" } - if(($null -ne $PSBoundParameters["Top"] -and (-not $PSBoundParameters.ContainsKey("All"))) -or ($null -ne $PSBoundParameters["Top"] -and $null -ne $PSBoundParameters["All"])) + if(($PSBoundParameters.ContainsKey("Top") -and (-not $PSBoundParameters.ContainsKey("All"))) -or ($PSBoundParameters.ContainsKey("Top") -and $null -ne $PSBoundParameters["All"])) { $topCount = $PSBoundParameters["Top"] $params["Uri"] += "&`$top=$topCount" diff --git a/module/Entra/AdditionalFunctions/Get-EntraAuditDirectoryLog.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAuditDirectoryLog.ps1 index 8bb4555c6..2b6b69b3c 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAuditDirectoryLog.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAuditDirectoryLog.ps1 @@ -23,7 +23,7 @@ function Get-EntraAuditDirectoryLog { $params["Method"] = "GET" $params["Uri"] = "$baseUri"+"?" - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 b/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 index b0bc8e851..95ff8dfe8 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraAuditSignInLog.ps1 @@ -24,7 +24,7 @@ function Get-EntraAuditSignInLog { $params["Uri"] = "$baseUri" $query = $null - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/Entra/AdditionalFunctions/Get-EntraObjectSetting.ps1 b/module/Entra/AdditionalFunctions/Get-EntraObjectSetting.ps1 index 69ca51ca1..faf51a15f 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraObjectSetting.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraObjectSetting.ps1 @@ -6,7 +6,7 @@ function Get-EntraObjectSetting { param ( [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][System.String] $Id, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [switch] $All, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -30,7 +30,7 @@ function Get-EntraObjectSetting { $selectProperties = $selectProperties -Join ',' $params["Uri"] = $baseUri+"?`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["Top"] -and (-not $PSBoundParameters.ContainsKey("All"))) + if($PSBoundParameters.ContainsKey("Top") -and (-not $PSBoundParameters.ContainsKey("All"))) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/Entra/AdditionalFunctions/Get-EntraPolicy.ps1 b/module/Entra/AdditionalFunctions/Get-EntraPolicy.ps1 index cd7d2e1e3..1a767cb26 100644 --- a/module/Entra/AdditionalFunctions/Get-EntraPolicy.ps1 +++ b/module/Entra/AdditionalFunctions/Get-EntraPolicy.ps1 @@ -8,7 +8,7 @@ function Get-EntraPolicy { [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Id, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [switch] $All ) @@ -19,6 +19,12 @@ function Get-EntraPolicy { $baseUrl = "https://graph.microsoft.com/v1.0/policies/" $endpoints = @("homeRealmDiscoveryPolicies", "claimsMappingPolicies", "tokenIssuancePolicies", "tokenLifetimePolicies", "activityBasedTimeoutPolicies", "featureRolloutPolicies", "defaultAppManagementPolicy", "appManagementPolicies", "authenticationFlowsPolicy", "authenticationMethodsPolicy", "permissionGrantPolicies") + if($PSBoundParameters.ContainsKey("Top") -and ($null -eq $Top -or $Top -eq 0)){ + Write-Error "Invalid page size specified: '0'. Must be between 1 and 999 inclusive. +Status: 400 (BadRequest) +ErrorCode: Request_UnsupportedQuery" + break + } $response = @() foreach ($endpoint in $endpoints) { $url = "${baseUrl}${endpoint}" diff --git a/module/Entra/customizations/Get-EntraApplication.ps1 b/module/Entra/customizations/Get-EntraApplication.ps1 index 10bbe2f17..6cca113a7 100644 --- a/module/Entra/customizations/Get-EntraApplication.ps1 +++ b/module/Entra/customizations/Get-EntraApplication.ps1 @@ -49,7 +49,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraApplicationOwner.ps1 b/module/Entra/customizations/Get-EntraApplicationOwner.ps1 index 67f9f53b0..3cb00e337 100644 --- a/module/Entra/customizations/Get-EntraApplicationOwner.ps1 +++ b/module/Entra/customizations/Get-EntraApplicationOwner.ps1 @@ -29,7 +29,7 @@ { $URI = "$baseUri/$($params.ApplicationId)/owners?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.ApplicationId)/owners?`$top=$topCount&$properties" diff --git a/module/Entra/customizations/Get-EntraContact.ps1 b/module/Entra/customizations/Get-EntraContact.ps1 index 718bd0e61..8e2b00106 100644 --- a/module/Entra/customizations/Get-EntraContact.ps1 +++ b/module/Entra/customizations/Get-EntraContact.ps1 @@ -39,7 +39,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 index f52015c4a..8172f09ef 100644 --- a/module/Entra/customizations/Get-EntraDeletedApplication.ps1 +++ b/module/Entra/customizations/Get-EntraDeletedApplication.ps1 @@ -47,7 +47,7 @@ $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 b/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 index 16eeb5c24..be25e5c7c 100644 --- a/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 +++ b/module/Entra/customizations/Get-EntraDeviceRegisteredOwner.ps1 @@ -29,7 +29,7 @@ { $URI = "$baseUri/$($params.DeviceId)/registeredOwners?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.DeviceId)/registeredOwners?`$top=$topCount&$properties" diff --git a/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 b/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 index 9b857d39c..bb25e96f5 100644 --- a/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 +++ b/module/Entra/customizations/Get-EntraDeviceRegisteredUser.ps1 @@ -29,7 +29,7 @@ { $URI = "$baseUri/$($params.DeviceId)/registeredUsers?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.DeviceId)/registeredUsers?`$top=$topCount&$properties" diff --git a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 index 5c0f9f509..99aba85fe 100644 --- a/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 +++ b/module/Entra/customizations/Get-EntraDirectoryRoleDefinition.ps1 @@ -45,7 +45,7 @@ $Value = "startswith(displayName,'$TmpValue')" $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraGroupMember.ps1 b/module/Entra/customizations/Get-EntraGroupMember.ps1 index cbbabfcb6..8edb5a21b 100644 --- a/module/Entra/customizations/Get-EntraGroupMember.ps1 +++ b/module/Entra/customizations/Get-EntraGroupMember.ps1 @@ -30,7 +30,7 @@ { $URI = "$baseUri/$($params.GroupId)/members?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/Entra/customizations/Get-EntraGroupOwner.ps1 b/module/Entra/customizations/Get-EntraGroupOwner.ps1 index ba85da4b2..a29ad599e 100644 --- a/module/Entra/customizations/Get-EntraGroupOwner.ps1 +++ b/module/Entra/customizations/Get-EntraGroupOwner.ps1 @@ -29,7 +29,7 @@ { $URI = "$baseUri/$($params.GroupId)/owners?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.GroupId)/owners?`$top=$topCount&$properties" diff --git a/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 b/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 index efbeba360..fd2067793 100644 --- a/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 +++ b/module/Entra/customizations/Get-EntraServicePrincipalOwner.ps1 @@ -29,7 +29,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraTenantDetail.ps1 b/module/Entra/customizations/Get-EntraTenantDetail.ps1 index d039980d1..bd61cd868 100644 --- a/module/Entra/customizations/Get-EntraTenantDetail.ps1 +++ b/module/Entra/customizations/Get-EntraTenantDetail.ps1 @@ -14,7 +14,7 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraUser.ps1 b/module/Entra/customizations/Get-EntraUser.ps1 index 293f44cef..1d24ef2d7 100644 --- a/module/Entra/customizations/Get-EntraUser.ps1 +++ b/module/Entra/customizations/Get-EntraUser.ps1 @@ -23,7 +23,7 @@ $properties = "`$select=$($selectProperties)" $params["Uri"] = "$baseUri/?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 b/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 index b283737ad..626fcc24c 100644 --- a/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 +++ b/module/Entra/customizations/Get-EntraUserCreatedObject.ps1 @@ -29,7 +29,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraUserDirectReport.ps1 b/module/Entra/customizations/Get-EntraUserDirectReport.ps1 index 5a9d994d9..6fbfcc7e7 100644 --- a/module/Entra/customizations/Get-EntraUserDirectReport.ps1 +++ b/module/Entra/customizations/Get-EntraUserDirectReport.ps1 @@ -29,7 +29,7 @@ { $URI = "$baseUri/$($params.UserId)/directReports?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.UserId)/directReports?`$top=$topCount&$properties" diff --git a/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 b/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 index 93635797c..902436e87 100644 --- a/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 +++ b/module/Entra/customizations/Get-EntraUserOwnedDevice.ps1 @@ -29,7 +29,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 b/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 index e470fef3d..03d3f9f7c 100644 --- a/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 +++ b/module/Entra/customizations/Get-EntraUserOwnedObject.ps1 @@ -31,7 +31,7 @@ $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $URI -Method $Method).value; $Top = $null - if ($null -ne $PSBoundParameters["Top"]) { + if ($PSBoundParameters.ContainsKey("Top")) { $Top = $PSBoundParameters["Top"] } diff --git a/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 b/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 index 7b0b417c5..9a3bf1b9f 100644 --- a/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 +++ b/module/Entra/customizations/Get-EntraUserRegisteredDevice.ps1 @@ -29,7 +29,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 index 15b737f16..e5155357d 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnector.ps1 @@ -8,7 +8,7 @@ function Get-EntraBetaApplicationProxyConnector { [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $SearchString, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Id, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -40,7 +40,7 @@ function Get-EntraBetaApplicationProxyConnector { { $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $t = '$' + 'Top' $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors?$t=$top" diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroup.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroup.ps1 index 109f12ffe..ec79f567a 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroup.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroup.ps1 @@ -8,7 +8,7 @@ function Get-EntraBetaApplicationProxyConnectorGroup { [Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $SearchString, [Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Id, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] @@ -40,7 +40,7 @@ function Get-EntraBetaApplicationProxyConnectorGroup { { $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $t = '$' + 'Top' $params["Uri"] = "https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups?$t=$top" diff --git a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 index 1f9a8846d..64d490d34 100644 --- a/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 +++ b/module/EntraBeta/AdditionalFunctions/Get-EntraBetaApplicationProxyConnectorGroupMembers.ps1 @@ -8,7 +8,7 @@ function Get-EntraBetaApplicationProxyConnectorGroupMembers { [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Id, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [System.Nullable`1[System.Int32]] $Top, + [System.Int32] $Top, [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [System.String] $Filter, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 index ba119c89a..8b4b7e01b 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplication.ps1 @@ -45,7 +45,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 index 897decbfd..1f9648ebf 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInDetailedSummary.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInDetailedSummary.ps1 index 81878141b..4892f4916 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInDetailedSummary.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInDetailedSummary.ps1 @@ -8,7 +8,7 @@ $params = @{} $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInSummary.ps1 b/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInSummary.ps1 index b96d5c878..6a52cf080 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInSummary.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaApplicationSignInSummary.ps1 @@ -19,7 +19,7 @@ $params["Filter"] = $PSBoundParameters["Filter"] $filterApplied = '?$filter=' + $params["Filter"] } - if ($null -ne $PSBoundParameters["Top"]) { + if ($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] $topCount = '?$top=' + $params["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaAuditDirectoryLog.ps1 b/module/EntraBeta/customizations/Get-EntraBetaAuditDirectoryLog.ps1 index eccf5bc9a..6f9b93efc 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaAuditDirectoryLog.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaAuditDirectoryLog.ps1 @@ -20,7 +20,7 @@ $Value = $TmpValue $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaAuditSignInLog.ps1 b/module/EntraBeta/customizations/Get-EntraBetaAuditSignInLog.ps1 index adc305b3a..20abdc636 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaAuditSignInLog.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaAuditSignInLog.ps1 @@ -20,7 +20,7 @@ $Value = $TmpValue $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 b/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 index 1674ad0a3..46811af95 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaContact.ps1 @@ -39,7 +39,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeletedApplication.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeletedApplication.ps1 index 08af5e12a..c00f21879 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeletedApplication.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeletedApplication.ps1 @@ -48,7 +48,7 @@ $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 index 62f65f8d6..27d6af012 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredOwner.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 index 4915c16f6..71cc56403 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDeviceRegisteredUser.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 index 5c241c18f..5fdc1cbcc 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaDirectoryRoleDefinition.ps1 @@ -45,7 +45,7 @@ $Value = "startswith(displayName,'$TmpValue')" $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 index 0979b3ccb..348c08ac3 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupMember.ps1 @@ -22,7 +22,7 @@ $params["All"] = $PSBoundParameters["All"] } } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 index 9961f217e..33f20023c 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaGroupOwner.ps1 @@ -32,7 +32,7 @@ $URI = "$baseUri/$($params.GroupId)/owners?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.GroupId)/owners?`$top=$topCount&$properties" diff --git a/module/EntraBeta/customizations/Get-EntraBetaObjectSetting.ps1 b/module/EntraBeta/customizations/Get-EntraBetaObjectSetting.ps1 index eda76adc9..8e4b6ad20 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaObjectSetting.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaObjectSetting.ps1 @@ -22,7 +22,7 @@ $params["Uri"] = $baseUri+"?`$select=$($selectProperties)" } - if($null -ne $PSBoundParameters["Top"] -and (-not $PSBoundParameters.ContainsKey("All"))) + if($PSBoundParameters.ContainsKey("Top") -and (-not $PSBoundParameters.ContainsKey("All"))) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaPolicy.ps1 b/module/EntraBeta/customizations/Get-EntraBetaPolicy.ps1 index bf83e28bf..8e4bcd63d 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaPolicy.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaPolicy.ps1 @@ -23,6 +23,12 @@ "authenticationMethodsPolicy", "permissionGrantPolicies") + if($PSBoundParameters.ContainsKey("Top") -and ($null -eq $Top -or $Top -eq 0)){ + Write-Error "Invalid page size specified: '0'. Must be between 1 and 999 inclusive. +Status: 400 (BadRequest) +ErrorCode: Request_UnsupportedQuery" + break + } $response = @() foreach ($endpoint in $endpoints) { $url = "${baseUrl}${endpoint}" diff --git a/module/EntraBeta/customizations/Get-EntraBetaPrivilegedRoleSetting.ps1 b/module/EntraBeta/customizations/Get-EntraBetaPrivilegedRoleSetting.ps1 index 0515bac1c..bec167298 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaPrivilegedRoleSetting.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaPrivilegedRoleSetting.ps1 @@ -31,7 +31,7 @@ $Value = $TmpValue $params["Filter"] = $Value } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 index b57826ef4..42ab0e7b9 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaServicePrincipalOwner.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaTenantDetail.ps1 b/module/EntraBeta/customizations/Get-EntraBetaTenantDetail.ps1 index 5ac0e2ec4..1da17ca5c 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaTenantDetail.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaTenantDetail.ps1 @@ -15,7 +15,7 @@ { $params["Verbose"] = $PSBoundParameters["Verbose"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 index 2646581f4..405598031 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUser.ps1 @@ -26,7 +26,7 @@ $query = "$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] if ($topCount -gt 999) { diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 index de7f198bc..ad46a4fcf 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserCreatedObject.ps1 @@ -29,7 +29,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 index 913ffb251..feb2cced4 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserDirectReport.ps1 @@ -31,7 +31,7 @@ { $URI = "$baseUri/$($params.UserId)/directReports?$properties" } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $topCount = $PSBoundParameters["Top"] $URI = "$baseUri/$($params.UserId)/directReports?`$top=$topCount&$properties" diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 index 5a077d807..fe07f1670 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedDevice.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 index ac11558b0..b3f2ee308 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserOwnedObject.ps1 @@ -9,54 +9,35 @@ CustomScript = @' PROCESS { $params = @{} + $Method = "GET" $customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand if ($null -ne $PSBoundParameters["ObjectId"]) { $params["UserId"] = $PSBoundParameters["ObjectId"] } - - $URI = "/beta/users/$($params.UserId)/ownedObjects" + $URI = "/beta/users/$($params.UserId)/ownedObjects/?" + + if ($PSBoundParameters.ContainsKey("Top")) + { + $URI += "&`$top=$Top" + } if($null -ne $PSBoundParameters["Property"]) { $selectProperties = $PSBoundParameters["Property"] $selectProperties = $selectProperties -Join ',' $properties = "`$select=$($selectProperties)" - $URI = "/beta/users/$($params.UserId)/ownedObjects?$properties" + $URI += "&$properties" } Write-Debug("============================ TRANSFORMATIONS ============================") $params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug Write-Debug("=========================================================================`n") - - $Method = "GET" - $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $URI -Method $Method).value; + $response = (Invoke-GraphRequest -Headers $customHeaders -Uri $URI -Method $Method).value | ConvertTo-Json -Depth 10 | ConvertFrom-Json - $Top = $null - if ($null -ne $PSBoundParameters["Top"]) { - $Top = $PSBoundParameters["Top"] - } - - if($Top -ne $null){ - $response | ForEach-Object { - if ($null -ne $_ -and $Top -gt 0) { - $data= $_ | ConvertTo-Json -Depth 10 | ConvertFrom-Json - } - - $Top = $Top - 1 - } - } - else { - $response | ForEach-Object { - if ($null -ne $_) { - $data= $_ | ConvertTo-Json -Depth 10 | ConvertFrom-Json - } - } - } - $targetList = @() - foreach ($res in $data) { + foreach ($res in $response) { $targetType = New-Object Microsoft.Graph.Beta.PowerShell.Models.MicrosoftGraphDirectoryObject $res.PSObject.Properties | ForEach-Object { $propertyName = $_.Name.Substring(0,1).ToUpper() + $_.Name.Substring(1) @@ -66,7 +47,6 @@ $targetList += $targetType } $targetList - -} + } '@ } \ No newline at end of file diff --git a/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 b/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 index ebb7fe1b5..2177b0bcc 100644 --- a/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 +++ b/module/EntraBeta/customizations/Get-EntraBetaUserRegisteredDevice.ps1 @@ -30,7 +30,7 @@ { $params["Debug"] = $PSBoundParameters["Debug"] } - if($null -ne $PSBoundParameters["Top"]) + if($PSBoundParameters.ContainsKey("Top")) { $params["Top"] = $PSBoundParameters["Top"] } diff --git a/src/CompatibilityAdapterBuilder.ps1 b/src/CompatibilityAdapterBuilder.ps1 index 8c24be4fc..9ef9cc992 100644 --- a/src/CompatibilityAdapterBuilder.ps1 +++ b/src/CompatibilityAdapterBuilder.ps1 @@ -845,13 +845,29 @@ $OutputTransformations } hidden [string] GetParameterTransformationName([string] $OldName, [string] $NewName){ - $paramBlock = @" - if(`$null -ne `$PSBoundParameters["$($OldName)"]) +# $paramBlock = @" +# if(`$null -ne `$PSBoundParameters["$($OldName)"]) +# { +# `$params["$($NewName)"] = `$PSBoundParameters["$($OldName)"] + +# } + +# "@ + $paramBlock = if ($OldName -eq "Top") {@" + if (`$PSBoundParameters.ContainsKey(`"Top`")) + { + `$params["$($NewName)"] = `$PSBoundParameters["$($OldName)"] + } + +"@ + } else {@" + if (`$null -ne `$PSBoundParameters["$($OldName)"]) { `$params["$($NewName)"] = `$PSBoundParameters["$($OldName)"] } "@ +} return $paramBlock }