Search notes:

Powershell: $host.ui

$host.ui is a System.Management.Automation.Internal.Host.InternalHostUserInterface object.

PromptForChoice

$one   = new-object System.Management.Automation.Host.ChoiceDescription '&one'  , 'First option'
$two   = new-object System.Management.Automation.Host.ChoiceDescription '&two'  , 'Second option'
$three = new-object System.Management.Automation.Host.ChoiceDescription 't&hree', 'Third option'

$options = [System.Management.Automation.Host.ChoiceDescription[]]($one, $two, $three)

$default = 2
$result = $host.ui.PromptForChoice('What now?', 'Choose an option', $options, $default)

write-host "OK: $($result+1)"

PromptForCredential

$host.ui.promptForCredential(…) can be used to get a System.Management.Automation.PSCredential object from a username and a password.
$cred = $host.ui.promptForCredential('Connecting to XYZ', 'Enter username and password.', '', 'XYZ')

Connecting to XYZ
Enter username and password.
User: rene
Password for user rene: ********
Compare with the get-credential cmdLet.

write… methods

$host.ui.write('text')
$host.ui.writeDebugLine('xyz was called')
$host.ui.writeErrorLine('wrong input.')
$host.ui.writeInformation('info')
$host.ui.writeLine('just a line')
$host.ui.writeProgress(…)
$host.ui.writeVerboseLine(…)
$host.ui.writeWarningLine(…)
Compare with the respective write cmdlets.

TODO

$host.ui.supportsVirtualTerminal
$host.ui.prompt(…)
$host.ui.promptForChoice(…)
$host.ui.readLineAsSecureString()

See also

$host.ui.rawUI

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758206416, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/variable/automatic/host/ui/index(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78