Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from StrangeRanger/dev
Browse files Browse the repository at this point in the history
Several CI/Workflow Changes + More...
  • Loading branch information
StrangeRanger authored Dec 2, 2023
2 parents f5cb920 + a148d6e commit c97256b
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 67 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-test-ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
41 changes: 0 additions & 41 deletions .github/workflows/dotnet-desktop-ci.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 2 additions & 1 deletion FAFB-PowerShell-Tool.Tests/FAFB-PowerShell-Tool.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RootNamespace>FAFB_PowerShell_Tool.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
16 changes: 8 additions & 8 deletions FAFB-PowerShell-Tool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RootNamespace>FAFB_PowerShell_Tool</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
38 changes: 30 additions & 8 deletions FAFB-PowerShell-Tool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,37 @@
xmlns:local="clr-namespace:FAFB_PowerShell_Tool"
mc:Ignorable="d"
Title="Active Directory Queries" Height="450" Width="800">
<Grid>
<Border BorderBrush="Black" BorderThickness="1"/>
<Button x:Name="Command_Button_1" Content="Command 1" HorizontalAlignment="Left" Margin="63,110,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton1"/>
<Button x:Name="Command_Button_2" Content="Command 2" HorizontalAlignment="Left" Margin="230,110,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton2"/>
<Button x:Name="Command_Button_3" Content="Command 3" HorizontalAlignment="Left" Margin="400,110,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton3"/>
<Button x:Name="Command_Button_4" Content="Command 4" HorizontalAlignment="Left" Margin="568,110,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton4"/>
<Button x:Name="Execute_Button" Content="Execute" HorizontalAlignment="Left" Margin="318,217,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="ExecutionButton"/>
<Button x:Name="Execute_Generic_Command" Content="Execute Non-PowerShell Command" HorizontalAlignment="Left" Margin="133,320,0,0" VerticalAlignment="Top" Height="58" Width="542" Click="ExecuteGenericCommand"/>

<Grid Background="White">
<Grid Margin="155,64,0,0" Background="White">
<Button x:Name="Execute_Button" Content="Execute" HorizontalAlignment="Left" Margin="408,87,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="ExecutionButton"/>
<Button x:Name="Execute_Generic_Command" Content="Execute Non-PowerShell Command" HorizontalAlignment="Left" Margin="408,28,0,0" VerticalAlignment="Top" Height="43" Width="198" Click="ExecuteGenericCommand"/>
<Border BorderThickness="1" BorderBrush="Black" RenderTransformOrigin="0.516,0.595">

</Border>
</Grid>
<Grid x:Name="Left_Side_Query_Bar" HorizontalAlignment="Left" Height="370" Margin="0,64,0,0" VerticalAlignment="Top" Width="155">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF616161" Offset="0"/>
<GradientStop Color="#FF5F5F5F" Offset="0.363"/>
<GradientStop Color="#FF898989" Offset="0.737"/>
</LinearGradientBrush>
</Grid.Background>
<Button x:Name="Command_Button_1" Content="Command 1" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton1"/>
<Button x:Name="Command_Button_2" Content="Command 2" HorizontalAlignment="Left" Margin="0,59,0,0" VerticalAlignment="Top" Height="48" Width="140" Click="CommandButton2"/>
<Button x:Name="Command_Button_3" Content="Command 3" HorizontalAlignment="Left" Margin="0,107,0,0" VerticalAlignment="Top" Height="49" Width="140" Click="CommandButton3"/>
<Button x:Name="Command_Button_4" Content="Command 4" HorizontalAlignment="Left" Margin="0,156,0,0" VerticalAlignment="Top" Height="48" Width="140" Click="CommandButton4"/>
</Grid>

<Grid x:Name="Header_Bar" HorizontalAlignment="Center" Height="64" VerticalAlignment="Top" Width="800">
<TextBlock x:Name="Title" HorizontalAlignment="Left" Margin="40,0,0,0" TextWrapping="Wrap" Text="Active Directory Queries" VerticalAlignment="Center" FontSize="18" Width="220" FontWeight="Bold"/>
<Button Content="Home" HorizontalAlignment="Left" Margin="647,28,0,0" VerticalAlignment="Top" Click="Button_Click"/>

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.

Check warning on line 34 in FAFB-PowerShell-Tool/MainWindow.xaml

View workflow job for this annotation

GitHub Actions / build (x64)

'MainWindow.Title' hides inherited member 'Window.Title'. Use the new keyword if hiding was intended.
<Button HorizontalAlignment="Left" Margin="545,24,0,0" VerticalAlignment="Top">
<Button Content="Connect to Ad" Click="Button_Click_1"/>
</Button>

</Grid>

</Grid>
</Window>
68 changes: 61 additions & 7 deletions FAFB-PowerShell-Tool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace FAFB_PowerShell_Tool
{
Expand All @@ -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)
Expand All @@ -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<string> 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);
}

}
}
}
6 changes: 5 additions & 1 deletion FAFB-PowerShell-Tool/PowerShellExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Management.Automation;
using System.IO;
using System.Management.Automation;
using System.Windows;

namespace FAFB_PowerShell_Tool;
Expand All @@ -10,6 +11,7 @@ public static List<string> Execute(string commandText)
{
using PowerShell ps = PowerShell.Create();
List<string> returnValues = new List<string>();
string filePath = @"C:\FAFB-PowerShell-Tool-Output.txt"; // For testing purposes only.

// TODO: Use a MessageBox to show errors to the user.
ThrowExceptionIfCommandTextIsNullOrWhiteSpace(commandText);
Expand All @@ -21,13 +23,15 @@ public static List<string> 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());
}
}
else
{
foreach (var result in results)
{
File.WriteAllText(filePath, result.ToString()); // For testing purposes only.
returnValues.Add(result.ToString());
}
}
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

...

0 comments on commit c97256b

Please sign in to comment.