Fandom

The Sysadmin Wiki

Powershell

157pages on
this wiki
Add New Page
Talk0 Share

Powershell is a new scripting platform on Windows systems.

Pause Edit

To get the same functionality as the pause command in dos, run the following commands:

write-host -nonewline "Press any key to continue . . . "; $host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown") | Out-Null; echo ""

The only difference between running this and the pause command in DOS, seems to be that this includes keypresses of modifiers like shift, ctrl and alt, which the pause command in DOS doesn't seem to do, although these keys should be included in the "any key" category.

Tail -f Edit

One way to implement the tail -f on Unix/Linux in powershell, would be with the following command:

Get-Content logfile.txt -wait

The -wait argument isn't in the documentation and it seems to stop updating after a while. Another way to implement it is with this script, which updates every second:

while ($true) { clear; cat logfile.txt | Select-Object -last ($host.ui.rawui.windowsize.height-1); sleep 1 }

The flickering happens because it clears the screen on every update. That could be avoided, by just reading a line at a time and overwriting it.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.