This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from StrangeRanger/dev
- Loading branch information
Showing
5 changed files
with
150 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Management.Automation.Runspaces; | ||
using ActiveDirectoryQuerier.PowerShell; | ||
|
||
namespace ActiveDirectoryQuerier; | ||
|
||
public class ActiveDirectoryInfo | ||
{ | ||
private readonly PSExecutor _psExecutor = new(); | ||
|
||
public Dictionary<string, Func<Task<PSOutput>>> AvailableOptions { get; } = new(); | ||
|
||
public ActiveDirectoryInfo() | ||
{ | ||
AvailableOptions.Add("Get user on domain", GetADUsers); | ||
AvailableOptions.Add("Get computers on domain", GetADComputers); | ||
AvailableOptions.Add("Get IPv4 of each system on domain", GetADIPv4Addresses); | ||
AvailableOptions.Add("Get IPv6 of each system on domain", GetADIPv6Addresses); | ||
} | ||
|
||
// ReSharper disable once InconsistentNaming | ||
private async Task<PSOutput> GetADUsers() | ||
{ | ||
Command psCommand = new("Get-ADUser"); | ||
psCommand.Parameters.Add("Filter", "*"); | ||
return await _psExecutor.ExecuteAsync(psCommand); | ||
} | ||
|
||
// ReSharper disable once InconsistentNaming | ||
private async Task<PSOutput> GetADComputers() | ||
{ | ||
Command psCommand = new("Get-ADComputer"); | ||
psCommand.Parameters.Add("Filter", "*"); | ||
return await _psExecutor.ExecuteAsync(psCommand); | ||
} | ||
|
||
// ReSharper disable once InconsistentNaming | ||
private async Task<PSOutput> GetADIPv4Addresses() | ||
{ | ||
Command psCommand = new("Get-ADComputer"); | ||
psCommand.Parameters.Add("Filter", "*"); | ||
psCommand.Parameters.Add("Properties", "IPv4Address"); | ||
return await _psExecutor.ExecuteAsync(psCommand); | ||
} | ||
|
||
// ReSharper disable once InconsistentNaming | ||
private async Task<PSOutput> GetADIPv6Addresses() | ||
{ | ||
Command psCommand = new("Get-ADComputer"); | ||
psCommand.Parameters.Add("Filter", "*"); | ||
psCommand.Parameters.Add("Properties", "IPv6Address"); | ||
return await _psExecutor.ExecuteAsync(psCommand); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters