diff --git a/ActiveDirectoryQuerier/ActiveDirectory/ADCommandsFetcher.cs b/ActiveDirectoryQuerier/ActiveDirectory/ADCommandsFetcher.cs index 6ab5746..edd8a0c 100644 --- a/ActiveDirectoryQuerier/ActiveDirectory/ADCommandsFetcher.cs +++ b/ActiveDirectoryQuerier/ActiveDirectory/ADCommandsFetcher.cs @@ -23,7 +23,7 @@ public static async Task> GetADCommands() if (psOutput.HadErrors) { string errorMessage = "Internal Error: An error occurred while retrieving the Active Directory commands: " + - $"({string.Join(" ", psOutput.StdErr)})"; + $"{string.Join(" ", psOutput.StdErr)}"; MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); throw new InvalidPowerShellStateException(errorMessage); } diff --git a/ActiveDirectoryQuerier/ActiveDirectoryInfo.cs b/ActiveDirectoryQuerier/ActiveDirectoryInfo.cs new file mode 100644 index 0000000..7dd2ed4 --- /dev/null +++ b/ActiveDirectoryQuerier/ActiveDirectoryInfo.cs @@ -0,0 +1,53 @@ +using System.Management.Automation.Runspaces; +using ActiveDirectoryQuerier.PowerShell; + +namespace ActiveDirectoryQuerier; + +public class ActiveDirectoryInfo +{ + private readonly PSExecutor _psExecutor = new(); + + public Dictionary>> 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 GetADUsers() + { + Command psCommand = new("Get-ADUser"); + psCommand.Parameters.Add("Filter", "*"); + return await _psExecutor.ExecuteAsync(psCommand); + } + + // ReSharper disable once InconsistentNaming + private async Task GetADComputers() + { + Command psCommand = new("Get-ADComputer"); + psCommand.Parameters.Add("Filter", "*"); + return await _psExecutor.ExecuteAsync(psCommand); + } + + // ReSharper disable once InconsistentNaming + private async Task 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 GetADIPv6Addresses() + { + Command psCommand = new("Get-ADComputer"); + psCommand.Parameters.Add("Filter", "*"); + psCommand.Parameters.Add("Properties", "IPv6Address"); + return await _psExecutor.ExecuteAsync(psCommand); + } +} diff --git a/ActiveDirectoryQuerier/ActiveDirectoryQuerier.csproj b/ActiveDirectoryQuerier/ActiveDirectoryQuerier.csproj index 403bbb6..22d5639 100644 --- a/ActiveDirectoryQuerier/ActiveDirectoryQuerier.csproj +++ b/ActiveDirectoryQuerier/ActiveDirectoryQuerier.csproj @@ -9,7 +9,7 @@ Active Directory Querier - 0.6.0 + 0.7.0 Hunter T., Pieter, Joseph https://github.com/StrangeRanger/Active-Directory-Querier @@ -22,7 +22,7 @@ - + diff --git a/ActiveDirectoryQuerier/MainWindow.xaml b/ActiveDirectoryQuerier/MainWindow.xaml index 07c52f0..ebf43f6 100644 --- a/ActiveDirectoryQuerier/MainWindow.xaml +++ b/ActiveDirectoryQuerier/MainWindow.xaml @@ -212,15 +212,14 @@ -