# PowerShell escape character ends the variable "Number is $id`:" # braces "embrace" the variable name "Number is ${id}:" # subexpressions execute the code in the parenthesis "Number is $($id):" # the format operator inserts the array on the right into the # placeholders in the template on the left 'Number is {0}:'-f$id # which is essentially this: 'Number is ' + @($id)[0] + ':'
# careful with "addition": this requires the first # element to be a string. So this works: 'Number is ' + $id + ':' # this won't: $id + " is the number" # whereas this will again: '' + $id + " is the number"
# specify your command name $ContextCommand = "Open Script with Notepad" # specify the command to execute. "%1" represents the file path to your # PowerShell script $command = 'notepad "%1"'
FunctionLock-Screen { [CmdletBinding()] param ( # number of seconds to lock [int] $LockSeconds = 10,
# message shown. Use {0} to insert remaining seconds # do not use {0} for a static message [string] $Title = 'wait for {0} more seconds...',
# dim screen [Switch] $DimScreen )
# when run without administrator privileges, the keyboard will not be blocked!
# get access to API functions that block user input # blocking of keyboard input requires admin privileges $code = @' [DllImport("user32.dll")] public static extern int ShowCursor(bool bShow); [DllImport("user32.dll")] public static extern bool BlockInput(bool fBlockIt); '@
#requires -RunAsAdministrator # when run without administrator privileges, the keyboard will not be blocked!
# get access to API functions that block user input # blocking of keyboard input requires administrator privileges $code = @' [DllImport("user32.dll")] public static extern bool BlockInput(bool fBlockIt); '@