Jorge's Quest For Knowledge!

All About Identity, Security, Recovery And Some Other Mic Stuff – It's Just Like An Addiction, The More You Have, The More You Want To Have!

Posts Tagged ‘PowerShell’

(2026-01-09) Oh Crap, An Application Partition Was Deleted From The AD Forest! – How To Restore It Back?

Posted by Jorge on 2026-01-09


Some days ago I was reading REDDIT and stumbled across this post, where someone mistakenly deleted a DNS application partition. I responded to that post by providing steps on how to recover. In addition I also wanted to refresh my memory and see if i had written down was correct or not. All I wrote in that REDDIT post was correct with the addition of having forgotten 1 important step!

WARNING: The steps listed here apply to restoring a deleted Application Partition in Active Directory. These steps DO NOT apply to restoring a deleted AD Domain!

To test this all out I used the following TEST environment:

  • AD Forest: IAMTEC.NET
  • Forest Root AD Domain: IAMTEC.NET –> 3x live RWDCs – W2K19 – R1FSRWDC1 (All Forest And Domain FSMO Roles), R1FSRWDC2, R1FSRWDC3) and 1x live RODC (W2K19 – R1FSRODC1) and 1x bogus RODC (RIVERBED)
    • Child AD Domain: CHLD.IAMTEC.NET –> 2x RWDCs – W2K19 – C1FSRWDC1 (All Domain FSMO Roles), C1FSRWDC2
  • Tree Root AD Domain: TROOT.NET –> 2x RWDCs – W2K19 – T1FSRWDC1 (All Domain FSMO Roles), T1FSRWDC2
  • All DCs are a GC
  • DNS is externally hosted, no DNS data in AD!
  • Backup/Recovery Solution: Semperis ADFR

As I did not have DNS in AD, i could not test the 100% exact scenario of the OP of the REDDIT post.

To simulate the scenario, I had to create an application partition first to test with, and I also enlisted all live RWDCs and RODCs in the AD forest!

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
CREATE NC DC=APP_NC_TEST R1FSRWDC1.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRWDC2.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRWDC3.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRODC1.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST C1FSRWDC1.CHLD.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST C1FSRWDC2.CHLD.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST T1FSRWDC1.TROOT.NET
ADD NC REPLICA DC=APP_NC_TEST T1FSRWDC2.TROOT.NET
Q
Q
Figure 1: Creating The Application Partition And Enlisting Additional DCs To Host It

Gave the DCs some minutes to replicate the partition data around.

Figure 2: The Definition (I.e., crossRef Object) Of The Application Partition

After this, I created a full backup of the AD forest using Semperis ADFR. After having confirmed the backup had completed successfully, it was time to start with the “mistaken” deletion. I used the following code to delete the application partition

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
LIST NC REPLICAS DC=APP_NC_TEST
DELETE NC DC=APP_NC_TEST
Q
Q
Figure 3: Listing The DCs That Host The Application Partition And Deleting The Application Partition

Gave the DCs some minutes to replicate the deletion of the partition data around.

To make sure all was deleted I used the following code:

(Get-ADForest).Domains | ForEach-Object {(Get-ADDomain -Identity $_).ReplicaDirectoryServers + (Get-ADDomain -Identity $_).ReadOnlyReplicaDirectoryServers | ForEach-Object {$dcFQDN = $_; Try{$events = Get-WinEvent -ComputerName $dcFQDN -FilterHashtable @{LogName = 'Directory Service'; ID = 1660} -ErrorAction STOP; $events | Format-Table @{Label="DC FQDN"; Expression={$dcFQDN}},TimeCreated,LevelDisplayName,Message -Wrap -AutoSize} CATCH {Write-Host "$dcFQDN - NO EVENTS YET... PATIENCE AND RETRY" -ForegroundColor Red}}}

With the following event from every DC hosting the partition, I knew for sure the partition did not exist anywhere anymore!

Figure 4: Confirming The Partition Was Deleted/Removed On All DCs In The AD Forest (In This Case!)

After the deletion of the data, I used Semperis ADFR to non-authoritatively restore the DC R1FSRWDC2.IAMTEC.NET using the most recent backup created.

Figure 5a: Non-Authoritative Restore Using Semperis ADFR

Figure 5b: Non-Authoritative Restore Using Semperis ADFR

Figure 5c: Non-Authoritative Restore Using Semperis ADFR

