Skip to content

Refactor Get-ReplicatingDirectoryPermissions.ps1 to remove ActiveDirectory module dependencies#2

Open
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-1
Open

Refactor Get-ReplicatingDirectoryPermissions.ps1 to remove ActiveDirectory module dependencies#2
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Jun 26, 2025

This PR refactors the Get-ReplicatingDirectoryPermissions.ps1 script to eliminate dependencies on the ActiveDirectory PowerShell module, as requested in the issue. The script now uses native .NET classes and ADSI calls instead.

Changes Made

Removed Dependencies:

  • Import-Module ActiveDirectory
  • Get-ADRootDSE
  • Get-ADObject (3 calls for different control access rights)
  • Get-ADDomain

Replaced With:

  • [ADSI]"LDAP://RootDSE" for RootDSE access
  • System.DirectoryServices.Protocols.LdapConnection for LDAP queries
  • System.DirectoryServices.Protocols.SearchRequest for directory searches
  • Custom Get-ControlAccessRightGuid function for retrieving control access right GUIDs
  • Direct access to defaultNamingContext for domain DN

Benefits

No dependency on ActiveDirectory PowerShell module - Script can run without RSAT or AD module installation
Uses native .NET classes - Available in all PowerShell versions
Maintains original functionality - Same output format and behavior
Better performance - More lightweight execution
Broader compatibility - Works on systems without AD module

Example Usage

The script maintains the same interface and output structure:

# Original usage remains unchanged
$permissions = .\Get-ReplicatingDirectoryPermissions.ps1

# Output format is preserved
$permissions | Format-Table IdentityReference, Permission

The refactored script has been validated for syntax correctness and maintains the original output structure while removing all ActiveDirectory module dependencies.

Fixes #1.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@bastienperez bastienperez marked this pull request as ready for review June 26, 2025 22:08
Copilot AI review requested due to automatic review settings June 26, 2025 22:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Copilot AI changed the title [WIP] Get-replicatingdirectorypermission Refactor Get-ReplicatingDirectoryPermissions.ps1 to remove ActiveDirectory module dependencies Jun 26, 2025
Copilot AI requested a review from bastienperez June 26, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-replicatingdirectorypermission

3 participants