Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix Get-EntraDirectoryObjectOnPremisesProvisioningError #1305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------

function Get-EntraDirectoryObjectOnPremisesProvisioningError {
[CmdletBinding(DefaultParameterSetName = 'GetById')]
[OutputType([System.Object])]
Expand All @@ -22,24 +23,59 @@ function Get-EntraDirectoryObjectOnPremisesProvisioningError {
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")
$Object = @('users', 'groups', 'contacts')
$response = @()
$data = @()

try {
foreach ($obj in $Object) {
$obj = ($obj | Out-String).TrimEnd()
$uri = 'https://graph.microsoft.com/v1.0/' + $obj + '?$select=onPremisesProvisioningErrors'
$response += ((Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method GET).value).onPremisesProvisioningErrors
$uri = "https://graph.microsoft.com/v1.0/" + $obj + "?`$filter=onPremisesProvisioningErrors/any(o:o/category ne null)&`$select=Id,UserPrincipalName,DisplayName,Mail,ProxyAddresses,onPremisesProvisioningErrors,onPremisesSyncEnabled&`$top=999"
$response = Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method GET
$response.value | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name ObjectType -Value $obj -Force
$data += $_
}
while ($response.ContainsKey('@odata.nextLink') -and $null -ne $response.'@odata.nextLink') {
$uri = $response.'@odata.nextLink'
$response = Invoke-GraphRequest -Uri $uri -Method GET
$response.value | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name ObjectType -Value $obj -Force
$data += $_
}
}
}
} catch {
}
catch {
Write-Error $_.Exception.Message
}
}