After the non-authoritative restore the DC R1FSRWDC2.IAMTEC.NET, I confirmed that INbound AD replication was disabled. This is needed to be able to authoritatively restore some objects to bring back the deleted partition. If this would not be done, more recent data in the AD Domain/Forest would update the restored DC as if nothing had happened.

Figure 6: Confirming Inbound AD Replication Was Disabled To Prevent Overwriting The Data Of The Non-Authoritative Restore

In this state I wanted to check the state of the objects of interest on both the restored DC R1FSRWDC2.IAMTEC.NET and some other DC R1FSRWDC1.IAMTEC.NET

LEFT WINDOW (RESTORED CROSS-REF OBJECT OF THE PARTITION):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NO CROSS-REF OBJECT OF THE PARTITION EXISTS (YET) AS IT IS DELETED):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"
Figure 7: Comparing Cross-Ref Objects On Both The Restored DC And Another DC

LEFT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON THE RESTORED DC):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON ANOTHER DC):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

Figure 8a: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – Differences Exist

Figure 8b: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – Differences Exist

Now lets analyze what needs to be done! Before the non-authoritative restore the application partition “DC=APP_NC_TEST” does not exist on any DC and its definition (i.e. cross-ref object) does also not exist. The question is “how to bring back (i.e., restore) the deleted application partition?”.

One way to restore the deleted the deleted application partition “DC=APP_NC_TEST” is to perform a full AD forest restore using the most recent backup that still contains the application partition. Although a solution, that would be some serious overkill, and let alone the huge impact on the environment!

So, IMHO, the best way to bring back the deleted application partition “DC=APP_NC_TEST” is to use the most recent backup available of any DC that actually hosted the partition, following up with some additional actions.

In my case, I use the DC R1FSRWDC2.IAMTEC.NET to perform an NON-authoritative restore. Now for the follow up actions, my logic is as follows, while using the following code that also executed on the restored DC R1FSRWDC2.IAMTEC.NET (!):

Stop-Service NTDS -Force
CD C:\TEMP
NTDSUTIL
ACTIVATE INSTANCE NTDS
AUTHORITATIVE RESTORE

At first we need to bring back the definition of the application partition. That is done by authoritatively restoring the cross-ref object of the deleted application partition.

RESTORE OBJECT "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"
Figure 9a: Authoritative Restore Of The Cross-Ref Object On The Restored DC

Figure 9b: Authoritative Restore Of The Cross-Ref Object On The Restored DC

Now when you look at the data:

  • The cross-ref object lists which DCs (a.k.a. replica locations) host the application partition
  • The NTDS Settings object of each DC lists, across multiple attributes, which partitions (a.k.a. NCs) are hosted the corresponding DC

The first bullet has already been authoritatively restored, so that is done! However, the data of the NTDS Settings object of the restored DC on the restored DC itself is older than the data of the NTDS Settings object of the restored DC on any other DC. Check the differences in figure 8a and 8b. On the left you can see the NTDS Settings object shows that R1FSRWDC2.IAMTEC.NET hosts the application partition and on the right you can see the NTDS Settings object shows that R1FSRWDC2.IAMTEC.NET DOES NOT host the application partition. Obviously we want the version on the left to take priority. In other words, if the NTDS Settings object of the restored DC on the restored DC is not authoritatively restored, the restored DC will have the actual application partition, but other DCs WILL NOT be able to replicate from it as its NTDS Settings object does not specify the hosts the application partition. Although specified as a Replica Location, other DCs will not be able to inbound replicate and host the application data as they cannot find another DC that hosts (i.e., has instantiated) the actual partition. The restored DC, although being a Replica Location, having the data, but not having specified it has it instantiated, will not be able to service replication requests from other DCs. Something similar like the following would be seen.

Figure 10: DCs Defined As Replica Locations But Not Being Able To Instantiate The Application Partition

The solution? Also perform an authoritative restore of the NTDS Settings object of the restored DC on the restored DC. After that the NTDS Service again.

RESTORE OBJECT "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"
Q
Q
Start-Service NTDS
Figure 11a: Authoritative Restore Of The NTDS Settings Object Of The Restored DC On The Restored DC

Figure 11b: Authoritative Restore Of The NTDS Settings Object Of The Restored DC On The Restored DC

Now you might also think that it is also needed to authoritatively restore the actual partition itself. That is not needed as nothing from that partition exists on the other DCs, and there is nothing to overwrite. The partition and its data are not in a deleted state, but rather have been fully deleted. In short, authoritative restore of the actual partition is not needed.

