$PSVersionTable $PSVersionTable.PSCompatibleVersions $PSVersionTable.PSVersion
Author: agowa338
Logfile Monitoring (PowerShell/Bash)
PowerShell:
Get-Content -Path .\log.txt -Tail 1 -Wait
Bash:
$ tail -f filename $ less +F filename $ watch tail logfile
Native Network Scanner – foreach-object (PowerShell)
1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send("192.168.1.$_") } | where-object {$_.Status -eq "success"} | select Address
Output:
Address
________
192.168.1.1
192.168.1.20
…
Instead of 1..255 you could use:
- (1..3),5,(7..10) => 1, 2, 3, 5, 7, 8, 9, 10
Status Monitoring – Statusbar
How to have one line updated, for example showing available disk space updated every second.
Within one line:
while true; do echo -ne “$(df | grep /dev/sda4)\\r”; sleep 1; done
how it works:
while true: start of endless loop
- echo:
- -n: prevents line warp after outputting
- -e: allows backslash escape keys
- $(command): Runs the command and inserts the output
- \\r: the first backslash escapes the second, and \r stands for jumping to the beginning of the line
- sleep 1: pause for one second
done: end of endless loop
Within a script, you can write it into multiple lines:
while true
do
echo -ne “$(df | grep /dev/sda4)\\r”
sleep 1
done
SFC is deprecated, use dism instead
Often sfc.exe reports errors that could not be resolved.
Instead of “sfc.exe /scannow” run the following as Administrator:
“Dism /Online /Cleanup-Image /ScanHealth”
“Dism /Online /Cleanup-Image /CheckHealth”
this will report healthy, repairable or non-repairable. If it reports repairable run the following:
“Dism /Online /Cleanup-Image /RestoreHealth”
For offline Images:
“Dism /Image:C:\offline /Cleanup-Image /RestoreHealth”
Note:
The needed files are pulled dynamically from Windows Update so you need to have Internet access.