This is a record of things I have found useful in Powershell. It is expected to grow over time.
The Powershell command Get-NetConnectionProfile "gets a connection profile associated with one or more physical network adapters. A connection profile represents a network connection".
With no arguments provided, for each physical network adapter, this provides various pieces of information, such as Name, InterfaceAlias, InterfaceIndex, NetworkCategory, etc.
These pieces of information can be used to find out more about a particular network connection, such as the IP address; say the InterfaceIndex = 13, then the IP address for that network connection can be found using the command Get-NetIPAddress -InterfaceIndex 13.
To change aspects of a network connection, use the Powershell command set-NetConnectionProfile, for example set-NetConnectionProfile -interfacealias "Ethernet 2" -NetworkCategory Private.
The command line prompt can be changed by defining a function called prompt, as described in this Stack Overflow answer. EG:
PS C:\Users\Jake\Documents> function prompt{"$ "}
$ date
24 April 2020 11:48:52
$
Parameters can be added to a Powershell script using the param function, which allows parameters to be given a name, and optionally also a default value and data-type. For example, if the following is saved in a file called script.ps1:
param($a=3, $b=4)
$c = $a + $b
echo "a = $a, b = $b, a + b = $c"
It can be called from the command line in various different ways:
$ ./script
a = 3, b = 4, a + b = 7
$ ./script 20
a = 20, b = 4, a + b = 24
$ ./script 20 30
a = 20, b = 30, a + b = 50
$ ./script -b 23
a = 3, b = 23, a + b = 26
$ ./script -b 23 -a 42
a = 42, b = 23, a + b = 65
$ powershell -file script.ps1 -b 123
a = 3, b = 123, a + b = 126