After the restore, OUTbound AD replication is forced on the restored DC so that the changes propagate to other DCs.

Figure 12: Forcing Outbound AD Replication On The Restored DC For The Changes To Propagate To Other DCs

LEFT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON THE RESTORED DC):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON ANOTHER DC):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

Figure 13a: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – NO Differences Exist

Figure 13b: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – NO Differences Exist

It is now time to enable INbound AD Replication on the restored DC.

REPADMIN.EXE /HOMESERVER:$ENV:COMPUTERNAME /OPTIONS $ENV:COMPUTERNAME -DISABLE_INBOUND_REPL

Forcing OUTbound AD Replication on the restored DC

REPADMIN.EXE /SYNCALL $ENV:COMPUTERNAME /edjqAP

Figure 14: Forcing Outbound AD Replication On The Restored DC For The Changes To Propagate To Other DCs

Forcing INbound AD Replication on the restored DC

REPADMIN.EXE /SYNCALL $ENV:COMPUTERNAME /edjqA

The error below can be expected if a certain DC has not (yet) instantiated the application partition

Figure 15: Forcing Inbound AD Replication On The Restored DC To Receive Any Updates From Other DCs

As of this point in the process all the other Replica Locations, as defined on the cross-ref object, that have nothing instantiated, will instantiate the application partition and inbound replicate the data from any other DC that already has instantiated the application partition, and in this case it is the DC R1FSRWDC2.IAMTEC.NET.

Checking which Replica Locations exist and which have instantiated the application partition.

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
LIST NC REPLICAS DC=APP_NC_TEST
Q
Q
Figure 16: Listing The Replica Locations Of The Application Partition And Their Instantiation State – Not (Yet) Complete

As you can see above, not all DCs (i.e., Replica Locations) have completed the operation. Just give it time to complete, especially when having many DCs hosting the application partition and lots of data is involved.

Figure 17: Listing The Replica Locations Of The Application Partition And Their Instantiation State – Completed!

Because of the restore of the application partition and the (re-)instantiation of the application partition, every DC hosting the application partition will report through event ID 1587 in the Directory Services Event Log it is processing the new Invocation IDs of each DC that instantiated the partition. To get assurance the process is working, I only need to see 1 Event on every DC as it otherwise could be an overload of data.

(Get-ADForest).Domains | ForEach-Object {(Get-ADDomain -Identity $_).ReplicaDirectoryServers + (Get-ADDomain -Identity $_).ReadOnlyReplicaDirectoryServers | ForEach-Object {$dcFQDN = $_; Try{$events = Get-WinEvent -ComputerName $dcFQDN -FilterHashtable @{LogName = 'Directory Service'; ID = 1587} -MaxEvents 1 -ErrorAction STOP; $events | Format-Table @{Label="DC FQDN"; Expression={$dcFQDN}},TimeCreated,LevelDisplayName,Message -Wrap -AutoSize} CATCH {Write-Host "$dcFQDN - NO EVENTS YET... PATIENCE AND RETRY (UNLESS IT IS AN RODC, A DECOMMISSIONED DC, ETC)" -ForegroundColor Red}}}

Figure 18a: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18b: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18c: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18d: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

And as I final step, I want to make sure all Replica Location are fully functioning for the application partition. You can easily do that through the PowerShell script SCRIPT: Check-AD-Replication-Latency-Convergence

Figure 19a: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19b: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19c: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19d: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19e: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19f: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Everything is now back to normal again! Hope this helps someone, if this mistake occurs. Remember, although there are similarities, THESE STEPS CANNOT BE USED FOR RESTORING A DELETED DOMAIN!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Active Directory Forest Recovery (ADFR), Forest Recovery, Partition Deletion/Restore | Tagged: , , , , | Leave a Comment »

(2025-07-10) Re-Awarded for the 20th Time – MVP Identity & Access And This Year Also PowerShell

Posted by Jorge on 2025-07-10


On July 10th I received an e-mail from Microsoft I was re-awarded again with the MVP Award for the Identity & Access and PowerShell Areas. This year is the 20th time I have received this award!

Thank you Microsoft for the award, and thank you Semperis for supporting this adventure.

Let’s go for yet another year! Whooohoooo!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in MVP | Tagged: , , | Leave a Comment »

(2025-06-27) Well-Known Containers In An AD domain – How To Restore And/Or Repair As Needed?

Posted by Jorge on 2025-06-27


