Hello Sudhir,
Thank you for your question and for reaching out with your question today.
The error message "Cannot find an object with identity" suggests that the PowerShell script is unable to find the specified user 'gary.lee' in the Active Directory domain 'cyberintelsys.local'. There could be a few reasons for this issue:
- User 'gary.lee' does not exist: Double-check that the user account 'gary.lee' exists in the Active Directory domain 'cyberintelsys.local'. You can verify this by using the Active Directory Users and Computers console or by running the Get-ADUser cmdlet directly on the Active Directory server.
- Inconsistent domain information: Ensure that the Active Directory domain information provided in the script or the Hybrid Worker Run As account matches the actual domain where the user account exists. The domain should be specified correctly in the script using the full domain name, such as 'DC=cyberintelsys,DC=local'.
- Replication delay: If you recently created or modified the user account 'gary.lee', there might be a delay in Active Directory replication. Replication delays can cause temporary inconsistencies in the domain controllers' data.
- Permissions: Verify that the Hybrid Worker Run As account has sufficient permissions to query Active Directory and access user information. The account needs permissions to read user objects in the domain.
- DNS resolution: Ensure that the DNS settings on the machine running the Azure Automation Hybrid Worker are correctly configured to resolve the Active Directory domain name 'cyberintelsys.local'. DNS resolution issues can prevent the Hybrid Worker from reaching the domain controller.
To troubleshoot the issue further, you can try the following steps:
- Confirm that the user 'gary.lee' exists in the specified domain by using the Active Directory Users and Computers console.
- Check the permissions of the Hybrid Worker Run As account to ensure it has the required rights to access Active Directory.
- Use fully qualified domain names in the script and verify that the domain name is correct.
- Test the script directly on the Active Directory server or another machine with the Active Directory PowerShell module installed to isolate any issues related to the Hybrid Worker environment.
- Check the DNS settings on the Hybrid Worker machine to ensure it can resolve the domain name correctly.
By verifying these aspects, you should be able to identify and resolve the issue with running the PowerShell script to set logon hours for the user account in Active Directory.
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
If the reply was helpful, please don’t forget to upvote or accept as answer.