Giter VIP home page Giter VIP logo

powershell-forms's Introduction

powershell-forms

Collect user inputs using modal pop-up forms. The forms are generated dynamically using a single line of code. Excellent option if you want to make your PowerShell script more user-friendly.

You can use powershell-forms with any sorts of arrays or objects. You can ask a user to select a file from an array of files or maybe a SharePoint List item from an array of items.

Getting started

  • Download PS-Forms.ps1 file
  • Load the PowerShell-forms functions by running . .\PS-Forms.ps1
  • Try out your first dialog by running Get-FormStringInput "Enter new file name"

List of all functions

Function Description
Get-FormArrayItem Select one item from an array of items
Get-FormArrayItems Select multiple items from an array of items
Get-FormBinaryAnswer Ask a Yes/No question and get value as a $true or $false
Get-FormStringInput Ask user to enter a string
Get-FormItemProperties Ask a user to fill out all properties of an object

Get-FormArrayItem

Select one item from an array of items:

$selectedItem = Get-FormArrayItem (Get-ChildItem) -ControlType RadioButtons

Get-FormArrayItems

Select several items from an array of items:

$selectedItem = Get-FormArrayItems (Get-ChildItem) 

Get-FormBinaryAnswer

Ask a Yes/No question and get value as a $true or $false:

$Delete = Get-FormBinaryAnswer "Delete file?"

Get-FormStringInput

Ask user to enter a string:

$newFileName = Get-FormStringInput "Enter new file name" -defaultValue "My new file"

Get-FormItemProperties

Ask a user to fill out all properties of an object:

# -------------------------------------------------------------------------------
# Prepare the list of inputs that user needs to populate using an interactive form    
# -------------------------------------------------------------------------------
$preDeployInputs = @{
    suffix                       = ""
    SPSiteUrl                    = "https://ENTER_SHAREPOINT_SITE.sharepoint.com"
    TimeZone                     = "Central Standard Time"
    sendGridRegistrationEmail    = "ENTER_VALID_EMAIL_ADDRESS"
    sendGridRegistrationPassword = $sendGridPassword
    sendGridRegistrationCompany  = "Contoso & Tailspin"
    sendGridRegistrationWebsite  = "https://www.company.com"
    fromEmail                    = "[email protected]"
}

$preDeployInputs = Get-FormItemProperties -item $preDeployInputs -dialogTitle "Fill these required fields"

Real-World Examples

Azure Cli + powershell-forms

Display a form with the list of Azure Locations where "Canada Central" is selected by default.

$locations = az account list-locations | ConvertFrom-Json
$location = Get-FormArrayItem -items $locations -key "displayName" -dialogTitle "Choose location" -defaultValue "Canada Central"

SharePoint Online

Select one list from an array of lists:

$lists = Get-PnPList
$list = Get-FormArrayItem $lists -key "Title"

Write-Host You selected list: $list.Title

powershell-forms's People

Contributors

zerg00s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.