PowerShell
July 9, 2019 — 9:17

Author: silver  Category: dev linux windows  Comments: Off

I’ve been using PS for a while now and I don’t hate it anymore :) In fact, I think it’s very usable for lots of tasks and automation. Easy to learn too, a bit like “python-lite” for sysadmins perhaps.

Here’s some Useful commands

discover/help:

  • Get-Command *help* or Get-Command-Module PackageManagement
  • Get-Member to view properties e.g. Get-Disk | Get-Member
  • Get-Alias

access:

  • Get-ExecutionPolicy -List
  • Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • Run as admin: powershell.exe -Command "Start-Process cmd -Verb RunAs"

support for csv, xml and json is included:

  • Import-CSV Export-CSV
  • ConvertTo-XML
  • ConvertFrom-Json ConvertTo-Json

And stuff like:

Remote usage is also possible over WinRM (or OpenSSH):

  • Enter-PSSession -ComputerName <host>

Then there’s Loops, Params, Arrays and Hash Tables e.g. foreach, Param([string]$arg), @() and @{}

Besides for Windows and Azure, PS (Core) can also be used on Linux/MacOS and then there’s PowerCLI for VMware. Not bad, not bad at all.

More info:








We use Matomo free and open source web analytics
We also use Jetpack WordPress.com Stats which honors DNT