1 Pluspunkt 0 Minuspunkte

Wie kann ich mit Powershell 7 das Datum und die Uhrzeit in einem bestimmten Format ausgeben wie z.B

Montag, 1.2.2024 10:20:30
von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Das kannst du mit der ToString() Methode. Mit "dddd" bekommst du den Wochentag dazu.

# Aktuelles Datum und Uhrzeit abrufen
$currentDateTime = Get-Date

# Datum und Uhrzeit im gewünschten Format darstellen
$formattedDateTime = $currentDateTime.ToString("dddd, d.M.yyyy HH:mm:ss", [System.Globalization.CultureInfo]::GetCultureInfo("de-DE"))

# Ausgabe
$formattedDateTime
von (532 Punkte)