LoicVeirman / HardenAD

Hardening Active Directory version 2
Other
250 stars 33 forks source link

Local admin group L-S_LocalAdmins_%ComputerName% never created #85

Closed Math6768 closed 5 months ago

Math6768 commented 6 months ago

Local admin group never created.

I've created 2 differents VMs and joined them to the domain. I've the same problem for both of them. I expect the creation of a security group called L-SLocalAdmins%ComputerName% No group has been created.

Log file says that computer join to domain event is catched but error occured.

WARNING: 03-19-2024 10:00:49 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(95) - Computer was not provided or is incorrect: Impossible de valider l'argument sur le paramètre « Identity ». La propriété Identity sur l’argument est nulle ou vide. Loading all computers... SUCCESS: 03-19-2024 10:00:49 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-19-2024 10:00:49 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:06:07 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:06:07 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:06:07 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:06:18 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:06:18 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:06:19 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:06:19 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:06:19 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:06:19 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:00 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:00 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! FATAL: 03-20-2024 14:07:00 Set-ConfigTable.ps1:Set-ConfigTable:(34) - An error occurred while querying the domain.Le processus ne peut pas accéder au fichier 'C:\Windows\HardenAD\Logs\Start-HardenADLocalGroups.log', car il est en cours d'utilisation par un autre processus. Exiting... FATAL: 03-20-2024 14:07:01 Set-ConfigTable.ps1:Set-ConfigTable:(34) - An error occurred while querying the domain.Une connexion à l’annuaire sur lequel traiter la demande n’était pas disponible. Il s’agit probablement d’une situation transitoire. Exiting... FATAL: 03-20-2024 14:07:01 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Une connexion à l’annuaire sur lequel traiter la demande n’était pas disponible. Il s’agit probablement d’une situation transitoire. Exiting... SUCCESS: 03-20-2024 14:07:01 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:01 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:01 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:02 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:07:02 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:07:02 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:03 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:03 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:19 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:19 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:20 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:07:20 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:21 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:21 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:21 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:21 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:22 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:22 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:22 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:22 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:22 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:22 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:23 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(91) - HV-DTC has been found! FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. SUCCESS: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly. FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... FATAL: 03-20-2024 14:07:23 Set-ConfigTable.ps1:Set-ConfigTable:(59) - An error occurred while loading the OUs. Impossible de valider l'argument sur le paramètre « Identity ». L’argument est Null. Spécifiez une valeur valide pour l’argument, puis réessayez. Exiting... WARNING: 03-20-2024 14:14:27 Start-HardenADLocalGroups.ps1:Start-HardenADLocalGroups:(95) - Computer was not provided or is incorrect: Le processus ne peut pas accéder au fichier 'C:\Windows\HardenAD\Logs\Start-HardenADLocalGroups.log', car il est en cours d'utilisation par un autre processus. Loading all computers... SUCCESS: 03-20-2024 14:14:28 Set-ConfigTable.ps1:Set-ConfigTable:(31) - The domain-specific elements have been loaded correctly.

Several tries have been made with new VM created from scratch and same issue occured.

Please let me know if you need more information.

Regards

PSIT-smiro commented 6 months ago

Hi @Math6768

I think I'm facing the same issue. No matter where the workstation is create/moved, the scheduled task is launched but the security group is not created. Where did you find the log file ?

Math6768 commented 6 months ago

Hi @PSIT-smiro

You'll find log file here : C:\Windows\HardenAD\Logs

PSIT-smiro commented 6 months ago

So, I'm facing the same errors :

PS C:\Users\myuser> import-module HADLocalAdmins PS C:\Users\myuser> Start-HardenADLocalGroups -ComputerName '' -EventID 5139 -OldDN 'CN=DESKTOP-22XXXX,OU=Workstations,OU=Harden_T0,DC=intra,DC=domaine,DC=fr' -NewDN 'CN=DESKTOP-22XXXX,OU=Workstations,OU=Harden_T12,DC=intra,DC=domaine,DC=fr' PS C:\Users\myuser> TerminatingError(Get-ADComputer): "Cannot validate argument on parameter 'Identity'. The Identity property on the argument is null or empty." [04/04/24 15:45:44] : Computer was not provided or is incorrect: Cannot validate argument on parameter 'Identity'. The Identity property on the argument is null or empty. Loading all computers... [04/04/24 15:45:45] : The domain-specific elements have been loaded correctly. PS C:\Users\myuser> TerminatingError(Get-ADOrganizationalUnit): "Cannot find an object with identity: 'OU=LocalAdmins,OU=GroupsT0,OU=_Administration,%DN%' under: 'DC=intra,DC=domaine,DC=fr'." [04/04/24 15:45:45] : An error occurred while loading the OUs. Cannot find an object with identity: 'OU=LocalAdmins,OU=GroupsT0,OU=_Administration,%DN%' under: 'DC=intra,DC=domaine,DC=fr'. Exiting...

They seem to be related to :

My Powershell skills are limited, a fix is needed 😊

LoicVeirman commented 6 months ago

The script is not working. Don't pull your head against walls, I'm myself crying each time I have to implem' this to a client infra... A new release is being reviewed.

livarkhal commented 5 months ago

Hello :)

At the line 100 of the script Start-HardenADLocalGroups.ps1, you have the loop TRY who search in the OU "LA_T0". This OU don't exist in the deployment of Harden AD, and LA-T0 don't exist in the $Config in the script too. Maybe it's a part of the problem?

EDIT

Fun fact, i don't know how but at a moment the script create en OU TBC in GroupsTO->LocalAdmins and the group L-S-T1_LocalAdmins_MyComputer in GroupsT2L->LocalAdmins 🤔

EDIT2

It's created when i add manually a new computer in the OU PawT0. For some reason, the scheduled tasks don't take all the ID events listed 🤷‍♀️ In the logfile, Get-Tiers.ps1 indicates that the computer added in PawT0 is a T1-Legacy 🤔

LoicVeirman commented 5 months ago

The new release is already updated in version 2.9.8 (current MASTER branch). Beware: this is a complete rewrite and scheduling process...