From cffdca75bcc931a847f94b296b7de4206955183b Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 2 Dec 2023 16:16:35 -0800
Subject: [PATCH 01/19] Created a tab for query builder and started the drop
down
---
FAFB-PowerShell-Tool/MainWindow.xaml | 18 ++-
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 18 +++
FAFB-PowerShell-Tool/QueryBuilder.cs | 58 ++++++++++
FAFB-PowerShell-Tool/commands.txt | 147 ++++++++++++++++++++++++
4 files changed, 239 insertions(+), 2 deletions(-)
create mode 100644 FAFB-PowerShell-Tool/QueryBuilder.cs
create mode 100644 FAFB-PowerShell-Tool/commands.txt
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index a969c2c..ca7c1eb 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -9,9 +9,23 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 4020195..e521405 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -63,6 +63,24 @@ private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
MessageBox.Show("System Host Name: " + hostName, "Command Output");
}
+ private void CommandCmb(object sender, RoutedEventArgs e) {
+
+ try
+ {
+ //Get the command Combo Box to modify
+ ComboBox Cmb = this.cmbCommandList;
+
+
+
+
+ }
+ catch (Exception ex)
+ {
+ Console.Write(ex);
+ }
+
+ }
+
private void Button_Click(object sender, RoutedEventArgs e)
{
// TODO: Add method body.
diff --git a/FAFB-PowerShell-Tool/QueryBuilder.cs b/FAFB-PowerShell-Tool/QueryBuilder.cs
new file mode 100644
index 0000000..ba88a61
--- /dev/null
+++ b/FAFB-PowerShell-Tool/QueryBuilder.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Shapes;
+
+namespace FAFB_PowerShell_Tool
+{
+ public class QueryBuilder
+ {
+
+ public static List CommandList() {
+
+ List list = new List();
+
+ try
+ {
+ string srcFilePath = 'commands.txt';
+
+ StreamReader sr = new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read));
+
+ // Read file.
+ while ((line = sr.ReadLine()) != null)
+ {
+ // Initialization.
+ CountryObj obj = new CountryObj();
+ string[] info = line.Split(':');
+
+ // Setting.
+ obj.CountryCode = info[0].ToString();
+ obj.CountryName = info[1].ToString();
+
+ // Adding.
+ lst.Add(obj);
+ }
+
+ // Closing.
+ sr.Dispose();
+ sr.Close();
+ }
+
+ }
+ catch (Exception ex)
+ {
+
+ }
+
+
+ return list;
+ }
+
+
+
+
+ }
+}
diff --git a/FAFB-PowerShell-Tool/commands.txt b/FAFB-PowerShell-Tool/commands.txt
new file mode 100644
index 0000000..513b9ad
--- /dev/null
+++ b/FAFB-PowerShell-Tool/commands.txt
@@ -0,0 +1,147 @@
+Add-ADCentralAccessPolicyMember
+Add-ADComputerServiceAccount
+Add-ADDomainControllerPasswordReplicationPolicy
+Add-ADFineGrainedPasswordPolicySubject
+Add-ADGroupMember
+Add-ADPrincipalGroupMembership
+Add-ADResourcePropertyListMember
+Clear-ADAccountExpiration
+Clear-ADClaimTransformLink
+Disable-ADAccount
+Disable-ADOptionalFeature
+Enable-ADAccount
+Enable-ADOptionalFeature
+Get-ADAccountAuthorizationGroup
+Get-ADAccountResultantPasswordReplicationPolicy
+Get-ADAuthenticationPolicy
+Get-ADAuthenticationPolicySilo
+Get-ADCentralAccessPolicy
+Get-ADCentralAccessRule
+Get-ADClaimTransformPolicy
+Get-ADClaimType
+Get-ADComputer
+Get-ADComputerServiceAccount
+Get-ADDCCloningExcludedApplicationList
+Get-ADDefaultDomainPasswordPolicy
+Get-ADDomain
+Get-ADDomainController
+Get-ADDomainControllerPasswordReplicationPolicy
+Get-ADDomainControllerPasswordReplicationPolicyUsage
+Get-ADFineGrainedPasswordPolicy
+Get-ADFineGrainedPasswordPolicySubject
+Get-ADForest
+Get-ADGroup
+Get-ADGroupMember
+Get-ADObject
+Get-ADOptionalFeature
+Get-ADOrganizationalUnit
+Get-ADPrincipalGroupMembership
+Get-ADReplicationAttributeMetadata
+Get-ADReplicationConnection
+Get-ADReplicationFailure
+Get-ADReplicationPartnerMetadata
+Get-ADReplicationQueueOperation
+Get-ADReplicationSite
+Get-ADReplicationSiteLink
+Get-ADReplicationSiteLinkBridge
+Get-ADReplicationSubnet
+Get-ADReplicationUpToDatenessVectorTable
+Get-ADResourceProperty
+Get-ADResourcePropertyList
+Get-ADResourcePropertyValueType
+Get-ADRootDSE
+Get-ADServiceAccount
+Get-ADTrust
+Get-ADUser
+Get-ADUserResultantPasswordPolicy
+Grant-ADAuthenticationPolicySiloAccess
+Install-ADServiceAccount
+Move-ADDirectoryServer
+Move-ADDirectoryServerOperationMasterRole
+Move-ADObject
+New-ADAuthenticationPolicy
+New-ADAuthenticationPolicySilo
+New-ADCentralAccessPolicy
+New-ADCentralAccessRule
+New-ADClaimTransformPolicy
+New-ADClaimType
+New-ADComputer
+New-ADDCCloneConfigFile
+New-ADFineGrainedPasswordPolicy
+New-ADGroup
+New-ADObject
+New-ADOrganizationalUnit
+New-ADReplicationSite
+New-ADReplicationSiteLink
+New-ADReplicationSiteLinkBridge
+New-ADReplicationSubnet
+New-ADResourceProperty
+New-ADResourcePropertyList
+New-ADServiceAccount
+New-ADUser
+Remove-ADAuthenticationPolicy
+Remove-ADAuthenticationPolicySilo
+Remove-ADCentralAccessPolicy
+Remove-ADCentralAccessPolicyMember
+Remove-ADCentralAccessRule
+Remove-ADClaimTransformPolicy
+Remove-ADClaimType
+Remove-ADComputer
+Remove-ADComputerServiceAccount
+Remove-ADDomainControllerPasswordReplicationPolicy
+Remove-ADFineGrainedPasswordPolicy
+Remove-ADFineGrainedPasswordPolicySubject
+Remove-ADGroup
+Remove-ADGroupMember
+Remove-ADObject
+Remove-ADOrganizationalUnit
+Remove-ADPrincipalGroupMembership
+Remove-ADReplicationSite
+Remove-ADReplicationSiteLink
+Remove-ADReplicationSiteLinkBridge
+Remove-ADReplicationSubnet
+Remove-ADResourceProperty
+Remove-ADResourcePropertyList
+Remove-ADResourcePropertyListMember
+Remove-ADServiceAccount
+Remove-ADUser
+Rename-ADObject
+Reset-ADServiceAccountPassword
+Restore-ADObject
+Revoke-ADAuthenticationPolicySiloAccess
+Search-ADAccount
+Set-ADAccountAuthenticationPolicySilo
+Set-ADAccountControl
+Set-ADAccountExpiration
+Set-ADAccountPassword
+Set-ADAuthenticationPolicy
+Set-ADAuthenticationPolicySilo
+Set-ADCentralAccessPolicy
+Set-ADCentralAccessRule
+Set-ADClaimTransformLink
+Set-ADClaimTransformPolicy
+Set-ADClaimType
+Set-ADComputer
+Set-ADDefaultDomainPasswordPolicy
+Set-ADDomain
+Set-ADDomainMode
+Set-ADFineGrainedPasswordPolicy
+Set-ADForest
+Set-ADForestMode
+Set-ADGroup
+Set-ADObject
+Set-ADOrganizationalUnit
+Set-ADReplicationConnection
+Set-ADReplicationSite
+Set-ADReplicationSiteLink
+Set-ADReplicationSiteLinkBridge
+Set-ADReplicationSubnet
+Set-ADResourceProperty
+Set-ADResourcePropertyList
+Set-ADServiceAccount
+Set-ADUser
+Show-ADAuthenticationPolicyExpression
+Sync-ADObject
+Test-ADServiceAccount
+Uninstall-ADServiceAccount
+Unlock-ADAccount
\ No newline at end of file
From 52e0346e05d4a9c2b91009c88389a77bde64b935 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Fri, 8 Dec 2023 12:28:26 -0800
Subject: [PATCH 02/19] Format with clang-format
---
FAFB-PowerShell-Tool/App.xaml.cs | 3 +-
FAFB-PowerShell-Tool/AssemblyInfo.cs | 15 +++++-----
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 26 ++++++------------
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 3 +-
FAFB-PowerShell-Tool/QueryBuilder.cs | 32 ++++++++--------------
5 files changed, 29 insertions(+), 50 deletions(-)
diff --git a/FAFB-PowerShell-Tool/App.xaml.cs b/FAFB-PowerShell-Tool/App.xaml.cs
index 2cd6839..4b9a349 100644
--- a/FAFB-PowerShell-Tool/App.xaml.cs
+++ b/FAFB-PowerShell-Tool/App.xaml.cs
@@ -8,7 +8,6 @@ namespace FAFB_PowerShell_Tool
/// Interaction logic for App.xaml
///
public partial class App : Application
- {
- }
+ { }
}
diff --git a/FAFB-PowerShell-Tool/AssemblyInfo.cs b/FAFB-PowerShell-Tool/AssemblyInfo.cs
index b0ec827..020e92b 100644
--- a/FAFB-PowerShell-Tool/AssemblyInfo.cs
+++ b/FAFB-PowerShell-Tool/AssemblyInfo.cs
@@ -1,10 +1,9 @@
using System.Windows;
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
- ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
-)]
+[assembly:ThemeInfo(ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
+ // (used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly // where the generic resource dictionary is located
+ // (used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+ )]
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index e521405..aca2a00 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -43,7 +43,6 @@ private void ExecutionButton(object sender, RoutedEventArgs e)
List commandOutput = PowerShellExecutor.Execute(command);
string fullCommandOutput = "";
-
foreach (var str in commandOutput)
{
fullCommandOutput += str;
@@ -63,22 +62,17 @@ private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
MessageBox.Show("System Host Name: " + hostName, "Command Output");
}
- private void CommandCmb(object sender, RoutedEventArgs e) {
-
+ private void CommandCmb(object sender, RoutedEventArgs e)
+ {
try
{
- //Get the command Combo Box to modify
+ // Get the command Combo Box to modify
ComboBox Cmb = this.cmbCommandList;
-
-
-
-
}
catch (Exception ex)
{
Console.Write(ex);
}
-
}
private void Button_Click(object sender, RoutedEventArgs e)
@@ -106,20 +100,17 @@ private void Button_Click_1(object sender, RoutedEventArgs e)
*/
}
+ private void RunRemoteCommand(String command)
+ {
+ // command is the command you want to run like get-aduser
- private void RunRemoteCommand(String command) {
-
- //command is the command you want to run like get-aduser
-
- String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}" ;
-
+ String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}";
try
{
List commandOutput = PowerShellExecutor.Execute(invokeCommand);
string fullCommandOutput = "";
-
foreach (var str in commandOutput)
{
fullCommandOutput += str;
@@ -131,7 +122,6 @@ private void RunRemoteCommand(String command) {
{
MessageBox.Show("INTERNAL ERROR: " + ex.Message);
}
-
}
}
-}
\ No newline at end of file
+}
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index efc7749..4ccaf5f 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -15,7 +15,7 @@ public static List Execute(string commandText)
// TODO: Use a MessageBox to show errors to the user.
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
- ps.AddScript(commandText);
+ ps.AddScript(commandText);
var results = ps.Invoke();
@@ -57,4 +57,3 @@ private static void ShowError(string message)
MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
-
diff --git a/FAFB-PowerShell-Tool/QueryBuilder.cs b/FAFB-PowerShell-Tool/QueryBuilder.cs
index ba88a61..635deeb 100644
--- a/FAFB-PowerShell-Tool/QueryBuilder.cs
+++ b/FAFB-PowerShell-Tool/QueryBuilder.cs
@@ -10,9 +10,8 @@ namespace FAFB_PowerShell_Tool
{
public class QueryBuilder
{
-
- public static List CommandList() {
-
+ public static List CommandList()
+ {
List list = new List();
try
@@ -21,38 +20,31 @@ public static List CommandList() {
StreamReader sr = new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read));
- // Read file.
+ // Read file.
while ((line = sr.ReadLine()) != null)
{
- // Initialization.
+ // Initialization.
CountryObj obj = new CountryObj();
string[] info = line.Split(':');
- // Setting.
+ // Setting.
obj.CountryCode = info[0].ToString();
obj.CountryName = info[1].ToString();
- // Adding.
+ // Adding.
lst.Add(obj);
}
- // Closing.
+ // Closing.
sr.Dispose();
sr.Close();
}
-
- }
- catch (Exception ex)
- {
-
- }
-
-
- return list;
}
+ catch (Exception ex)
+ { }
-
-
-
+ return list;
}
+
+}
}
From dc9f9b79f9faeff93a80f2a2fd7ef7171842a0be Mon Sep 17 00:00:00 2001
From: "Hunter T."
Date: Fri, 8 Dec 2023 16:13:54 -0800
Subject: [PATCH 03/19] Update format with clang-format
---
FAFB-PowerShell-Tool.Tests/GlobalUsings.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/FAFB-PowerShell-Tool.Tests/GlobalUsings.cs b/FAFB-PowerShell-Tool.Tests/GlobalUsings.cs
index ab67c7e..540383d 100644
--- a/FAFB-PowerShell-Tool.Tests/GlobalUsings.cs
+++ b/FAFB-PowerShell-Tool.Tests/GlobalUsings.cs
@@ -1 +1 @@
-global using Microsoft.VisualStudio.TestTools.UnitTesting;
\ No newline at end of file
+global using Microsoft.VisualStudio.TestTools.UnitTesting;
From edcca76ab6b193d3c2beb94502a8a148ab6d39d2 Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 9 Dec 2023 14:10:03 -0800
Subject: [PATCH 04/19] got the drop down working and started a good structure
for commands
---
FAFB-PowerShell-Tool/Command.cs | 31 +++++++++++++++++
FAFB-PowerShell-Tool/MainWindow.xaml | 5 +--
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 44 ++++++++++++++++---------
FAFB-PowerShell-Tool/QueryBuilder.cs | 34 ++++++++-----------
4 files changed, 74 insertions(+), 40 deletions(-)
create mode 100644 FAFB-PowerShell-Tool/Command.cs
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
new file mode 100644
index 0000000..0e72008
--- /dev/null
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -0,0 +1,31 @@
+using JetBrains.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Text;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FAFB_PowerShell_Tool
+{
+ internal class Command
+ {
+ string commandName;
+ string[] parameters;
+ int parameterCount;
+
+ public Command(string commandName, string[] parameters, int parameterCount)
+ {
+ this.commandName = commandName;
+ this.parameters = parameters;
+ this.parameterCount = parameterCount;
+ }
+ }
+
+
+
+
+
+
+
+}
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index ca7c1eb..b5d0671 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -19,10 +19,7 @@
-
-
-
-
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index e521405..155018c 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -1,3 +1,4 @@
+using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
@@ -14,6 +15,33 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
+
+
+ // This is for the combox containing the commands
+ try
+ {
+ //Get the command Combo Box to modify
+ ComboBox Cmb = this.cmbCommandList;
+
+ ObservableCollection list = new ObservableCollection();
+
+ list.Add("hello");
+ list.Add("he");
+ list.Add("heladso");
+ list.Add("hellasdfo");
+ list.Add("helldfdfo");
+ list.Add("hellfffffo");
+
+ Cmb.ItemsSource = list;
+
+
+
+ }
+ catch (Exception ex)
+ {
+ Console.Write(ex);
+ }
+
}
private void CommandButton1(object sender, RoutedEventArgs e)
@@ -63,21 +91,7 @@ private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
MessageBox.Show("System Host Name: " + hostName, "Command Output");
}
- private void CommandCmb(object sender, RoutedEventArgs e) {
-
- try
- {
- //Get the command Combo Box to modify
- ComboBox Cmb = this.cmbCommandList;
-
-
-
-
- }
- catch (Exception ex)
- {
- Console.Write(ex);
- }
+ private void Window_Loaded(object sender, RoutedEventArgs e) {
}
diff --git a/FAFB-PowerShell-Tool/QueryBuilder.cs b/FAFB-PowerShell-Tool/QueryBuilder.cs
index ba88a61..6560735 100644
--- a/FAFB-PowerShell-Tool/QueryBuilder.cs
+++ b/FAFB-PowerShell-Tool/QueryBuilder.cs
@@ -2,49 +2,41 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Shapes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Collections.ObjectModel;
namespace FAFB_PowerShell_Tool
{
public class QueryBuilder
{
- public static List CommandList() {
+ public static ObservableCollection CommandList() {
- List list = new List();
+ ObservableCollection list = new ObservableCollection();
try
{
- string srcFilePath = 'commands.txt';
-
- StreamReader sr = new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read));
+ string srcFilePath = "commands.txt";
+ string[] lines = File.ReadAllLines(srcFilePath);
// Read file.
- while ((line = sr.ReadLine()) != null)
+ foreach (string line in lines)
{
- // Initialization.
- CountryObj obj = new CountryObj();
- string[] info = line.Split(':');
-
- // Setting.
- obj.CountryCode = info[0].ToString();
- obj.CountryName = info[1].ToString();
-
- // Adding.
- lst.Add(obj);
+ list.Add(line);
}
// Closing.
- sr.Dispose();
- sr.Close();
- }
-
}
catch (Exception ex)
{
-
+ Console.WriteLine(ex.Message);
}
From 6a39ccbcd74d68207805f89cf63df432e12fb945 Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 9 Dec 2023 15:55:46 -0800
Subject: [PATCH 05/19] Building the Command class with functions for the
commands, and getting it working
---
FAFB-PowerShell-Tool/Command.cs | 84 +++++++++++++++++++++++--
FAFB-PowerShell-Tool/MainWindow.xaml | 2 +-
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 15 +----
3 files changed, 82 insertions(+), 19 deletions(-)
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index 0e72008..c72ab10 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -1,18 +1,29 @@
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Drawing.Text;
using System.Linq;
using System.Text;
+using System.IO;
using System.Threading.Tasks;
+using System.Diagnostics;
namespace FAFB_PowerShell_Tool
{
- internal class Command
+
+ ///
+ /// This class is used to organize the all of the powershell commands
+ ///
+ ///
+ /// This is the root commands name ex. "get-aduser"
+ /// This is an array of the parameter options that the command has
+ /// This is the counr of the parameter array
+ public class Command
{
- string commandName;
- string[] parameters;
- int parameterCount;
+ public string commandName { get; set; }
+ string[] parameters { get; set; }
+ int parameterCount { get; set; }
public Command(string commandName, string[] parameters, int parameterCount)
{
@@ -20,11 +31,74 @@ public Command(string commandName, string[] parameters, int parameterCount)
this.parameters = parameters;
this.parameterCount = parameterCount;
}
+ public Command(string commandName)
+ {
+ this.commandName = commandName;
+ }
+
+ ///
+ /// This is a method for getting a list of commands from a file
+ ///
+ /// "list" this is an ObservableCollection of the Commands
+ public static ObservableCollection ReadFileCommandList()
+ {
+
+ ObservableCollection list = new ObservableCollection();
+
+ try
+ {
+ //get the file path will probably want user input eventually and to use relative paths
+ string srcFilePath = "C:\\Users\\pickl\\Source\\Repos\\FAFB-PowerShell-Tool\\FAFB-PowerShell-Tool\\commands.txt";
+ string[] lines = File.ReadAllLines(srcFilePath);
+
+ // Trim the strings and add them to the return list
+ foreach (string line in lines)
+ {
+ string trimmedLine = line.Trim();
+ Command command = new Command(trimmedLine);
+
+ list.Add(command);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+
+
+ return list;
+ }
+
+ ///
+ /// This method is for getting the commands of a particular module
+ ///
+ /// A List of Commands in an Observable Collection
+ public static ObservableCollection GetPowerShellCommands()
+ {
+ return new ObservableCollection();
+ }
+ ///
+ /// This method is for getting the parameters of a Command
+ ///
+ /// This is the command in question
+ /// This is the powershell command to get the parameters of the command
+ ///
+ public string[] GetParametersArray(Command c)
+ {
+ string getParameterSetnames = "(Get-Command " + c.commandName + ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
+
+ List results = PowerShellExecutor.Execute(getParameterSetnames);
+ Trace.WriteLine(results);
+
+
+
+ return new string[1];
+ }
}
-
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index b5d0671..c0924e6 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -19,7 +19,7 @@
-
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 507a164..a4c6969 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -22,20 +22,9 @@ public MainWindow()
{
//Get the command Combo Box to modify
ComboBox Cmb = this.cmbCommandList;
-
- ObservableCollection list = new ObservableCollection();
-
- list.Add("hello");
- list.Add("he");
- list.Add("heladso");
- list.Add("hellasdfo");
- list.Add("helldfdfo");
- list.Add("hellfffffo");
-
+ ObservableCollection list = Command.ReadFileCommandList();
Cmb.ItemsSource = list;
-
-
-
+ Cmb.DisplayMemberPath = "commandName";
}
catch (Exception ex)
{
From 1711a4a82118b9b898c6276c6abf430e10537146 Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 9 Dec 2023 16:53:20 -0800
Subject: [PATCH 06/19] Changed the powershell error output to the solution
directory to avoid permissions
---
FAFB-PowerShell-Tool/Command.cs | 2 +-
.../FAFB-PowerShell-Tool-Output.txt | 1 +
FAFB-PowerShell-Tool/MainWindow.xaml | 3 ++-
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 24 ++++++++++++++++++-
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 2 +-
5 files changed, 28 insertions(+), 4 deletions(-)
create mode 100644 FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index c72ab10..3949afe 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -83,7 +83,7 @@ public static ObservableCollection GetPowerShellCommands()
/// This is the command in question
/// This is the powershell command to get the parameters of the command
///
- public string[] GetParametersArray(Command c)
+ public static string[] GetParametersArray(Command c)
{
string getParameterSetnames = "(Get-Command " + c.commandName + ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
diff --git a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
new file mode 100644
index 0000000..8c5333d
--- /dev/null
+++ b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
@@ -0,0 +1 @@
+Error: A parameter cannot be found that matches parameter name 'filter'.
\ No newline at end of file
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index c0924e6..8d01859 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -19,7 +19,8 @@
-
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index a4c6969..4bda6d3 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -35,7 +35,9 @@ public MainWindow()
private void CommandButton1(object sender, RoutedEventArgs e)
{
- command = "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String -Width 4096";
+ //Seems like you need to import the neccesary module that you are using possibly
+ command = "Import-Module ActiveDirectory" +
+ "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String -Width 4096";
}
private void CommandButton2(object sender, RoutedEventArgs e)
@@ -88,6 +90,26 @@ private void Button_Click(object sender, RoutedEventArgs e)
// TODO: Add method body.
}
+ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //Get the combox that we are working with
+ ComboBox? cmb = sender as ComboBox;
+ //Get the command that is selected which is just an object so we have to convert to Command
+ try
+ {
+ Command? selectedCommand = cmb.SelectedValue as Command;
+ Trace.WriteLine("Selcetion changed: " + selectedCommand.commandName);
+
+ string[] test = Command.GetParametersArray(selectedCommand);
+ } catch (Exception ex)
+ {
+ Trace.WriteLine(ex);
+ }
+ //Debug
+
+
+ }
+
private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
// TODO: Add method body.
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index 4ccaf5f..959d1e2 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -11,7 +11,7 @@ public static List Execute(string commandText)
{
using PowerShell ps = PowerShell.Create();
List returnValues = new List();
- string filePath = @"C:\FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
+ string filePath = @"../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
// TODO: Use a MessageBox to show errors to the user.
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
From a8ffe83140fc57c6e584190fabe9caaf78c27b27 Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 9 Dec 2023 17:07:32 -0800
Subject: [PATCH 07/19] The parameter drop down can be filled once the command
is fixed, it runs in ps but not in this version
---
FAFB-PowerShell-Tool/Command.cs | 26 ++++++++++++++++---
.../FAFB-PowerShell-Tool-Output.txt | 2 +-
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 3 ++-
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index 3949afe..b5464ca 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -8,6 +8,8 @@
using System.IO;
using System.Threading.Tasks;
using System.Diagnostics;
+using System.Management.Automation.Runspaces;
+using System.Windows;
namespace FAFB_PowerShell_Tool
{
@@ -85,10 +87,28 @@ public static ObservableCollection GetPowerShellCommands()
///
public static string[] GetParametersArray(Command c)
{
- string getParameterSetnames = "(Get-Command " + c.commandName + ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
+ string getParameterSetnames = "Import-Module ActiveDirectory" +
+ "(Get-Command " + c.commandName + ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
- List results = PowerShellExecutor.Execute(getParameterSetnames);
- Trace.WriteLine(results);
+ //List results = PowerShellExecutor.Execute(getParameterSetnames);
+ //Trace.WriteLine(results.Count);
+
+ try
+ {
+ List commandOutput = PowerShellExecutor.Execute(getParameterSetnames);
+ string fullCommandOutput = "";
+
+ foreach (var str in commandOutput)
+ {
+ fullCommandOutput += str;
+ }
+
+ MessageBox.Show(fullCommandOutput, "Command Output");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ }
diff --git a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
index 8c5333d..760f70d 100644
--- a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
+++ b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
@@ -1 +1 @@
-Error: A parameter cannot be found that matches parameter name 'filter'.
\ No newline at end of file
+Error: A positional parameter cannot be found that accepts argument 'System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.CommandParameterSetInfo]'.
\ No newline at end of file
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 4bda6d3..8638b4a 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -47,7 +47,8 @@ private void CommandButton2(object sender, RoutedEventArgs e)
private void CommandButton3(object sender, RoutedEventArgs e)
{
- command = "Get-Process | Out-String -Width 4096";
+ command = "Import-Module ActiveDirectory" +
+ "(Get-Command Get-Process).ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}} | Out-String -Width 4096";
}
private void CommandButton4(object sender, RoutedEventArgs e)
From 11689d30fc7cb76d1d89be81ffc510c47ca16f66 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Sun, 10 Dec 2023 19:07:50 -0800
Subject: [PATCH 08/19] Several changes:
- Format with clang-format
- Remove unused imports
- Slight refactor
- PowerShellExecutor.cs is now a singleton
- Fix naming conventions
---
.gitignore | 6 +
.../PowerShellExecutorTest.cs | 35 ++-
FAFB-PowerShell-Tool/App.xaml.cs | 18 +-
FAFB-PowerShell-Tool/Command.cs | 177 +++++++-------
.../FAFB-PowerShell-Tool-Output.txt | 1 -
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 220 +++++++++---------
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 43 +++-
FAFB-PowerShell-Tool/QueryBuilder.cs | 54 ++---
8 files changed, 266 insertions(+), 288 deletions(-)
delete mode 100644 FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
diff --git a/.gitignore b/.gitignore
index 0d608c1..8e74522 100644
--- a/.gitignore
+++ b/.gitignore
@@ -479,3 +479,9 @@ $RECYCLE.BIN/
.vscode/launch.json
.vscode/tasks.json
+
+.idea/.idea.FAFB-PowerShell-Tool/.idea/indexLayout.xml
+
+.idea/.idea.FAFB-PowerShell-Tool/.idea/workspace.xml
+
+FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
diff --git a/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs b/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
index 28deeea..c392a9e 100644
--- a/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
+++ b/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
@@ -1,25 +1,20 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace FAFB_PowerShell_Tool.Tests;
-namespace FAFB_PowerShell_Tool.Tests
+[TestClass]
+public class PowerShellExecutorTest
{
- [TestClass]
- public class PowerShellExecutorTest
+ private readonly PowerShellExecutor _powerShellExecutor = PowerShellExecutor.Instance;
+
+ [TestMethod]
+ public void ThrowArgumentNullExceptionWhenCommandTextIsNull()
{
- [TestMethod]
- public void ThrowArgumentNullExceptionWhenCommandTextIsNull()
- {
- Assert.ThrowsException(() => PowerShellExecutor.Execute(null!));
- }
+ Assert.ThrowsException(() => _powerShellExecutor.Execute(null!));
+ }
- [TestMethod]
- public void ThrowArgumentExceptionWhenCommandTextIsWhitespace()
- {
- Assert.ThrowsException(() => PowerShellExecutor.Execute(""));
- Assert.ThrowsException(() => PowerShellExecutor.Execute(" "));
- }
+ [TestMethod]
+ public void ThrowArgumentExceptionWhenCommandTextIsWhitespace()
+ {
+ Assert.ThrowsException(() => _powerShellExecutor.Execute(""));
+ Assert.ThrowsException(() => _powerShellExecutor.Execute(" "));
}
-}
+}
\ No newline at end of file
diff --git a/FAFB-PowerShell-Tool/App.xaml.cs b/FAFB-PowerShell-Tool/App.xaml.cs
index 4b9a349..b06bd4e 100644
--- a/FAFB-PowerShell-Tool/App.xaml.cs
+++ b/FAFB-PowerShell-Tool/App.xaml.cs
@@ -1,13 +1,9 @@
-using System.Configuration;
-using System.Data;
-using System.Windows;
+using System.Windows;
-namespace FAFB_PowerShell_Tool
-{
- ///
- /// Interaction logic for App.xaml
- ///
- public partial class App : Application
- { }
+namespace FAFB_PowerShell_Tool;
-}
+///
+/// Interaction logic for App.xaml
+///
+public partial class App : Application
+{ }
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index b5464ca..b9c9bf5 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -1,125 +1,106 @@
-using JetBrains.Annotations;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Drawing.Text;
-using System.Linq;
-using System.Text;
+using System.Collections.ObjectModel;
using System.IO;
-using System.Threading.Tasks;
-using System.Diagnostics;
-using System.Management.Automation.Runspaces;
using System.Windows;
-namespace FAFB_PowerShell_Tool
+namespace FAFB_PowerShell_Tool;
+
+///
+/// This class is used to organize the all of the powershell commands
+///
+///
+/// This is the root commands name ex. "get-aduser"
+/// This is an array of the parameter options that the command has
+/// This is the counr of the parameter array
+public class Command
{
+ public string CommandName { get; set; }
+ private string[] Parameters { get; set; }
+ private int ParameterCount { get; set; }
+ private static readonly PowerShellExecutor PowerShellExecutor = PowerShellExecutor.Instance;
+
+ public Command(string commandName, string[] parameters, int parameterCount)
+ {
+ CommandName = commandName;
+ Parameters = parameters;
+ ParameterCount = parameterCount;
+ }
+ public Command(string commandName)
+ {
+ CommandName = commandName;
+ }
///
- /// This class is used to organize the all of the powershell commands
+ /// This is a method for getting a list of commands from a file
///
- ///
- /// This is the root commands name ex. "get-aduser"
- /// This is an array of the parameter options that the command has
- /// This is the counr of the parameter array
- public class Command
+ /// "list" this is an ObservableCollection of the Commands
+ public static ObservableCollection ReadFileCommandList()
{
- public string commandName { get; set; }
- string[] parameters { get; set; }
- int parameterCount { get; set; }
-
- public Command(string commandName, string[] parameters, int parameterCount)
- {
- this.commandName = commandName;
- this.parameters = parameters;
- this.parameterCount = parameterCount;
- }
- public Command(string commandName)
- {
- this.commandName = commandName;
- }
+ ObservableCollection list = new ObservableCollection();
- ///
- /// This is a method for getting a list of commands from a file
- ///
- /// "list" this is an ObservableCollection of the Commands
- public static ObservableCollection ReadFileCommandList()
+ try
{
+ // get the file path will probably want user input eventually and to use relative paths
+ string srcFilePath =
+ "C:\\Users\\pickl\\Source\\Repos\\FAFB-PowerShell-Tool\\FAFB-PowerShell-Tool\\commands.txt";
+ string[] lines = File.ReadAllLines(srcFilePath);
- ObservableCollection list = new ObservableCollection();
-
- try
+ // Trim the strings and add them to the return list
+ foreach (string line in lines)
{
- //get the file path will probably want user input eventually and to use relative paths
- string srcFilePath = "C:\\Users\\pickl\\Source\\Repos\\FAFB-PowerShell-Tool\\FAFB-PowerShell-Tool\\commands.txt";
- string[] lines = File.ReadAllLines(srcFilePath);
-
- // Trim the strings and add them to the return list
- foreach (string line in lines)
- {
- string trimmedLine = line.Trim();
- Command command = new Command(trimmedLine);
+ string trimmedLine = line.Trim();
+ Command command = new Command(trimmedLine);
- list.Add(command);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
+ list.Add(command);
}
-
-
- return list;
}
-
- ///
- /// This method is for getting the commands of a particular module
- ///
- /// A List of Commands in an Observable Collection
- public static ObservableCollection GetPowerShellCommands()
+ catch (Exception ex)
{
- return new ObservableCollection();
+ Console.WriteLine(ex.Message);
}
- ///
- /// This method is for getting the parameters of a Command
- ///
- /// This is the command in question
- /// This is the powershell command to get the parameters of the command
- ///
- public static string[] GetParametersArray(Command c)
- {
- string getParameterSetnames = "Import-Module ActiveDirectory" +
- "(Get-Command " + c.commandName + ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
-
- //List results = PowerShellExecutor.Execute(getParameterSetnames);
- //Trace.WriteLine(results.Count);
-
- try
- {
- List commandOutput = PowerShellExecutor.Execute(getParameterSetnames);
- string fullCommandOutput = "";
- foreach (var str in commandOutput)
- {
- fullCommandOutput += str;
- }
-
- MessageBox.Show(fullCommandOutput, "Command Output");
- }
- catch (Exception ex)
- {
- MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
- }
-
-
-
- return new string[1];
- }
+ return list;
}
+ ///
+ /// Retrieves the commands of a particular module.
+ ///
+ /// A List of Commands in an Observable Collection.
+ public static ObservableCollection GetPowerShellCommands()
+ {
+ return new ObservableCollection();
+ }
+ ///
+ /// Retrieves the parameters of a Command.
+ ///
+ /// The command in question.
+ /// ...
+ public static string[] GetParametersArray(Command c)
+ {
+ string getParameterSetNames =
+ "Import-Module ActiveDirectory" + "(Get-Command " + c.CommandName +
+ ").ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}}";
+ // List results = PowerShellExecutor.Execute(getParameterSetnames);
+ // Trace.WriteLine(results.Count);
+ try
+ {
+ List commandOutput = PowerShellExecutor.Execute(getParameterSetNames);
+ string fullCommandOutput = "";
+ foreach (var str in commandOutput)
+ {
+ fullCommandOutput += str;
+ }
+ MessageBox.Show(fullCommandOutput, "Command Output");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ }
+ return new string[1];
+ }
}
diff --git a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
deleted file mode 100644
index 760f70d..0000000
--- a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
+++ /dev/null
@@ -1 +0,0 @@
-Error: A positional parameter cannot be found that accepts argument 'System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.CommandParameterSetInfo]'.
\ No newline at end of file
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 8638b4a..0e207a5 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -3,156 +3,150 @@
using System.Windows;
using System.Windows.Controls;
-namespace FAFB_PowerShell_Tool
+namespace FAFB_PowerShell_Tool;
+
+///
+/// Interaction logic for MainWindow.xaml
+///
+public partial class MainWindow : Window
{
- ///
- /// Interaction logic for MainWindow.xaml
- ///
- public partial class MainWindow : Window
+ private string _command = null!;
+ private readonly PowerShellExecutor _powerShellExecutor = PowerShellExecutor.Instance;
+
+ public MainWindow()
{
- private string command = null!;
+ InitializeComponent();
- public MainWindow()
+ // This is for the combox containing the commands
+ try
{
- InitializeComponent();
-
-
- // This is for the combox containing the commands
- try
- {
- //Get the command Combo Box to modify
- ComboBox Cmb = this.cmbCommandList;
- ObservableCollection list = Command.ReadFileCommandList();
- Cmb.ItemsSource = list;
- Cmb.DisplayMemberPath = "commandName";
- }
- catch (Exception ex)
- {
- Console.Write(ex);
- }
-
+ // Get the command Combo Box to modify
+ ComboBox cmb = cmbCommandList;
+ ObservableCollection list = Command.ReadFileCommandList();
+ cmb.ItemsSource = list;
+ cmb.DisplayMemberPath = "commandName";
}
-
- private void CommandButton1(object sender, RoutedEventArgs e)
+ catch (Exception ex)
{
- //Seems like you need to import the neccesary module that you are using possibly
- command = "Import-Module ActiveDirectory" +
- "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String -Width 4096";
+ Console.Write(ex);
}
+ }
- private void CommandButton2(object sender, RoutedEventArgs e)
- {
- command = "Get-Process";
- }
+ private void CommandButton1(object sender, RoutedEventArgs e)
+ {
+ // Seems like you need to import the necessary module that you are using possibly
+ _command = "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String";
+ }
- private void CommandButton3(object sender, RoutedEventArgs e)
- {
- command = "Import-Module ActiveDirectory" +
- "(Get-Command Get-Process).ParameterSets | Select-Object -Property @{n='ParameterSetName';e={$_.name}}, @{n='Parameters';e={$_.ToString()}} | Out-String -Width 4096";
- }
+ private void CommandButton2(object sender, RoutedEventArgs e)
+ {
+ _command = "Get-Process | Out-String";
+ }
- private void CommandButton4(object sender, RoutedEventArgs e)
- {
- command = "Get-ChildItem -Path $env:USERPROFILE | Out-String -Width 4096";
- }
+ private void CommandButton3(object sender, RoutedEventArgs e)
+ {
+ _command = "Get-ChildItem -Path $env:USERPROFILE";
+ }
- private void ExecutionButton(object sender, RoutedEventArgs e)
- {
- try
- {
- List commandOutput = PowerShellExecutor.Execute(command);
- string fullCommandOutput = "";
+ private void CommandButton4(object sender, RoutedEventArgs e)
+ {
+ _command = "Get-ChildItem -Path $env:USERPROFILE | Out-String";
+ }
- foreach (var str in commandOutput)
- {
- fullCommandOutput += str;
- }
+ private void ExecutionButton(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ List commandOutput = _powerShellExecutor.Execute(_command);
+ string fullCommandOutput = "";
- MessageBox.Show(fullCommandOutput, "Command Output");
- }
- catch (Exception ex)
+ foreach (var str in commandOutput)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ fullCommandOutput += str;
}
- }
- private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
- {
- string hostName = System.Net.Dns.GetHostName();
- MessageBox.Show("System Host Name: " + hostName, "Command Output");
+ MessageBox.Show(fullCommandOutput, "Command Output");
}
-
- private void Window_Loaded(object sender, RoutedEventArgs e) {
-
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
+ catch (Exception ex)
{
- // TODO: Add method body.
+ MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
}
+ }
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- //Get the combox that we are working with
- ComboBox? cmb = sender as ComboBox;
- //Get the command that is selected which is just an object so we have to convert to Command
- try
- {
- Command? selectedCommand = cmb.SelectedValue as Command;
- Trace.WriteLine("Selcetion changed: " + selectedCommand.commandName);
+ private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
+ {
+ string hostName = System.Net.Dns.GetHostName();
+ MessageBox.Show("System Host Name: " + hostName, "Command Output");
+ }
- string[] test = Command.GetParametersArray(selectedCommand);
- } catch (Exception ex)
- {
- Trace.WriteLine(ex);
- }
- //Debug
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ { }
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ // TODO: Add method body.
+ }
- }
+ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // Get the combox that we are working with
+ ComboBox? cmb = sender as ComboBox;
+ // Get the command that is selected which is just an object so we have to convert to Command
+ try
+ {
+ Command? selectedCommand = cmb.SelectedValue as Command;
+ Trace.WriteLine("Selcetion changed: " + selectedCommand.CommandName);
- private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
+ string[] test = Command.GetParametersArray(selectedCommand);
+ }
+ catch (Exception ex)
{
- // TODO: Add method body.
+ Trace.WriteLine(ex);
}
+ // Debug
+ }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- String computerName = "";
+ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ // TODO: Add method body.
+ }
- String startRemoteSession = "$sessionAD = New-PSSession -ComputerName" + computerName;
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ String computerName = "";
- /*
- TextBox tbx = new TextBox();
+ String startRemoteSession = "$sessionAD = New-PSSession -ComputerName" + computerName;
- tbx.Visibility = Visibility.Visible;
- //tbx.ClearValue
- tbx.
- */
- }
+ /*
+ TextBox tbx = new TextBox();
- private void RunRemoteCommand(String command)
- {
- // command is the command you want to run like get-aduser
+ tbx.Visibility = Visibility.Visible;
+ //tbx.ClearValue
+ tbx.
+ */
+ }
- String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}";
+ private void RunRemoteCommand(String command)
+ {
+ // command is the command you want to run like get-aduser
- try
- {
- List commandOutput = PowerShellExecutor.Execute(invokeCommand);
- string fullCommandOutput = "";
+ String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}";
- foreach (var str in commandOutput)
- {
- fullCommandOutput += str;
- }
+ try
+ {
+ List commandOutput = _powerShellExecutor.Execute(invokeCommand);
+ string fullCommandOutput = "";
- MessageBox.Show(fullCommandOutput);
- }
- catch (Exception ex)
+ foreach (var str in commandOutput)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message);
+ fullCommandOutput += str;
}
+
+ MessageBox.Show(fullCommandOutput);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("INTERNAL ERROR: " + ex.Message);
}
}
}
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index 959d1e2..0c276dd 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -4,24 +4,46 @@
namespace FAFB_PowerShell_Tool;
-// TODO: Should this be made into a singleton rather than a static class?
public class PowerShellExecutor
{
- public static List Execute(string commandText)
+ private static PowerShellExecutor _instance;
+ private PowerShell _powerShell;
+
+ // Private constructor.
+ private PowerShellExecutor()
+ {
+ _powerShell = PowerShell.Create();
+ //_powerShell.AddScript("Import-Module ActiveDirectory");
+ //_powerShell.Invoke();
+ //_powerShell.Commands.Clear();
+ }
+
+ // Public static method to get the instance.
+ public static PowerShellExecutor Instance
+ {
+ get {
+ if (_instance is null)
+ {
+ _instance = new PowerShellExecutor();
+ }
+ return _instance;
+ }
+ }
+
+ public List Execute(string commandText)
{
- using PowerShell ps = PowerShell.Create();
List returnValues = new List();
- string filePath = @"../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
+ string filePath = "../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
// TODO: Use a MessageBox to show errors to the user.
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
- ps.AddScript(commandText);
+ _powerShell.AddScript(commandText);
- var results = ps.Invoke();
+ var results = _powerShell.Invoke();
- if (ps.HadErrors)
+ if (_powerShell.HadErrors)
{
- foreach (var error in ps.Streams.Error)
+ foreach (var error in _powerShell.Streams.Error)
{
File.WriteAllText(filePath, "Error: " + error.ToString()); // For testing purposes only.
returnValues.Add("Error: " + error.ToString());
@@ -39,7 +61,7 @@ public static List Execute(string commandText)
return returnValues;
}
- private static void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string commandText)
+ private void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string commandText)
{
if (commandText is null)
{
@@ -52,8 +74,9 @@ private static void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string command
}
}
- private static void ShowError(string message)
+ private void ShowError(string message)
{
MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
+
diff --git a/FAFB-PowerShell-Tool/QueryBuilder.cs b/FAFB-PowerShell-Tool/QueryBuilder.cs
index 5ebb895..d67db2b 100644
--- a/FAFB-PowerShell-Tool/QueryBuilder.cs
+++ b/FAFB-PowerShell-Tool/QueryBuilder.cs
@@ -1,47 +1,31 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Shapes;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.IO;
using System.Collections.ObjectModel;
-namespace FAFB_PowerShell_Tool
+namespace FAFB_PowerShell_Tool;
+
+public class QueryBuilder
{
- public class QueryBuilder
+ public static ObservableCollection CommandList()
{
-
- public static ObservableCollection CommandList() {
+ ObservableCollection list = new ObservableCollection();
- ObservableCollection list = new ObservableCollection();
+ try
+ {
+ string srcFilePath = "commands.txt";
+ string[] lines = File.ReadAllLines(srcFilePath);
- try
+ // Read file.
+ foreach (string line in lines)
{
- string srcFilePath = "commands.txt";
- string[] lines = File.ReadAllLines(srcFilePath);
-
- // Read file.
- foreach (string line in lines)
- {
- list.Add(line);
- }
-
- // Closing.
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
+ list.Add(line);
}
-
+ // Closing.
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
return list;
}
-
-}
}
From 3bb0d5552b036367bbd8a7ab113f6d4ea9e975ea Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 23 Dec 2023 17:38:48 -0800
Subject: [PATCH 09/19] Started to implement the saving feature of the query
and just designing
---
FAFB-PowerShell-Tool/Command.cs | 7 +++--
FAFB-PowerShell-Tool/MainWindow.xaml | 11 +++----
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 30 ++++++++++++++++++-
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 7 +++++
.../{QueryBuilder.cs => Query.cs} | 6 ++--
5 files changed, 50 insertions(+), 11 deletions(-)
rename FAFB-PowerShell-Tool/{QueryBuilder.cs => Query.cs} (87%)
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index b9c9bf5..371a1de 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -1,5 +1,6 @@
using System.Collections.ObjectModel;
using System.IO;
+using System.Management.Automation;
using System.Windows;
namespace FAFB_PowerShell_Tool;
@@ -8,9 +9,9 @@ namespace FAFB_PowerShell_Tool;
/// This class is used to organize the all of the powershell commands
///
///
-/// This is the root commands name ex. "get-aduser"
-/// This is an array of the parameter options that the command has
-/// This is the counr of the parameter array
+/// This is the root commands name ex. "get-aduser"
+/// This is an array of the parameter options that the command has
+/// This is the counr of the parameter array
public class Command
{
public string CommandName { get; set; }
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index 8d01859..5d2ec33 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -21,13 +21,14 @@
+
-
+
@@ -35,10 +36,10 @@
-
-
-
-
+
+
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 0e207a5..4280096 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -24,7 +24,7 @@ public MainWindow()
ComboBox cmb = cmbCommandList;
ObservableCollection list = Command.ReadFileCommandList();
cmb.ItemsSource = list;
- cmb.DisplayMemberPath = "commandName";
+ cmb.DisplayMemberPath = "CommandName";
}
catch (Exception ex)
{
@@ -149,4 +149,32 @@ private void RunRemoteCommand(String command)
MessageBox.Show("INTERNAL ERROR: " + ex.Message);
}
}
+
+ ///
+ /// Click Handler for the Save query button
+ ///
+ ///
+ ///
+ private void SaveQuery_Click(object sender, RoutedEventArgs e)
+ {
+ // Try to get the content within the drop downs
+ try
+ {
+ // Get the Command
+ Command? commadName = cmbCommandList.SelectedValue as Command;
+ //string commandParameters = cmbParameters.Text;
+
+ Button newButton = new Button();
+ newButton.Content = "Special Command";
+ newButton.Width = 140;
+ newButton.Height = 48;
+
+ Left_Side_Query_Bar.Children.Add(newButton);
+ }
+ catch (Exception ex)
+ {
+ Console.Write(ex);
+ }
+
+ }
}
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index 0c276dd..2c5b515 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -35,12 +35,17 @@ public List Execute(string commandText)
List returnValues = new List();
string filePath = "../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
+ returnValues.Clear();
+
// TODO: Use a MessageBox to show errors to the user.
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
_powerShell.AddScript(commandText);
var results = _powerShell.Invoke();
+
+
+
if (_powerShell.HadErrors)
{
foreach (var error in _powerShell.Streams.Error)
@@ -58,6 +63,8 @@ public List Execute(string commandText)
}
}
+
+
return returnValues;
}
diff --git a/FAFB-PowerShell-Tool/QueryBuilder.cs b/FAFB-PowerShell-Tool/Query.cs
similarity index 87%
rename from FAFB-PowerShell-Tool/QueryBuilder.cs
rename to FAFB-PowerShell-Tool/Query.cs
index d67db2b..74dd019 100644
--- a/FAFB-PowerShell-Tool/QueryBuilder.cs
+++ b/FAFB-PowerShell-Tool/Query.cs
@@ -2,8 +2,10 @@
using System.Collections.ObjectModel;
namespace FAFB_PowerShell_Tool;
-
-public class QueryBuilder
+///
+/// This will contain a query that is built
+///
+public class Query
{
public static ObservableCollection CommandList()
{
From dc52b75a525ce22a91348c0cb600fd95ea5516e6 Mon Sep 17 00:00:00 2001
From: J0seph0 <103216770+J0seph0@users.noreply.github.com>
Date: Sat, 23 Dec 2023 17:56:18 -0800
Subject: [PATCH 10/19] Started work on a editor on the last tab
---
FAFB-PowerShell-Tool/MainWindow.xaml | 19 ++++++++++++++----
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 26 +++++++++++++++++++++++++
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index 5d2ec33..e469ef4 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -11,19 +11,30 @@
-
+
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 4280096..b10c0e4 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -177,4 +177,30 @@ private void SaveQuery_Click(object sender, RoutedEventArgs e)
}
}
+
+ private void ExecuteScriptEditorButton(object sender, RoutedEventArgs e)
+ {
+
+ string scriptEditorText = Script_Editor.Text;
+
+ Trace.WriteLine(scriptEditorText);
+
+
+ try
+ {
+ List commandOutput = _powerShellExecutor.Execute(scriptEditorText);
+ string fullCommandOutput = "";
+
+ foreach (var str in commandOutput)
+ {
+ fullCommandOutput += str;
+ }
+
+ MessageBox.Show(fullCommandOutput, "Command Output");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ }
+ }
}
From 94c51fdbd90a153248fc64cbc295214575b7ceeb Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Sun, 24 Dec 2023 14:28:00 -0800
Subject: [PATCH 11/19] Possible fix and more changes...
---
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 19 +++++----
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 49 +++++++++-------------
2 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index b10c0e4..84ada0c 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -11,13 +11,16 @@ namespace FAFB_PowerShell_Tool;
public partial class MainWindow : Window
{
private string _command = null!;
+ private string _fullCommandOutput = null!;
+ private List _commandOutput = null!;
private readonly PowerShellExecutor _powerShellExecutor = PowerShellExecutor.Instance;
+
public MainWindow()
{
InitializeComponent();
- // This is for the combox containing the commands
+ // This is for the ComboBox containing the commands.
try
{
// Get the command Combo Box to modify
@@ -34,7 +37,6 @@ public MainWindow()
private void CommandButton1(object sender, RoutedEventArgs e)
{
- // Seems like you need to import the necessary module that you are using possibly
_command = "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String";
}
@@ -57,20 +59,23 @@ private void ExecutionButton(object sender, RoutedEventArgs e)
{
try
{
- List commandOutput = _powerShellExecutor.Execute(_command);
- string fullCommandOutput = "";
+ _commandOutput = _powerShellExecutor.Execute(_command);
+ _fullCommandOutput = "";
- foreach (var str in commandOutput)
+ foreach (var str in _commandOutput)
{
- fullCommandOutput += str;
+ _fullCommandOutput += str;
}
- MessageBox.Show(fullCommandOutput, "Command Output");
+ MessageBox.Show(_fullCommandOutput, "Command Output");
}
catch (Exception ex)
{
MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
}
+
+ _commandOutput.Clear();
+ _fullCommandOutput = "";
}
private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index 2c5b515..219608a 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -6,52 +6,40 @@ namespace FAFB_PowerShell_Tool;
public class PowerShellExecutor
{
- private static PowerShellExecutor _instance;
- private PowerShell _powerShell;
+ private static PowerShellExecutor? _instance;
+ private readonly PowerShell _powerShell;
- // Private constructor.
private PowerShellExecutor()
{
_powerShell = PowerShell.Create();
- //_powerShell.AddScript("Import-Module ActiveDirectory");
- //_powerShell.Invoke();
- //_powerShell.Commands.Clear();
+ _powerShell.AddScript("Import-Module ActiveDirectory;");
+ _powerShell.Invoke();
+ _powerShell.Commands.Clear();
}
- // Public static method to get the instance.
+ // Public property to get the instance of the class. (Singleton)
public static PowerShellExecutor Instance
{
- get {
- if (_instance is null)
- {
- _instance = new PowerShellExecutor();
- }
- return _instance;
- }
+ get { return _instance ??= new PowerShellExecutor(); }
}
public List Execute(string commandText)
{
List returnValues = new List();
- string filePath = "../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
-
- returnValues.Clear();
+ const string filePath = "../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
- // TODO: Use a MessageBox to show errors to the user.
+ //returnValues.Clear();
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
_powerShell.AddScript(commandText);
var results = _powerShell.Invoke();
-
-
-
if (_powerShell.HadErrors)
{
foreach (var error in _powerShell.Streams.Error)
{
- File.WriteAllText(filePath, "Error: " + error.ToString()); // For testing purposes only.
- returnValues.Add("Error: " + error.ToString());
+ File.WriteAllText(filePath, "Error: " + error); // For testing purposes only.
+ returnValues.Add("Error: " + error);
}
}
else
@@ -63,25 +51,28 @@ public List Execute(string commandText)
}
}
-
-
return returnValues;
}
- private void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string commandText)
+ private static void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string commandText)
{
+ const string exceptionMessageOne = "Command text cannot be null.";
+ const string exceptionMessageTwo = "Command text cannot be null or whitespace.";
+
if (commandText is null)
{
- throw new ArgumentNullException("Command text cannot be null.");
+ ShowError(exceptionMessageOne);
+ throw new ArgumentNullException(exceptionMessageOne);
}
if (string.IsNullOrWhiteSpace(commandText))
{
- throw new ArgumentException("Command text cannot be null or whitespace.");
+ ShowError(exceptionMessageTwo);
+ throw new ArgumentException(exceptionMessageTwo);
}
}
- private void ShowError(string message)
+ private static void ShowError(string message)
{
MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
From 0b81a664383f753dabed220af0e3b0e51bd43464 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Sun, 24 Dec 2023 15:24:59 -0800
Subject: [PATCH 12/19] Revert several previous changes and now uses .NET 6.0
---
.../PowerShellExecutorTest.cs | 2 +-
FAFB-PowerShell-Tool/Command.cs | 2 +-
.../FAFB-PowerShell-Tool.csproj | 6 ++--
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 34 ++++++++-----------
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 10 +-----
FAFB-PowerShell-Tool/Query.cs | 2 +-
6 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs b/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
index c392a9e..cd3ad73 100644
--- a/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
+++ b/FAFB-PowerShell-Tool.Tests/PowerShellExecutorTest.cs
@@ -3,7 +3,7 @@
[TestClass]
public class PowerShellExecutorTest
{
- private readonly PowerShellExecutor _powerShellExecutor = PowerShellExecutor.Instance;
+ private readonly PowerShellExecutor _powerShellExecutor = new();
[TestMethod]
public void ThrowArgumentNullExceptionWhenCommandTextIsNull()
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index 371a1de..69e0880 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -17,7 +17,7 @@ public class Command
public string CommandName { get; set; }
private string[] Parameters { get; set; }
private int ParameterCount { get; set; }
- private static readonly PowerShellExecutor PowerShellExecutor = PowerShellExecutor.Instance;
+ private static readonly PowerShellExecutor PowerShellExecutor = PowerShellExecutor;
public Command(string commandName, string[] parameters, int parameterCount)
{
diff --git a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj
index 3662b9b..92a05c0 100644
--- a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj
+++ b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj
@@ -2,7 +2,7 @@
WinExe
- net8.0-windows
+ net6.0-windows
x64
FAFB_PowerShell_Tool
enable
@@ -18,8 +18,8 @@
-
-
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 84ada0c..fd2467a 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -11,10 +11,6 @@ namespace FAFB_PowerShell_Tool;
public partial class MainWindow : Window
{
private string _command = null!;
- private string _fullCommandOutput = null!;
- private List _commandOutput = null!;
- private readonly PowerShellExecutor _powerShellExecutor = PowerShellExecutor.Instance;
-
public MainWindow()
{
@@ -57,25 +53,24 @@ private void CommandButton4(object sender, RoutedEventArgs e)
private void ExecutionButton(object sender, RoutedEventArgs e)
{
+ PowerShellExecutor powerShellExecutor = new();
+
try
{
- _commandOutput = _powerShellExecutor.Execute(_command);
- _fullCommandOutput = "";
+ List commandOutput = powerShellExecutor.Execute(_command);
+ string fullCommandOutput = "";
- foreach (var str in _commandOutput)
+ foreach (var str in commandOutput)
{
- _fullCommandOutput += str;
+ fullCommandOutput += str;
}
- MessageBox.Show(_fullCommandOutput, "Command Output");
+ MessageBox.Show(fullCommandOutput, "Command Output");
}
catch (Exception ex)
{
MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
}
-
- _commandOutput.Clear();
- _fullCommandOutput = "";
}
private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
@@ -136,10 +131,11 @@ private void RunRemoteCommand(String command)
// command is the command you want to run like get-aduser
String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}";
+ PowerShellExecutor powerShellExecutor = new();
try
{
- List commandOutput = _powerShellExecutor.Execute(invokeCommand);
+ List commandOutput = powerShellExecutor.Execute(invokeCommand);
string fullCommandOutput = "";
foreach (var str in commandOutput)
@@ -156,7 +152,7 @@ private void RunRemoteCommand(String command)
}
///
- /// Click Handler for the Save query button
+ /// Click Handler for the Save query button
///
///
///
@@ -166,8 +162,8 @@ private void SaveQuery_Click(object sender, RoutedEventArgs e)
try
{
// Get the Command
- Command? commadName = cmbCommandList.SelectedValue as Command;
- //string commandParameters = cmbParameters.Text;
+ Command? commandName = cmbCommandList.SelectedValue as Command;
+ // string commandParameters = cmbParameters.Text;
Button newButton = new Button();
newButton.Content = "Special Command";
@@ -180,20 +176,18 @@ private void SaveQuery_Click(object sender, RoutedEventArgs e)
{
Console.Write(ex);
}
-
}
private void ExecuteScriptEditorButton(object sender, RoutedEventArgs e)
{
-
string scriptEditorText = Script_Editor.Text;
+ PowerShellExecutor powerShellExecutor = new();
Trace.WriteLine(scriptEditorText);
-
try
{
- List commandOutput = _powerShellExecutor.Execute(scriptEditorText);
+ List commandOutput = powerShellExecutor.Execute(scriptEditorText);
string fullCommandOutput = "";
foreach (var str in commandOutput)
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index 219608a..f8b441a 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -6,10 +6,9 @@ namespace FAFB_PowerShell_Tool;
public class PowerShellExecutor
{
- private static PowerShellExecutor? _instance;
private readonly PowerShell _powerShell;
- private PowerShellExecutor()
+ public PowerShellExecutor()
{
_powerShell = PowerShell.Create();
_powerShell.AddScript("Import-Module ActiveDirectory;");
@@ -17,18 +16,11 @@ private PowerShellExecutor()
_powerShell.Commands.Clear();
}
- // Public property to get the instance of the class. (Singleton)
- public static PowerShellExecutor Instance
- {
- get { return _instance ??= new PowerShellExecutor(); }
- }
-
public List Execute(string commandText)
{
List returnValues = new List();
const string filePath = "../../../../FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.
- //returnValues.Clear();
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
_powerShell.AddScript(commandText);
diff --git a/FAFB-PowerShell-Tool/Query.cs b/FAFB-PowerShell-Tool/Query.cs
index 74dd019..526867c 100644
--- a/FAFB-PowerShell-Tool/Query.cs
+++ b/FAFB-PowerShell-Tool/Query.cs
@@ -3,7 +3,7 @@
namespace FAFB_PowerShell_Tool;
///
-/// This will contain a query that is built
+/// This will contain a query that is built
///
public class Query
{
From 43a8025d732f6a51fae484165d3c57e28bc81a18 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Sun, 24 Dec 2023 19:53:50 -0800
Subject: [PATCH 13/19] Custom message box class
---
FAFB-PowerShell-Tool/Command.cs | 6 ++--
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 18 +++++-----
FAFB-PowerShell-Tool/MessageBoxOutput.cs | 39 ++++++++++++++++++++++
FAFB-PowerShell-Tool/PowerShellExecutor.cs | 9 ++---
FAFB-PowerShell-Tool/Query.cs | 1 +
5 files changed, 55 insertions(+), 18 deletions(-)
create mode 100644 FAFB-PowerShell-Tool/MessageBoxOutput.cs
diff --git a/FAFB-PowerShell-Tool/Command.cs b/FAFB-PowerShell-Tool/Command.cs
index 69e0880..8acba74 100644
--- a/FAFB-PowerShell-Tool/Command.cs
+++ b/FAFB-PowerShell-Tool/Command.cs
@@ -94,12 +94,12 @@ public static string[] GetParametersArray(Command c)
{
fullCommandOutput += str;
}
-
- MessageBox.Show(fullCommandOutput, "Command Output");
+
+ MessageBoxOutput.ShowMessageBox(fullCommandOutput);
}
catch (Exception ex)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ MessageBoxOutput.ShowMessageBox(ex.Message, MessageBoxOutput.OutputType.InternalError);
}
return new string[1];
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index fd2467a..067bd41 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -65,22 +65,24 @@ private void ExecutionButton(object sender, RoutedEventArgs e)
fullCommandOutput += str;
}
- MessageBox.Show(fullCommandOutput, "Command Output");
+ MessageBoxOutput.ShowMessageBox(fullCommandOutput);
}
catch (Exception ex)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ MessageBoxOutput.ShowMessageBox(ex.Message, MessageBoxOutput.OutputType.InternalError);
}
}
private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
{
string hostName = System.Net.Dns.GetHostName();
- MessageBox.Show("System Host Name: " + hostName, "Command Output");
+ MessageBoxOutput.ShowMessageBox("System Host Name: " + hostName);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
- { }
+ {
+ // TODO: Add method body.
+ }
private void Button_Click(object sender, RoutedEventArgs e)
{
@@ -143,11 +145,11 @@ private void RunRemoteCommand(String command)
fullCommandOutput += str;
}
- MessageBox.Show(fullCommandOutput);
+ MessageBoxOutput.ShowMessageBox(fullCommandOutput);
}
catch (Exception ex)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message);
+ MessageBoxOutput.ShowMessageBox(ex.Message, MessageBoxOutput.OutputType.InternalError);
}
}
@@ -195,11 +197,11 @@ private void ExecuteScriptEditorButton(object sender, RoutedEventArgs e)
fullCommandOutput += str;
}
- MessageBox.Show(fullCommandOutput, "Command Output");
+ MessageBoxOutput.ShowMessageBox(fullCommandOutput);
}
catch (Exception ex)
{
- MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR");
+ MessageBoxOutput.ShowMessageBox(ex.Message, MessageBoxOutput.OutputType.InternalError);
}
}
}
diff --git a/FAFB-PowerShell-Tool/MessageBoxOutput.cs b/FAFB-PowerShell-Tool/MessageBoxOutput.cs
new file mode 100644
index 0000000..c693e71
--- /dev/null
+++ b/FAFB-PowerShell-Tool/MessageBoxOutput.cs
@@ -0,0 +1,39 @@
+using System.Windows;
+
+namespace FAFB_PowerShell_Tool;
+
+public static class MessageBoxOutput
+{
+ public enum OutputType
+ {
+ Error,
+ InternalError,
+ Information,
+ Warning,
+ Generic
+ }
+
+ public static void ShowMessageBox(string message, OutputType type = OutputType.Generic)
+ {
+ switch (type)
+ {
+ case OutputType.Error:
+ MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ break;
+ case OutputType.InternalError:
+ MessageBox.Show(message, "Internal Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ break;
+ case OutputType.Information:
+ MessageBox.Show(message, "Information", MessageBoxButton.OK, MessageBoxImage.Information);
+ break;
+ case OutputType.Warning:
+ MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ break;
+ case OutputType.Generic:
+ MessageBox.Show(message, "Command Output", MessageBoxButton.OK, MessageBoxImage.None);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(type), type, null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/FAFB-PowerShell-Tool/PowerShellExecutor.cs b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
index f8b441a..767e67f 100644
--- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs
+++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs
@@ -53,20 +53,15 @@ private static void ThrowExceptionIfCommandTextIsNullOrWhiteSpace(string command
if (commandText is null)
{
- ShowError(exceptionMessageOne);
+ MessageBoxOutput.ShowMessageBox(exceptionMessageOne, MessageBoxOutput.OutputType.InternalError);
throw new ArgumentNullException(exceptionMessageOne);
}
if (string.IsNullOrWhiteSpace(commandText))
{
- ShowError(exceptionMessageTwo);
+ MessageBoxOutput.ShowMessageBox(exceptionMessageTwo, MessageBoxOutput.OutputType.InternalError);
throw new ArgumentException(exceptionMessageTwo);
}
}
-
- private static void ShowError(string message)
- {
- MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- }
}
diff --git a/FAFB-PowerShell-Tool/Query.cs b/FAFB-PowerShell-Tool/Query.cs
index 526867c..fdb98a3 100644
--- a/FAFB-PowerShell-Tool/Query.cs
+++ b/FAFB-PowerShell-Tool/Query.cs
@@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
namespace FAFB_PowerShell_Tool;
+
///
/// This will contain a query that is built
///
From bafa135ca10d5c47c13b8ec54854f509b9455733 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:28:08 -0800
Subject: [PATCH 14/19] Update .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 8e74522..e0bed98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -485,3 +485,5 @@ $RECYCLE.BIN/
.idea/.idea.FAFB-PowerShell-Tool/.idea/workspace.xml
FAFB-PowerShell-Tool/FAFB-PowerShell-Tool-Output.txt
+
+.idea/.idea.FAFB-PowerShell-Tool/.idea/
From 401823ccfd595a70278f8ac4919579e164dd85f6 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:29:36 -0800
Subject: [PATCH 15/19] Completely rewrote MainWindow
---
FAFB-PowerShell-Tool/MainWindow.xaml | 125 ++++++++++++++----------
FAFB-PowerShell-Tool/MainWindow.xaml.cs | 100 +++++++++++--------
2 files changed, 130 insertions(+), 95 deletions(-)
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml
index e469ef4..50e1b81 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml
@@ -5,62 +5,83 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FAFB_PowerShell_Tool"
mc:Ignorable="d"
- Title="Active Directory Queries" Height="450" Width="800">
+ Title="MainWindow" Height="500" Width="800">
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
index 067bd41..36c9237 100644
--- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs
+++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs
@@ -12,6 +12,9 @@ public partial class MainWindow : Window
{
private string _command = null!;
+ ///
+ ///
+ ///
public MainWindow()
{
InitializeComponent();
@@ -19,41 +22,56 @@ public MainWindow()
// This is for the ComboBox containing the commands.
try
{
- // Get the command Combo Box to modify
- ComboBox cmb = cmbCommandList;
+ // Get the command Combo Box to modify.
+ ComboBox comboBoxCommandList = ComboBoxCommandList;
ObservableCollection list = Command.ReadFileCommandList();
- cmb.ItemsSource = list;
- cmb.DisplayMemberPath = "CommandName";
+ comboBoxCommandList.ItemsSource = list;
+ comboBoxCommandList.DisplayMemberPath = "CommandName";
}
catch (Exception ex)
{
- Console.Write(ex);
+ Console.WriteLine(ex);
}
}
-
- private void CommandButton1(object sender, RoutedEventArgs e)
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void MSampleOne(object sender, RoutedEventArgs e)
{
_command = "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String";
}
- private void CommandButton2(object sender, RoutedEventArgs e)
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void MSampleTwo(object sender, RoutedEventArgs e)
{
_command = "Get-Process | Out-String";
}
- private void CommandButton3(object sender, RoutedEventArgs e)
- {
- _command = "Get-ChildItem -Path $env:USERPROFILE";
- }
-
- private void CommandButton4(object sender, RoutedEventArgs e)
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void MSampleThree(object sender, RoutedEventArgs e)
{
_command = "Get-ChildItem -Path $env:USERPROFILE | Out-String";
}
- private void ExecutionButton(object sender, RoutedEventArgs e)
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void MExecutionButton(object sender, RoutedEventArgs e)
{
- PowerShellExecutor powerShellExecutor = new();
+ PowerShellExecutor powerShellExecutor = new PowerShellExecutor();
try
{
@@ -73,27 +91,24 @@ private void ExecutionButton(object sender, RoutedEventArgs e)
}
}
- private void ExecuteGenericCommand(object sender, RoutedEventArgs e)
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void MExecuteGenericCommand(object sender, RoutedEventArgs e)
{
string hostName = System.Net.Dns.GetHostName();
MessageBoxOutput.ShowMessageBox("System Host Name: " + hostName);
}
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- // TODO: Add method body.
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- // TODO: Add method body.
- }
-
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ // TODO: Review this method, as it has unused variables...
+ private void MComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
- // Get the combox that we are working with
+ // Get the ComboBox that was changed.
ComboBox? cmb = sender as ComboBox;
- // Get the command that is selected which is just an object so we have to convert to Command
+
+ // Get the selected command.
try
{
Command? selectedCommand = cmb.SelectedValue as Command;
@@ -105,15 +120,16 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs
{
Trace.WriteLine(ex);
}
- // Debug
}
- private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ // TODO: Figure out the purpose of this method.
+ private void MTextBoxTextChanged(object sender, TextChangedEventArgs e)
{
// TODO: Add method body.
}
- private void Button_Click_1(object sender, RoutedEventArgs e)
+ // TODO: Review this method, as it has unused variables and is not used...
+ private void MButtonClickOne(object sender, RoutedEventArgs e)
{
String computerName = "";
@@ -128,6 +144,7 @@ private void Button_Click_1(object sender, RoutedEventArgs e)
*/
}
+ // TODO: Review this method, as it is not used...
private void RunRemoteCommand(String command)
{
// command is the command you want to run like get-aduser
@@ -153,18 +170,14 @@ private void RunRemoteCommand(String command)
}
}
- ///
- /// Click Handler for the Save query button
- ///
- ///
- ///
- private void SaveQuery_Click(object sender, RoutedEventArgs e)
+ // TODO: Review this method, as it has unused variables...
+ private void MSaveQueryButton(object sender, RoutedEventArgs e)
{
// Try to get the content within the drop downs
try
{
// Get the Command
- Command? commandName = cmbCommandList.SelectedValue as Command;
+ Command? commandName = ComboBoxCommandList.SelectedValue as Command;
// string commandParameters = cmbParameters.Text;
Button newButton = new Button();
@@ -172,7 +185,7 @@ private void SaveQuery_Click(object sender, RoutedEventArgs e)
newButton.Width = 140;
newButton.Height = 48;
- Left_Side_Query_Bar.Children.Add(newButton);
+ LeftSideQueryGrid.Children.Add(newButton);
}
catch (Exception ex)
{
@@ -180,9 +193,10 @@ private void SaveQuery_Click(object sender, RoutedEventArgs e)
}
}
+ // TODO: Review this method, as it is not used...
private void ExecuteScriptEditorButton(object sender, RoutedEventArgs e)
{
- string scriptEditorText = Script_Editor.Text;
+ string scriptEditorText = ScriptEditorTextBox.Text;
PowerShellExecutor powerShellExecutor = new();
Trace.WriteLine(scriptEditorText);
@@ -204,4 +218,4 @@ private void ExecuteScriptEditorButton(object sender, RoutedEventArgs e)
MessageBoxOutput.ShowMessageBox(ex.Message, MessageBoxOutput.OutputType.InternalError);
}
}
-}
+}
\ No newline at end of file
From a2d6c4fceac29857e00c48d24703c7b8b7861233 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:39:59 -0800
Subject: [PATCH 16/19] Update build-test-ci.yml
---
.github/workflows/build-test-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml
index 6694e02..0799721 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -25,7 +25,7 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '6.0.x'
- name: Dotnet Build & Publish
run: |
From 6afcdd13ee57a62a6d95807a5e5ba727744461db Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:40:20 -0800
Subject: [PATCH 17/19] Update release-ci.yml
---
.github/workflows/release-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml
index 295c476..60203ee 100644
--- a/.github/workflows/release-ci.yml
+++ b/.github/workflows/release-ci.yml
@@ -25,7 +25,7 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '6.0.x'
- name: Dotnet Build & Publish
run: |
From 141bc06355cce3e57019592f71264e7ad3f9cf67 Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:43:55 -0800
Subject: [PATCH 18/19] Update build-test-ci.yml
---
.github/workflows/build-test-ci.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml
index 0799721..8e9e356 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -25,13 +25,13 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '8.0.x'
- name: Dotnet Build & Publish
run: |
dotnet restore
- dotnet build $env:Project_File -c Debug -f net8.0-windows -r win-${{ matrix.targetplatform }} --no-restore
- dotnet publish $env:Project_File -c Debug -f net8.0-windows -r win-${{ matrix.targetplatform }} -o ./publish/FAFB_PowerShell_Tool_${{ matrix.targetplatform }} --no-restore
+ dotnet build $env:Project_File -c Debug -f net6.0-windows -r win-${{ matrix.targetplatform }} --no-restore
+ dotnet publish $env:Project_File -c Debug -f net6.0-windows -r win-${{ matrix.targetplatform }} -o ./publish/FAFB_PowerShell_Tool_${{ matrix.targetplatform }} --no-restore
#- name: Upload Artifact
# uses: actions/upload-artifact@v3
From be2c9ab566e7831f4f6f86fdc8ecb67affac1ced Mon Sep 17 00:00:00 2001
From: Hunter T
Date: Wed, 27 Dec 2023 10:44:14 -0800
Subject: [PATCH 19/19] Update release-ci.yml
---
.github/workflows/release-ci.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml
index 60203ee..da144b8 100644
--- a/.github/workflows/release-ci.yml
+++ b/.github/workflows/release-ci.yml
@@ -25,13 +25,13 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '6.0.x'
+ dotnet-version: '8.0.x'
- name: Dotnet Build & Publish
run: |
dotnet restore
- dotnet build $env:Project_File -c Release -f net8.0-windows -r win-${{ matrix.targetplatform }} --no-restore
- dotnet publish $env:Project_File -c Release -f net8.0-windows -r win-${{ matrix.targetplatform }} -o ./publish/FAFB_PowerShell_Tool_${{ matrix.targetplatform }} --no-restore
+ dotnet build $env:Project_File -c Release -f net6.0-windows -r win-${{ matrix.targetplatform }} --no-restore
+ dotnet publish $env:Project_File -c Release -f net6.0-windows -r win-${{ matrix.targetplatform }} -o ./publish/FAFB_PowerShell_Tool_${{ matrix.targetplatform }} --no-restore
- name: Zip Release Files
run: Compress-Archive -Path .\publish\FAFB_PowerShell_Tool_${{ matrix.targetplatform }} -DestinationPath .\FAFB_PowerShell_Tool_${{ matrix.targetplatform }}.zip