Within any AD domain many organizational units (OUs) and containers exist that have child objects.

Previously in AD, OUs were not protected from (accidental) deletion. It was therefore a common fact mistakes were made and an OU with (many) child objects was deleted with all kinds of possible consequences. After some time, Microsoft implemented the “Protect from accidental deletion” option for every OU. That feature was more of a cosmetic thing to easily enable that protection. That option is nothing more than a set of deny ACEs being implemented to disallow deletion of the OU by anyone. It was therefore already there since the very first version of AD. It was just not easily visible and accessible.

In old ADs, the protection had to be implemented for every existing OU. For new OUs, the protection is enabled by default. Many (well-known) containers in AD are also protected by default from being deleted. That protection is implemented differently. Below you can see the USERS container being protected through a configuration of the “systemFlags” attribute with “DISALLOW_DELETE”.

Figure 1: The USERS Container Configure With “DISALLOW_DELETE” Through The “systemFlags”

Below you can find the containers in this AD domain that have been protected by the “systemFLAGS” value “DISALLOW_DELETE”.

Get-ADObject -LDAPFilter "(&(objectClass=container)(systemFlags:1.2.840.113556.1.4.803:=2147483648))"
Figure 2: All The Containers Configured With “DISALLOW_DELETE” Through The “systemFlags”

However, many other (well-known) containers in AD are not protected from (accidental) deletion by default. The reason for that is unclear to me.

Below you can find the containers in this AD domain that have NOT been protected by the “systemFLAGS” value “DISALLOW_DELETE”.

Get-ADObject -LDAPFilter "(&(objectClass=container)(!(systemFlags:1.2.840.113556.1.4.803:=2147483648)))"
Figure 3a: All The Containers NOT Configured With “DISALLOW_DELETE” Through The “systemFlags”
Figure 3b: All The Containers NOT Configured With “DISALLOW_DELETE” Through The “systemFlags”
Figure 3c: All The Containers NOT Configured With “DISALLOW_DELETE” Through The “systemFlags”
Figure 3d: All The Containers NOT Configured With “DISALLOW_DELETE” Through The “systemFlags”

Some of those containers are so-called well-known containers that are represented in AD by both a distinguished name (DN) and a well-known unique GUID (not the ObjectGUID!). To find the well-known container both the DN or the GUID can be used. The GUID can be seen as, and functions as, a shortcut to find the location of the well-known container.

Get-ADObject -SearchBase $((Get-ADRootDse).defaultNamingContext) -SearchScope Base -Filter * -Properties wellKnownObjects,otherWellKnownObjects
Get-ADObject -SearchBase $((Get-ADRootDse).defaultNamingContext) -SearchScope Base -Filter * -Properties wellKnownObjects,otherWellKnownObjects  | Select * -ExpandProperty wellKnownObjects
Get-ADObject -SearchBase $((Get-ADRootDse).defaultNamingContext) -SearchScope Base -Filter * -Properties wellKnownObjects,otherWellKnownObjects  | Select * -ExpandProperty otherWellKnownObjects
Figure 4: The (Other) Well Known Objects Defined On The Domain NC With Their Well-Known GUID And DN

On the domain NC the attributes “wellKnownObjects” and “otherWellKnownObjects” hold the relationship between a well-known GUID and the DN of some container/OU that represents a certain function, like a container for users, one for computers, one for (s/g/d)MSAs and more. Because of the GUID/DN relationship, it is technically possible to update the DN that is tied to a specific GUID. In other words, it is possible to redirect to some other container or even OU if wanted or needed. One common scenario was to have another redirected OU as the default location for users and/or computers. That is done by respectively using the tools REDIRUSR or REDIRCMP. It is not needed to use those tools, as you can also use PowerShell to do the same. You just need to know how and what to do.

Moving any of the existing containers (if allowed through its systemFlags) to another location, updates the DN of the object accordingly in the attributes “wellKnownObjects” and “otherWellKnownObjects”

Due to the possibility of having different locations in different ADs for specific containers, applications instead find the specific container for a certain function using the well-known unique GUID instead.

So, what is the worst thing that can happen? It might be accidentally deleted, or someone might rigorously clean containers that are not being used at all.

