Hangfire.PowerShellExecutor 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Hangfire.PowerShellExecutor --version 1.0.0                
NuGet\Install-Package Hangfire.PowerShellExecutor -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hangfire.PowerShellExecutor" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hangfire.PowerShellExecutor --version 1.0.0                
#r "nuget: Hangfire.PowerShellExecutor, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hangfire.PowerShellExecutor as a Cake Addin
#addin nuget:?package=Hangfire.PowerShellExecutor&version=1.0.0

// Install Hangfire.PowerShellExecutor as a Cake Tool
#tool nuget:?package=Hangfire.PowerShellExecutor&version=1.0.0                

Hangfire.PowerShellExecutor

NuGet NuGet MIT License

A plugin for Hangfire that allows you to easily launch your powershell scripts.

Read about hangfire here: https://github.com/HangfireIO/Hangfire here: http://hangfire.io

Features

  • Noob Friendly: Allow to easily launch your powershell scripts.
  • 100% Safe: no Hangfire-managed data (e.g. jobs, states) is ever updated, hence there's no risk to corrupt it.
  • (blah-blah-blah)

Setup

Install NuGet package, and configure the console in .NET Core's Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddHangfire(config =>
    {
        config.UseSqlServerStorage("connectionSting");
        config.UseConsole();
    });
}

Otherwise,

GlobalConfiguration.Configuration
    .UseSqlServerStorage("connectionSting")
    .UseConsole();

NOTE: If you have Dashboard and Server running separately, you'll need to call UseConsole() on both.

Example

using Hangfire.Console;
using Hangfire.Server;
using System.Threading;
using System.Threading.Tasks;

namespace Hangfire.PowerShellExecutor.Jobs
{
    public class PowerShellJob
    {
        public async Task ExecuteAsync(PerformContext context, CancellationToken cancellationToken)
        {
            context.SetTextColor(ConsoleTextColor.Green);
            context.WriteLine("*****************************************************************");
            context.WriteLine("Starting: Hangfire Script");
            context.WriteLine("*****************************************************************");
            context.ResetTextColor();

            // Create an instance of the configuration
            var psConfig = new PsExecutorConfig();
            // Define the execution policy
            psConfig.SetExecutionPolicy(ExecutionPolicy.Bypass);
            // Add parameters
            psConfig.AddSecret("PE_SUPERSECRET", "P@ssw0rd");
            psConfig.AddParameter("PE_PARAMETER01", "parameter01");
            psConfig.AddParameter("PE_PARAMETER02", "parameter02");
            // Set the location of the powershell script
            psConfig.SetScriptPath(@"D:\Scripts\Get-ChildItem.ps1");
            // Execute the powershell script
            context.StartProcess(psConfig, cancellationToken);

            context.WriteLine("");
            context.SetTextColor(ConsoleTextColor.Green);
            context.WriteLine("*****************************************************************");
            context.WriteLine("Finishing: Hangfire Script");
            context.WriteLine("*****************************************************************");
        }
    }
}

License

Authored by: Thomas ILLIET

This project is under MIT license. You can obtain the license copy here.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.7 2,024 12/14/2021
1.1.6 362 11/10/2021
1.1.5 354 11/4/2021
1.1.4 316 11/1/2021
1.1.3 337 9/2/2021
1.1.2 328 9/1/2021
1.1.1 382 7/11/2021
1.1.0 356 7/6/2021
1.0.1 404 7/4/2021
1.0.0 488 7/3/2021