Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Note the comments after Params!!

https://ss64.com/ps/get-help.html
https://stackoverflow.com/questions/5237723/how-do-i-get-help-messages-to-appear-for-my-powershell-script-parameters

<#
.SYNOPSIS
    Short Synposis
.DESCRIPTION
    Author: FreeSoftwareServers
    Date:   Sept, 2020
    Addition Arguments: Explanation

.EXAMPLE
script.ps1 -PARAM TRUE

.EXAMPLE
PowerShell.exe -ExecutionPolicy Bypass -File "C:\suppress\prompt.ps1" 2>&1>$null
#The Above Line Suppresses Confirmation Prompt

#Files to Print
$PWD = "C:\tmp" 
$PrintFiles = @(
       [pscustomobject]@{FILEPATH="$PWD\test.xlsx";OptArgs="-DUPLEXFLIPON SHORT -ORIENTATION LANDSCAPE -FitToPagesTall TRUE"}
   )

#Configure Default Params
$Script="C:\tmp\print_file.ps1"
#Must Define 1 Print Server minimum
$DefParams = @(
       [pscustomobject]@{VarName="PRINTSRV";VarVal="\\NA\NA01"}
       [pscustomobject]@{VarName="DUPLEXPRINTSRV"; VarVal="\\NA\NA02"}
   )
#Don't Edit Below This Line
$DefArgs = "" ; $DefParams | ForEach-Object{IF ($_.VarVal) {$DefArgs += " -" + $_.VarName + ' "' + $_.VarVal + '" '}}
$PRINTCMD = "" ; $PrintFiles | ForEach-Object {$PRINTCMD = $SCRIPT + $DefArgs + '-FILEPATH "' + $_.FILEPATH + '" ' + $_.OptArgs ; $PRINTCMD ; Invoke-Expression $PRINTCMD}
#>
Param(
    [Parameter(Mandatory=$true)] #MANDATORY, accepts "WildCards", Eg: "C:\tmp\tes*.docx"
    [string]$FILEPATH, 
  • No labels