diff --git a/.github/workflows/build-test-ci.yml b/.github/workflows/build-test-ci.yml new file mode 100644 index 0000000..6694e02 --- /dev/null +++ b/.github/workflows/build-test-ci.yml @@ -0,0 +1,40 @@ +name: Built Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + strategy: + matrix: + targetplatform: [x64] + #targetplatform: [x86, x64] + + runs-on: windows-latest + + env: + Project_File: FAFB-PowerShell-Tool\FAFB-PowerShell-Tool.csproj + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install .NET Core + uses: actions/setup-dotnet@v3 + with: + 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 + + #- name: Upload Artifact + # uses: actions/upload-artifact@v3 + # with: + # name: FAFB_PowerShell_Tool_${{ matrix.targetplatform }} + # path: ./publish/FAFB_PowerShell_Tool_${{ matrix.targetplatform }} diff --git a/.github/workflows/dotnet-desktop-ci.yml b/.github/workflows/dotnet-desktop-ci.yml deleted file mode 100644 index e57b58a..0000000 --- a/.github/workflows/dotnet-desktop-ci.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: .NET Core Desktop .EXE (CI) - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - - build: - - strategy: - matrix: - targetplatform: [x86, x64] - - runs-on: windows-latest - - env: - Project_File: FAFB-PowerShell-Tool\FAFB-PowerShell-Tool.csproj - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install .NET Core - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.x' - - - name: Build - run: dotnet build $env:Project_File -c Release -f net8.0-windows -r win-${{ matrix.targetplatform }} - - - name: Publish Artifact - run: dotnet publish -c Release -f net8.0-windows -r win-${{ matrix.targetplatform }} -o ./FAFB_PowerShell_Tool_${{ matrix.targetplatform }} --self-contained true -p:PublishSingleFile=false -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=embedded - - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: FAFB_PowerShell_Tool_${{ matrix.targetplatform }} - path: FAFB_PowerShell_Tool_${{ matrix.targetplatform }} diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml new file mode 100644 index 0000000..295c476 --- /dev/null +++ b/.github/workflows/release-ci.yml @@ -0,0 +1,45 @@ +name: Create and Upload Release + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + build: + strategy: + matrix: + targetplatform: [x64] + #targetplatform: [x86, x64] + + runs-on: windows-latest + + env: + Project_File: FAFB-PowerShell-Tool\FAFB-PowerShell-Tool.csproj + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install .NET Core + uses: actions/setup-dotnet@v3 + with: + 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 + + - name: Zip Release Files + run: Compress-Archive -Path .\publish\FAFB_PowerShell_Tool_${{ matrix.targetplatform }} -DestinationPath .\FAFB_PowerShell_Tool_${{ matrix.targetplatform }}.zip + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + files: FAFB_PowerShell_Tool_${{ matrix.targetplatform }}.zip + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/FAFB-PowerShell-Tool.Tests/FAFB-PowerShell-Tool.Tests.csproj b/FAFB-PowerShell-Tool.Tests/FAFB-PowerShell-Tool.Tests.csproj index a3d96d5..e2f6c4f 100644 --- a/FAFB-PowerShell-Tool.Tests/FAFB-PowerShell-Tool.Tests.csproj +++ b/FAFB-PowerShell-Tool.Tests/FAFB-PowerShell-Tool.Tests.csproj @@ -1,7 +1,8 @@ - + net8.0-windows + x64 FAFB_PowerShell_Tool.Tests enable enable diff --git a/FAFB-PowerShell-Tool.sln b/FAFB-PowerShell-Tool.sln index 411f4fa..fe18e1a 100644 --- a/FAFB-PowerShell-Tool.sln +++ b/FAFB-PowerShell-Tool.sln @@ -26,18 +26,18 @@ Global {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|ARM.Build.0 = Debug|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|ARM64.ActiveCfg = Debug|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|ARM64.Build.0 = Debug|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x64.ActiveCfg = Debug|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x64.Build.0 = Debug|Any CPU + {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x64.ActiveCfg = Debug|x64 + {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x64.Build.0 = Debug|x64 {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x86.ActiveCfg = Debug|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Debug|x86.Build.0 = Debug|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|Any CPU.ActiveCfg = Release|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|Any CPU.Build.0 = Release|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM.ActiveCfg = Release|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM.Build.0 = Release|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM64.ActiveCfg = Release|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM64.Build.0 = Release|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x64.ActiveCfg = Release|Any CPU - {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x64.Build.0 = Release|Any CPU + {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM64.ActiveCfg = Release|x64 + {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|ARM64.Build.0 = Release|x64 + {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x64.ActiveCfg = Release|x64 + {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x64.Build.0 = Release|x64 {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x86.ActiveCfg = Release|Any CPU {C6E51308-E9E0-4738-9D5A-49841912633B}.Release|x86.Build.0 = Release|Any CPU {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -50,8 +50,8 @@ Global {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Debug|x64.Build.0 = Debug|Any CPU {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Debug|x86.ActiveCfg = Debug|Any CPU {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Debug|x86.Build.0 = Debug|Any CPU - {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|Any CPU.Build.0 = Release|Any CPU + {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|Any CPU.ActiveCfg = Release|x86 + {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|Any CPU.Build.0 = Release|x86 {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|ARM.ActiveCfg = Release|Any CPU {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|ARM.Build.0 = Release|Any CPU {E93739C2-C7BC-4F69-BEA2-C5F30548EA8C}.Release|ARM64.ActiveCfg = Release|Any CPU diff --git a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj index 566eb29..3662b9b 100644 --- a/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj +++ b/FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj @@ -3,6 +3,7 @@ WinExe net8.0-windows + x64 FAFB_PowerShell_Tool enable enable diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml b/FAFB-PowerShell-Tool/MainWindow.xaml index 2c23aa0..a969c2c 100644 --- a/FAFB-PowerShell-Tool/MainWindow.xaml +++ b/FAFB-PowerShell-Tool/MainWindow.xaml @@ -6,15 +6,37 @@ xmlns:local="clr-namespace:FAFB_PowerShell_Tool" mc:Ignorable="d" Title="Active Directory Queries" Height="450" Width="800"> - - - + + diff --git a/FAFB-PowerShell-Tool/MainWindow.xaml.cs b/FAFB-PowerShell-Tool/MainWindow.xaml.cs index dc2b86b..4020195 100644 --- a/FAFB-PowerShell-Tool/MainWindow.xaml.cs +++ b/FAFB-PowerShell-Tool/MainWindow.xaml.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Windows; +using System.Windows.Controls; namespace FAFB_PowerShell_Tool { @@ -17,22 +18,22 @@ public MainWindow() private void CommandButton1(object sender, RoutedEventArgs e) { - command = "Get-ADUser -filter * -Properties * | out-gridvie"; + command = "Get-ADUser -filter * -Properties * | Select name, department, title | Out-String -Width 4096"; } private void CommandButton2(object sender, RoutedEventArgs e) { - command = "Get-Process | Out-String -Width 4096"; + command = "Get-Process"; } private void CommandButton3(object sender, RoutedEventArgs e) { - command = "Get-ChildItem -Path $env:USERPROFILE | Out-String -Width 4096"; + command = "Get-Process | Out-String -Width 4096"; } private void CommandButton4(object sender, RoutedEventArgs e) { - command = "New-Item -Path $env:USERPROFILE\\myFile.txt -ItemType File"; + command = "Get-ChildItem -Path $env:USERPROFILE | Out-String -Width 4096"; } private void ExecutionButton(object sender, RoutedEventArgs e) @@ -48,18 +49,71 @@ private void ExecutionButton(object sender, RoutedEventArgs e) fullCommandOutput += str; } - MessageBox.Show(fullCommandOutput); + MessageBox.Show(fullCommandOutput, "Command Output"); } catch (Exception ex) { - MessageBox.Show("INTERNAL ERROR: " + ex.Message); + MessageBox.Show("INTERNAL ERROR: " + ex.Message, "ERROR"); } } private void ExecuteGenericCommand(object sender, RoutedEventArgs e) { string hostName = System.Net.Dns.GetHostName(); - MessageBox.Show("System Host Name: " + hostName); + MessageBox.Show("System Host Name: " + hostName, "Command Output"); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + // TODO: Add method body. + } + + private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) + { + // TODO: Add method body. + } + + private void Button_Click_1(object sender, RoutedEventArgs e) + { + String computerName = ""; + + String startRemoteSession = "$sessionAD = New-PSSession -ComputerName" + computerName; + + /* + TextBox tbx = new TextBox(); + + tbx.Visibility = Visibility.Visible; + //tbx.ClearValue + tbx. + */ + } + + + private void RunRemoteCommand(String command) { + + //command is the command you want to run like get-aduser + + String invokeCommand = "Invoke-Command -Session $sessionAD -ScriptBlock{" + command + "}" ; + + + try + { + List commandOutput = PowerShellExecutor.Execute(invokeCommand); + string fullCommandOutput = ""; + + + foreach (var str in commandOutput) + { + fullCommandOutput += str; + } + + MessageBox.Show(fullCommandOutput); + } + catch (Exception ex) + { + 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 139a358..efc7749 100644 --- a/FAFB-PowerShell-Tool/PowerShellExecutor.cs +++ b/FAFB-PowerShell-Tool/PowerShellExecutor.cs @@ -1,4 +1,5 @@ -using System.Management.Automation; +using System.IO; +using System.Management.Automation; using System.Windows; namespace FAFB_PowerShell_Tool; @@ -10,6 +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. // TODO: Use a MessageBox to show errors to the user. ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText); @@ -21,6 +23,7 @@ public static List Execute(string commandText) { foreach (var error in ps.Streams.Error) { + File.WriteAllText(filePath, "Error: " + error.ToString()); // For testing purposes only. returnValues.Add("Error: " + error.ToString()); } } @@ -28,6 +31,7 @@ public static List Execute(string commandText) { foreach (var result in results) { + File.WriteAllText(filePath, result.ToString()); // For testing purposes only. returnValues.Add(result.ToString()); } } diff --git a/README.md b/README.md index 8708856..9794177 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # FAFB-PowerShell-Tool -[ADD DESCRIPTION OF PROJECT] +[![Project Tracker](https://img.shields.io/badge/repo%20status-Project%20Tracker-lightgrey)](https://randomserver.xyz/project-tracker.html) +![Platform](https://img.shields.io/badge/platform-Windows-lightgrey) +[![Style Guide](https://img.shields.io/badge/code%20style-Style%20Guide-blueviolet)](https://github.com/StrangeRanger) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ce2ddca07a934a5f85e8061e295f3324)](https://app.codacy.com/gh/StrangeRanger/FAFB-PowerShell-Tool/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) + +FAFB PowerShell Tool is a Windows GUI for creating, saving, and executing one or more PowerShell commands, against a Local Active Directory. + +## Getting Started + +### Installing + +FAFB PowerShell Tool does not require to be installed. Simply go to [the lastest releases tab](https://github.com/StrangeRanger/FAFB-PowerShell-Tool/releases), and download the version for you'r appropriate architecture... + +## Usage + +... + +## Supported Operating Systems + +...