PowerShell
which = Get-Command
export ENVIRONMENT='paniat' = $env:ENVIRONMENT = 'paniat'
grep whatever = Select-String -Pattern whatever
Command History liegt in Datei %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt. Get-History sollte wohl auch funktionieren, tut aber nicht... history gilt nur f�r die aktuelle Session. Auch ggf. interessant ist Start-Transcript und Stop-Transcript, um ganze Sessions aufzuzeichnen.
Prüfen, ob System AD-joined ist: dsregcmd /status
NTP checken / einstellen
Quelle: https://www.reddit.com/r/PowerShell/comments/a3mfnp/check_ntp_in_powershell/
NTP key location: $NTPreg = "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters"
Get current NTP configuration. $NTPtype can be "NT5DS" (domain hierarchy, get time from PDCe) or "NTP" (get time from configured NTP source.) $NTPtype = (Get-ItemProperty -Path $NTPreg).Type
Get FQDN of the NTP server to get time from. Only applicable if $NTPtype is NTP. Ignored if $NTPtype is NT5DS. $NTPvalue = (Get-ItemProperty -Path $NTPreg).NTPserver
Use w32tm.exe to set the client to get time from the PDCe:
$w32tm = "w32tm /config /syncfromflags:domhier /update"
invoke-expression $w32tmrestart-service W32Time
Use w32tm.exe on the PDCe to get time from external source:
$ntpserver = "time.google.com"
$w32tm = "w32tm /config /manualpeerlist:$ntpserver /syncfromflags:manual /reliable:yes /update"
Invoke-Expression $w32tmrestart-service W32Time
Auf Prozess / Befehl warten
Manchmal notig zB bei Installationen von Sachen. Die warten nicht von selbst und returnen sofort, daher mit Start-Process -Wait: Start-Process "C:\Installation\vcredist_x86.exe" -ArgumentList "/repair /passive /norestart /log vcredist.log" -Wait
Checken, ob Server an WSUS hängt
Get-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate
Uptime / letzter Reboot
wmic path Win32_OperatingSystem get LastBootUpTime