The question is of course how do you fix this? The way of fixing it obviously depends on what or how something was broken or mistakenly repaired. As an example to explain the different scenarios, I will use the “Managed Service Accounts (MSA)” container. There are a few scenarios to think of and let’s define those:

  1. The MSA container was deleted, the Recycle Bin is ON and the deletion is still within Deleted Object Lifetime?
  2. The MSA container was deleted, the Recycle Bin is OFF and the deletion is still within Tombstone Lifetime?
  3. The MSA container was deleted, and it is already beyond “Deleted Object Lifetime” (Recycle Bin is ON) / “Tombstone Lifetime” (Recycle Bin is OFF)?
  4. The MSA container was deleted, and it was recreated as an OU instead?

Make sure to plan the following ACCORDINGLY to reduce any possible impact while executing any actions!

[AD.1] The MSA container was deleted, the Recycle Bin is ON and the deletion is still within Deleted Object Lifetime?

Because the moment of deletion is still within the Deleted Object Lifetime and the Recycle Bin IS being used, the deleted MSA container can easily be undeleted. With the Recycle Bin enabled you will get a fully restored object as the object and all attribute values would be restored as if nothing had happened.

The solution to fix this is:

  1. If you have already created a new OU (not a container) with the same name, you will only be able restore the original container after renaming the OU to something else temporarily. Therefore, rename first if applicable.
  2. Undelete using Active Directory Administration Center (ADAC) or through PowerShell
  3. Protect the original container from accidental deletion using either Active Directory Users And Computers (ADUC), Active Directory Administration Center (ADAC) or PowerShell (https://gist.github.com/zjorz/b8ff6beb5f46a1e8e48e30776e292ede)
  4. If applicable, by using PowerShell, recursively restore all child objects that have the restored container as the parent
  5. If applicable, Move ALL objects…
    • FROM WITHIN: “<the temporary renamed OU>”
    • TO: “CN=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”
  6. If applicable, delete “<the temporary renamed OU>” (remove protection from accidental deletion if needed FIRST)
Figure 5: The “Managed Service Accounts” Container Being Deleted With The Ability To UNDelete

[AD.2] The MSA container was deleted, the Recycle Bin is OFF and the deletion is still within Tombstone Lifetime?

Because the moment of deletion is still within the Tombstone Lifetime and the Recycle Bin IS NOT being used, the deleted MSA container can easily be undeleted. With the Recycle Bin NOT enabled you would get a partially restored object as the object and only the attribute values that are retained during deletion would be restored. Whatever was still missing you would need to restore yourself by in this case looking at the property values of a MSA container in another domain.

The solution to fix this is:

  1. If you have already created a new OU (not a container) with the same name, you will only be able restore the original container after renaming the OU to something else temporarily. Therefore, rename first if applicable.
  2. Undelete through PowerShell
  3. Repopulate any missing attributes on the restored container by looking at another AD where the official container still exists
  4. Protect the container from accidental deletion using either Active Directory Users And Computers (ADUC), Active Directory Administration Center (ADAC) or PowerShell (https://gist.github.com/zjorz/b8ff6beb5f46a1e8e48e30776e292ede)
  5. If applicable, by using PowerShell, recursively restore all child objects that have the restored container as the parent
  6. Using PowerShell, repopulate any missing attributes on the restored objects by leveraging a parallel AD instance through DSAMAIN (requires a backup or an IFM set upfront where the objects still exist)
  7. If applicable, Move ALL objects…
    • FROM WITHIN: “<the temporary renamed OU>”
    • TO: “CN=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”
  8. If applicable, delete “<the temporary renamed OU>” (remove protection from accidental deletion if needed FIRST)
Figure 6: The “Managed Service Accounts” Container With All Configured Attributes

[AD.3] The MSA container was deleted, and it is already beyond “Deleted Object Lifetime” (Recycle Bin is ON) / “Tombstone Lifetime” (Recycle Bin is OFF)?

Whenany object is already beyond the “Deleted Object Lifetime” (Recycle Bin is ON) or the “Tombstone Lifetime” (Recycle Bin is OFF), the only way to get the object back is to recreate it.

The solution to fix this is:

  1. Create the container (not OU!) “CN=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”
  2. Protect the container from accidental deletion using either Active Directory Users And Computers (ADUC), Active Directory Administration Center (ADAC) or PowerShell (https://gist.github.com/zjorz/b8ff6beb5f46a1e8e48e30776e292ede)
  3. Fix the otherWellKnowObjects attribute on the domain NC head using the following code: https://gist.github.com/zjorz/ac3cdd4c7036297971c34595529ff34d

[AD.4] The MSA container was deleted, and it was recreated as an OU instead?

An OU has a DN “OU=…” and a container has DN “CN…”, so any object in the MSA OU, that is moved to the new to be created MSA container will get a different DN any way.

From : “CN=OBJECT,OU=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”

To: “CN=OBJECT,CN=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”

The solution to fix this is:

  1. Create the following container “CN=Managed Zervice Accounts,DC=<DOMAIN>,DC=<TLD>” (REMARK: note spelling and it just temporary)
  2. Protect the container from accidental deletion using either Active Directory Users And Computers (ADUC), Active Directory Administration Center (ADAC) or PowerShell (https://gist.github.com/zjorz/b8ff6beb5f46a1e8e48e30776e292ede)
  3. Move ALL objects…
    • FROM WITHIN: “OU=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”
    • TO: “CN=Managed Zervice Accounts,DC=<DOMAIN>,DC=<TLD>”
  4. Delete “OU=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>” (remove protection from accidental deletion if needed FIRST)
  5. Rename “CN=Managed Zervice Accounts,DC=<DOMAIN>,DC=<TLD>” to “CN=Managed Service Accounts,DC=<DOMAIN>,DC=<TLD>”
  6. Fix the otherWellKnowObjects attribute on the domain NC head using the following code: https://gist.github.com/zjorz/ac3cdd4c7036297971c34595529ff34d

After enabling the protection against accidental deletion the following errors appears when trying to delete the container.

Figure 7: An Error Specifying The Deletion Is NOT Allowed Due To “Protection Against Accidental Deletion”

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Containers, Object Deletion/Restore, Organizational Units (OUs) | Tagged: , , , | Leave a Comment »

(2024-12-13) Testing SYSVOL/File Replication Latency/Convergence Through PowerShell (Update 6)

Posted by Jorge on 2024-12-13


A new version of the SYSVOL/File Replication Convergence Check script has been published containing updates, improvements, and bug fixes. Read more about it, and get the new version of the script, by clicking HERE. Any feedback, or feature requests? Just let me know!

While on that subject, and although I cannot name the specific people and/or companies that, A number of individuals approached me with tons of feedback. I listened to them and all what was said was valid and made sense. That’s why I decided to do major updates on this script. And to make it even better, those same people also helped in testing. The script was tested in an AD environments with 20+, 100+ and 160+ DCs. I can only say THANK YOU for your help and dedication in making this better!

Oh, and I almost forgot to mention it, make sure to read the documentation first and also try it out first in a TEST environment to see how it works, what it does and to see if it meets your needs!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Forest Recovery, Replication, SYSVOL | Tagged: , , , , | Leave a Comment »

(2024-12-13) Testing Active Directory Replication Latency/Convergence Through PowerShell (Update 6)

Posted by Jorge on 2024-12-13


A new version of the AD Replication Convergence Check script has been published containing updates, improvements, and bug fixes. Read more about it, and get the new version of the script, by clicking HERE. Any feedback, or feature requests? Just let me know!

While on that subject, and although I cannot name the specific people and/or companies that, A number of individuals approached me with tons of feedback. I listened to them and all what was said was valid and made sense. That’s why I decided to do major updates on this script. And to make it even better, those same people also helped in testing. The script was tested in an AD environments with 20+, 100+ and 160+ DCs. I can only say THANK YOU for your help and dedication in making this better!

Oh, and I almost forgot to mention it, make sure to read the documentation first and also try it out first in a TEST environment to see how it works, what it does and to see if it meets your needs!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Forest Recovery, Replication | Tagged: , , , , | Leave a Comment »

(2024-05-01) Delivering A Demo About Reconnecting AD Back With Entra ID At “Troopers 2024”

Posted by Jorge on 2024-05-01


Very proud (again!) to have been selected again to present at Troopers 2024!

Somewhere in the week of June 24th – 28th, I will be challenging the demo gods for a full hour. Let’s just hope everything goes as planned!

Last year at Troopers I presented about the “Best Practices for Resynchronizing AD and Entra ID After Forest Recovery”. This year, I will actually show you how this can be done for real!

For more information about the conference, please see: https://troopers.de/

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Certificate Services (ADCS), Azure AD Cloud Sync, Azure AD Connect, Fixing Identity Data, Forest Recovery, GAP Analysis, GAP Analysis, PowerShell, Tooling/Scripting, Windows Azure Active Directory | Tagged: , , , , , , , , , , | Leave a Comment »

 
Design a site like this with WordPress.com
Get started