Hallo,
ich wollte jetzt mal in den Umgang mit der Powershell einsteigen. Habe mir dann erst mal ein Einsteigerbuch gekauft. Schon im ersten Kapitel bin ich auf Probleme gestoßen wo mir jegliches logisch Verständnis fehlt. Ich habe ausgib geschaut, alles was ich gefunden habe war genau so geschrieben wie im Buch. Und zwar geht es um das setzen der Farben in Powershell, bzw. auslesen mit Get-PSReadLineOption und dem Set Pardon.
Der Befehl "Get-PSReadLineOption"
Erst mal die Version $PSVersionTable
Name Value ---- ----- PSVersion 5.1.17763.1 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.1 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Buch und MS Docs
PS C:\> Get-PSReadlineOption EditMode : Windows ContinuationPrompt : >>> ContinuationPromptForegroundColor : DarkYellow ContinuationPromptBackgroundColor : DarkMagenta ExtraPromptLineCount : 0 AddToHistoryHandler : CommandValidationHandler : CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...} HistoryNoDuplicates : False MaximumHistoryCount : 4096 MaximumKillRingCount : 10 HistorySearchCursorMovesToEnd : False ShowToolTips : False DingTone : 1221 CompletionQueryItems : 100 WordDelimiters : ;:,.[]{}()/\|^&*-=+--- DingDuration : 50 BellStyle : Audible HistorySearchCaseSensitive : False HistorySavePath : C:\Users\TestUser\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt HistorySaveStyle : SaveIncrementally DefaultTokenForegroundColor : DarkYellow CommentForegroundColor : DarkGreen KeywordForegroundColor : Green StringForegroundColor : DarkCyan OperatorForegroundColor : DarkGray VariableForegroundColor : Green CommandForegroundColor : Yellow ParameterForegroundColor : DarkGray TypeForegroundColor : Gray NumberForegroundColor : White MemberForegroundColor : White DefaultTokenBackgroundColor : DarkMagenta CommentBackgroundColor : DarkMagenta KeywordBackgroundColor : DarkMagenta StringBackgroundColor : DarkMagenta OperatorBackgroundColor : DarkMagenta VariableBackgroundColor : DarkMagenta CommandBackgroundColor : DarkMagenta ParameterBackgroundColor : DarkMagenta TypeBackgroundColor : DarkMagenta NumberBackgroundColor : DarkMagenta MemberBackgroundColor : DarkMagenta EmphasisForegroundColor : Cyan EmphasisBackgroundColor : DarkMagenta ErrorForegroundColor : Red ErrorBackgroundColor : DarkMagenta
Meine Ausgabe
PS C:\Users\Chef> Get-PSReadLineOption EditMode : Windows AddToHistoryHandler : HistoryNoDuplicates : True HistorySavePath : C:\Users\Chef\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt HistorySaveStyle : SaveIncrementally HistorySearchCaseSensitive : False HistorySearchCursorMovesToEnd : False MaximumHistoryCount : 4096 ContinuationPrompt : >> ExtraPromptLineCount : 0 PromptText : > BellStyle : Audible DingDuration : 50 DingTone : 1221 CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...} CommandValidationHandler : CompletionQueryItems : 100 MaximumKillRingCount : 10 ShowToolTips : True ViModeIndicator : None WordDelimiters : ;:,.[]{}()/\|^&*-=+'"–—― CommandColor : "$([char]0x1b)[93m" CommentColor : "$([char]0x1b)[32m" ContinuationPromptColor : "$([char]0x1b)[33m" DefaultTokenColor : "$([char]0x1b)[33m" EmphasisColor : "$([char]0x1b)[96m" ErrorColor : "$([char]0x1b)[91m" KeywordColor : "$([char]0x1b)[92m" MemberColor : "$([char]0x1b)[97m" NumberColor : "$([char]0x1b)[97m" OperatorColor : "$([char]0x1b)[90m" ParameterColor : "$([char]0x1b)[90m" SelectionColor : "$([char]0x1b)[35;43m" StringColor : "$([char]0x1b)[36m" TypeColor : "$([char]0x1b)[37m" VariableColor : "$([char]0x1b)[92m"
Erst mal fehlen Variabelen wie z.B.
ContinuationPromptForegroundColor ContinuationPromptBackgroundColor
und die Farben werden nicht als Farbnamen angezeigt.
Dann gehts ja weiter mit Set-PSReadlineOption. Wenn ich mir nun mit StrG+Leertaste alle Optionen anzeigen lasse, fehlen mir halt auch hier welche. auch hier der Vergleich.
Das sollte ich laut docs.microsoft haben
Set-PSReadlineOption [-EditMode <EditMode>] [-ContinuationPrompt <String>] [-ContinuationPromptForegroundColor <ConsoleColor>] [-ContinuationPromptBackgroundColor <ConsoleColor>] [-EmphasisForegroundColor <ConsoleColor>] [-EmphasisBackgroundColor <ConsoleColor>] [-ErrorForegroundColor <ConsoleColor>] [-ErrorBackgroundColor <ConsoleColor>] [-HistoryNoDuplicates] [-AddToHistoryHandler <System.Func`2[System.String,System.Boolean]>] [-CommandValidationHandler <System.Action`1[System.Management.Automation.Language.CommandAst]>] [-HistorySearchCursorMovesToEnd] [-MaximumHistoryCount <Int32>] [-MaximumKillRingCount <Int32>] [-ResetTokenColors] [-ShowToolTips] [-ExtraPromptLineCount <Int32>] [-DingTone <Int32>] [-DingDuration <Int32>] [-BellStyle <BellStyle>] [-CompletionQueryItems <Int32>] [-WordDelimiters <String>] [-HistorySearchCaseSensitive] [-HistorySaveStyle <HistorySaveStyle>] [-HistorySavePath <String>] [-ViModeIndicator <ViModeStyle>] [<CommonParameters>] [-TokenKind] <TokenClassification> [[-ForegroundColor] <ConsoleColor>] [[-BackgroundColor] <ConsoleColor>] [<CommonParameters>]
und hier meine
Set-PSReadLineOption [-EditMode <EditMode>] [-ContinuationPrompt <string>] [-HistoryNoDuplicates] [-AddToHistoryHandler <Func[string,bool]>] [-CommandValidationHandler <Action[CommandAst]>] [-HistorySearchCursorMovesToEnd] [-MaximumHistoryCount <int>] [-MaximumKillRingCount <int>] [-ShowToolTips] [-ExtraPromptLineCount <int>] [-DingTone <int>] [-DingDuration <int>] [-BellStyle <BellStyle>] [-CompletionQueryItems <int>] [-WordDelimiters <string>] [-HistorySearchCaseSensitive] [-HistorySaveStyle <HistorySaveStyle>] [-HistorySavePath <string>] [-AnsiEscapeTimeout <int>] [-PromptText <string>] [-ViModeIndicator <ViModeStyle>] [-Colors <hashtable>] [<CommonParameters>]
gibt es dafür eine Erklärung?
Danke vorab