powershell¶
PowerShell is a shell for Windows operating systems, and it was ported to Linux in 2016.
https://github.com/PowerShell/PowerShell/
Profile.ps1¶
On startup, powershell will run any .ps1 files it finds in the WindowsPowerShell directory under my documents. There is allegedly a Profile.ps1 file in there by default.
$env:Path = "c:\Users\user1\Dropbox\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"
Examples¶
Restart a remote computer¶
Find a command that matches a substring¶
Get help on commands that match a substring¶
Show ACLs of the current dir¶
Show system BIOS information¶
Show object methods¶
Browse the registry¶
Show top processes¶
Browse the Cert store¶
Get a list of stopped services¶
Compare two objects¶
This will only show the lines that are not common:
Save object to a csv¶
Load object from a csv and parse it¶
Import-Csv ./processes.csv | Where-Object { $_.Name -like "*systemd*" } | Select-Object -last 10 | Format-Table
Replacement for unix tail¶
tail filename
tail -f
Replacement for unix wc¶
Replacement for unix time¶
Replacement for unix grep -B2 -A1¶
Install PowerShell in Ubuntu 18.04¶
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update && \
apt-get install -y powershell
See Also¶
- http://poshcode.org/: Used to be a great PSH site with example code. Now it looks like it's just a chat network portal, which IMHO seems much less useful.
- https://developer.vmware.com/web/tool/12.5.0/vmware-powercli: PowerCLI: VMware PSH CLI