Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

batch color-befehl in powershell

$
0
0

Hallo

mittlerweile schreibe ich die meisten neuen Scripte in Powershell. Das funktioniert recht gut.

Laut Konvention hier muss im Fehlerfall ein rotes Fenster mit einer sprechenden Meldung stehen bleiben.

Das geht unter DOS/Batch recht einfach per color-befehl. Genau das brauche ich auch in Powershell.

Ich brauche nicht den Hintergrund in einer Zeile oder ab einer Zeile sondern die 1:1 Umsetzung des color-Befehls.

Ich habe schon versucht:

$Host.PrivateData.ConsolePaneForegroundColor = "DarkCyan"
$Host.PrivateData.ConsolePaneBackgroundColor= $bckgrnd
$Host.PrivateData.ConsolePaneTextBackgroundColor= "Yellow"

oder 

function color ($bc,$fc) {
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = $bc
$a.ForegroundColor = $fc ; cls}

ebenso hab ich versucht cmd color 07 aber nichts geht.

Wie kann ich ein vollständig rotes Fenster mit schwarzem Text erreichen?


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>