Hello World

PowerShell - Hello World +

The Hello World + PowerShell script severs no Administrative or practical purpose. What it does demonstrate is how easy PowerShell scripts can be enhanced to add web based user interaction, with NO web programming experience. 

Type anything then TAB or click off the control to see the response; note the dynamic control added during runtime.


What to say to the World

<#
.SYNOPSIS
    Hello World Example - AdPowerForm
.DESCRIPTION
    Supports all the features of original HelloWorld (if nessesary):
    Passes in a parameter that contains a text string. If no value is passed
    in then prompt for text. If Value is "Hello" print "Good"
    else print "Bad". Keep prompting until a value is entered.
    
    A few extra ATPowerForm line: 
    Web page prompts for text string. If Value is "Hello" a new readonly
    textbox is dynamically added displaying "Good" else it displays "Bad". If
    empty is entered then the readonly textbox is dynalically removed. All
    done using events.
.NOTES
    Script Name:    HelloWorld_Plus.ps1
    Version:        1.0
    Author:         Nudigital Solutions
    Creation Date:  05/01/2014
    Purpose/Change: Initial script development
#>
param(
    [string]$pfCMD = "",
    [int]$pfField,
    [hashtable]$pfFields = @{},
    [hashtable]$pfDetails = @{},
    [hashtable]$pfGlobals = @{},
    [string]$pfModPath = $Env:ATPowerForm,
    [string]$Value = ""            # Only required for manual execution
)

################################
# Load ATPowerForm Interfaces
$pfScriptPath = $MyInvocation.MyCommand.Path;
. $pfModPath\ATPowerForm.ps1;
################################

<#
.SYNOPSIS
    Optional method to create ATPowerForm control definitions for rendoring in the UI 

#>
function pfPaint
{
    pfTextbox -Field 1 -Label "What to say to the World" -Help "Hello Help" -PSCall True -ToolTip "Hello Tip";
}

<#
.SYNOPSIS
    Optiona Method for validation and processing of ATPowerForm control events 
#>
function pfEvent
{
    Switch ($pfField)
    {
        1 {
            if ($pfFields[1] -ne "") {
                pfDeleteField -Field 2 -DeleteType Data;
                If ($pfFields[1] -eq "Hello") {
                    pfTextbox -Field 2 -Label "Result" -Text $($pfFields[1] + " to you too.") -ReadOnly True;
                } else {
                    pfTextbox -Field 2 -Label "Result" -Text "Don't you mean Hello" -ReadOnly True;
                }
            } else {
                pfDeleteField -Field 2 -DeleteType Page;
            }
        }
    }
}


#########################
# Main Execution and Exit
#########################
if ($pfCMD -ne "") {
    $pfSuccess = pfExecute; # ATPowerForm Execution function
    Return $pfReturnData;
}


# The following lines are only required for console execution
$Value = Read-Host -Prompt "Greetings (" + $Value + ")";
If ($Value -ne "Hello Data" -and $Value -ne "" ) {
    $Value = "Hello Default"
} else {
    $Value = "Hello Data"
}
Write $Value