end {
if ([string]::IsNullOrWhiteSpace($response)) {
Write-Output 'False'
} else {
$response
if ($data.Count -eq 0) {
Write-Output 'No data found'
}
else {
$Results = New-Object -TypeName System.Collections.Generic.List[PSObject]
foreach ($item in $data) {
$upn = ""
if ($item | Get-Member userPrincipalName) {
$upn = $item.userPrincipalName
}
$Results.Add(
[PSCustomObject]@{
Id = $item.Id
PropertyCausingError = $item.onPremisesProvisioningErrors.PropertyCausingError
UserPrincipalName = $upn
Category = $item.onPremisesProvisioningErrors.category
Value = $item.onPremisesProvisioningErrors.Value
OccurredDateTime = $item.onPremisesProvisioningErrors.OccurredDateTime
DisplayName = $item.displayName
OnPremisesSyncEnabled = $item.onPremisesSyncEnabled
Mail = $item.mail
ProxyAddresses = $item.proxyAddresses
ObjectType = $item.ObjectType
}
)
}
$Results
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------

function Get-EntraBetaDirectoryObjectOnPremisesProvisioningError {
[CmdletBinding(DefaultParameterSetName = 'GetById')]
[OutputType([System.Object])]
Expand All @@ -22,24 +23,59 @@ function Get-EntraBetaDirectoryObjectOnPremisesProvisioningError {
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")
$Object = @('users', 'groups', 'contacts')
$response = @()
$data = @()

try {
foreach ($obj in $Object) {
$obj = ($obj | Out-String).TrimEnd()
$uri = 'https://graph.microsoft.com/beta/' + $obj + '?$select=onPremisesProvisioningErrors'
$response += ((Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method GET).value).onPremisesProvisioningErrors
$uri = "https://graph.microsoft.com/beta/" + $obj + "?`$filter=onPremisesProvisioningErrors/any(o:o/category ne null)&`$select=Id,UserPrincipalName,DisplayName,Mail,ProxyAddresses,onPremisesProvisioningErrors,onPremisesSyncEnabled&`$top=999"
$response = Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method GET
$response.value | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name ObjectType -Value $obj -Force
$data += $_
}
while ($response.ContainsKey('@odata.nextLink') -and $null -ne $response.'@odata.nextLink') {
$uri = $response.'@odata.nextLink'
$response = Invoke-GraphRequest -Uri $uri -Method GET
$response.value | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name ObjectType -Value $obj -Force
$data += $_
}
}
}
} catch {
}
catch {
Write-Error $_.Exception.Message
}
}

end {
if ([string]::IsNullOrWhiteSpace($response)) {
Write-Output 'False'
} else {
$response
if ($data.Count -eq 0) {
Write-Output 'No data found'
}
else {
$Results = New-Object -TypeName System.Collections.Generic.List[PSObject]
foreach ($item in $data) {
$upn = ""
if ($item | Get-Member userPrincipalName) {
$upn = $item.userPrincipalName
}
$Results.Add(
[PSCustomObject]@{
Id = $item.Id
PropertyCausingError = $item.onPremisesProvisioningErrors.PropertyCausingError
UserPrincipalName = $upn
Category = $item.onPremisesProvisioningErrors.category
Value = $item.onPremisesProvisioningErrors.Value
OccurredDateTime = $item.onPremisesProvisioningErrors.OccurredDateTime
DisplayName = $item.displayName
OnPremisesSyncEnabled = $item.onPremisesSyncEnabled
Mail = $item.mail
ProxyAddresses = $item.proxyAddresses
ObjectType = $item.ObjectType
}
)
}
$Results
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: This article provides details on the Get-EntraBetaDirectoryObjectOn


ms.topic: reference
ms.date: 08/19/2024
ms.date: 01/26/2025
ms.author: eunicewaweru
ms.reviewer: stevemutungi
manager: CelesteDG
Expand All @@ -21,7 +21,7 @@ schema: 2.0.0

## Synopsis

Returns whether Microsoft Entra ID has objects with DirSync provisioning error.
Returns directory synchronization errors when synchronizing on-premises directories to Microsoft Entra ID.

## Syntax

Expand All @@ -33,48 +33,66 @@ Get-EntraBetaDirectoryObjectOnPremisesProvisioningError

## Description

The `Get-EntraBetaDirectoryObjectOnPremisesProvisioningError` returns whether Microsoft Entra ID has objects with DirSync provisioning error.
The `Get-EntraBetaDirectoryObjectOnPremisesProvisioningError` returns directory synchronization errors for the `user`, `group`, or `organizational contact` entities when synchronizing on-premises directories to Microsoft Entra ID.

## Examples

### Example 1: Return whether Microsoft Entra ID has objects with DirSync provisioning error

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
Get-EntraBetaDirectoryObjectOnPremisesProvisioningError
Get-EntraBetaDirectoryObjectOnPremisesProvisioningError | Format-Table -AutoSize
```

```Output
False
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command returns whether Microsoft Entra ID has objects with DirSync provisioning error.
This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

### Example 2: Return whether Microsoft Entra ID has objects with DirSync provisioning error
### Example 2: Get directory synchronization errors with filtering

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
Get-EntraBetaDirectoryObjectOnPremisesProvisioningError | where-Object propertyCausingError -eq 'UserPrincipalName' | Format-Table -AutoSize
```

```Output
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

### Example 3: Get directory synchronization errors for a specific tenant

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
$tenant = Get-EntraBetaTenantDetail
Get-EntraBetaDirectoryObjectOnPremisesProvisioningError -TenantId $tenant.Id
Get-EntraBetaDirectoryObjectOnPremisesProvisioningError -TenantId $tenant.Id | Format-Table -AutoSize
```

```Output
False
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command returns whether Microsoft Entra ID has objects with DirSync provisioning error.
This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

- `-TenantId` Specifies the unique ID of the tenant.

## Parameters

### -TenantId

The unique ID of the tenant to perform the operation on.

If this isn't provided then the value defaults to the tenant of the current user.

This parameter is only applicable to partner users.
The unique tenant ID for the operation. If not provided, it defaults to the current user's tenant. This parameter is included for compatibility with legacy modules.

```yaml
Type: System.String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: This article provides details on the Get-EntraDirectoryObjectOnPrem


ms.topic: reference
ms.date: 06/26/2024
ms.date: 01/26/2025
ms.author: eunicewaweru
ms.reviewer: stevemutungi
manager: CelesteDG
Expand All @@ -21,7 +21,7 @@ schema: 2.0.0

## Synopsis

Returns whether Microsoft Entra ID has objects with DirSync provisioning error.
Returns directory synchronization errors when synchronizing on-premises directories to Microsoft Entra ID.

## Syntax

Expand All @@ -33,48 +33,66 @@ Get-EntraDirectoryObjectOnPremisesProvisioningError

## Description

The `Get-EntraDirectoryObjectOnPremisesProvisioningError` returns whether Microsoft Entra ID has objects with DirSync provisioning error.
The `Get-EntraDirectoryObjectOnPremisesProvisioningError` returns directory synchronization errors for the `user`, `group`, or `organizational contact` entities when synchronizing on-premises directories to Microsoft Entra ID.

## Examples

### Example 1: Return whether Microsoft Entra ID has objects with DirSync provisioning error
### Example 1: Get directory synchronization errors

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
Get-EntraDirectoryObjectOnPremisesProvisioningError
Get-EntraDirectoryObjectOnPremisesProvisioningError | Format-Table -AutoSize
```

```Output
False
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command returns whether Microsoft Entra ID has objects with DirSync provisioning error.
This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

### Example 2: Return whether Microsoft Entra ID has objects with DirSync provisioning error
### Example 2: Get directory synchronization errors with filtering

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
Get-EntraDirectoryObjectOnPremisesProvisioningError | where-Object propertyCausingError -eq 'UserPrincipalName' | Format-Table -AutoSize
```

```Output
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

### Example 3: Get directory synchronization errors for a specific tenant

```powershell
Connect-Entra -Scopes 'User.Read.All', 'Directory.Read.All', 'Group.Read.All', 'Contacts.Read'
$tenant = Get-EntraTenantDetail
Get-EntraDirectoryObjectOnPremisesProvisioningError -TenantId $tenant.Id
Get-EntraDirectoryObjectOnPremisesProvisioningError -TenantId $tenant.Id | Format-Table -AutoSize
```

```Output
False
Id PropertyCausingError UserPrincipalName Category Value OccurredDateTime DisplayName OnPremisesSyncEnabled Mail
-- -------------------- ----------------- -------- ----- ---------------- ----------- --------------------- ----
cccccccc-2222-3333-4444-dddddddddddd ProxyAddresses PropertyConflict SMTP:[email protected] 3/14/2022 11:46:44 PM ConflictMail1 True
eeeeeeee-4444-5555-6666-ffffffffffff UserPrincipalName PropertyConflict [email protected] 7/4/2024 12:06:16 AM BlockSoftMatch1 True
```

This command returns whether Microsoft Entra ID has objects with DirSync provisioning error.
This command lists directory sync errors for `users`, `groups`, or `organizational contacts` during on-premises synchronization to Microsoft Entra ID.

- `-TenantId` Specifies the unique ID of the tenant.

## Parameters

### -TenantId

The unique ID of the tenant to perform the operation on.

If this isn't provided then the value defaults to the tenant of the current user.

This parameter is only applicable to partner users.
The unique tenant ID for the operation. If not provided, it defaults to the current user's tenant. This parameter is included for compatibility with legacy modules.

```yaml
Type: System.String
Expand Down
Loading