Giter Site home page Giter Site logo

abeeinspace / powerrun Goto Github PK

View Code? Open in Web Editor NEW

This project forked from justind-dev/powerrun

0.0 0.0 0.0 142 KB

A simple powershell program which generates a list of available powershell scripts in a directory to easily run them.

License: Creative Commons Zero v1.0 Universal

PowerShell 100.00%

powerrun's Introduction

PowerRun Powershell Script Runner

Summary

PowerRun provides a dynamic menu system for executing PowerShell scripts within a specified directory and its subdirectories. It's designed for ease of use, allowing users to add, execute, and manage PowerShell scripts through a simple numbered menu system. This tool is useful for organizing and running scripts for various automation tasks, testing, or administrative purposes without directly consuming resources from the local machine.

PreRequisites

  • PowerShell 5.1 or higher is required.
  • Scripts intended for use with PowerRun should be located in the script's directory or its subdirectories.
  • Each script must include specific comments at the beginning to be properly listed in the PowerRun menu: DisplayText, Description, and ConfiguredParameters.

Contents

The PowerRun system includes the main PowerRun-Menu.ps1 script, which scans for PowerShell .ps1 files in its directory and subdirectories, displaying them in a dynamic menu for execution. It supports:

  • Dynamically numbered menu entries for found scripts.
  • Description toggle for scripts.
  • Refresh functionality to update the script list based on the directory contents.
  • Help section detailing script formatting requirements.

Example Scripts

  • ShowDateAndDaysLeft.ps1 - Displays the current date and the number of days left in the current year.
  • FileSummary.ps1 - Provides a summary of lines, words, and characters in a specified file.

How-To

Installing PowerRun

Place PowerRun-Menu.ps1 in a directory where you intend to run or manage your PowerShell scripts.

Adding New Scripts/Folders

Simply add .ps1 files in the PowerRun directory or any of its subdirectories. Ensure the scripts include the required comments for DisplayText, Description, and ConfiguredParameters at the beginning.

Running PowerRun

  • Open a PowerShell prompt and navigate to the directory containing PowerRun-Menu.ps1.
  • Execute .\PowerRun-Menu.ps1.
  • Use the numbered menu to select a script to run, toggle descriptions, refresh the script list, view help information, or exit.

Script Formatting

To ensure a script is properly listed in PowerRun's menu, format the first three lines of your .ps1 file as follows:

# DisplayText: "Your Script Name"
# Description: "A brief description of what your script does."
# ConfiguredParameters: "Any required parameters, formatted as a single string."

Refreshing Script List

Select the 'Refresh Scripts' option from the menu to update the list based on the current directory contents.

Understanding the ConfiguredParameters

The ConfiguredParameters comment allows you to specify parameters that PowerRun will pass when executing the script. This is useful for scripts that require input values, such as file paths or configuration options. Format this comment with the exact string you'd intend to pass to the PowerShell script directly.

Setting the Working Directory

To ensure scripts run with the correct relative path context, You can set the working directory to the location of each script with in your custom scripts themselves. This is particularly useful for scripts that interact with other files or scripts in the same directory. For example, if a script accesses a file named interesting-file.txt located in the same directory, it can simply refer to it as .\interesting-file.txt. This behavior is achieved with the following line at the beginning of each script:

Set-Location -Path $PSScriptRoot

Screenshots

Main Menu Example

alt text

Descriptions enabled:

alt text

Running A Script

alt text

powerrun's People

Contributors

justind-dev avatar abeeinspace avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.