Lab 09 ‐ Powershell Scripting - rune-seregina/sys-255-fa24 GitHub Wiki
Objective
To add onto my practice Bash scripting, I aimed to gain familiarity with the Windows scripting language, PowerShell, to augment my system administration skills. Using PowerShell, I created and executed some simple scripts with parameters, and practiced executing remote PowerShell commands.
Vocab:
- Alias: an alternate name for a command or commandlet in PowerShell, set using the New-Alias commandlet/
- Cmdlet: "mini command", perform an action within powershell. Follow a verb-noun naming convention (Get-Process, Set-Location, etc.)
- Array: a structure designed to store collections of items, aka multiple values stored within a variable
- Split Operator: splits a string into substrings
Resources used:
- My Network Diagram (Last Update: Lab 05):
- SYS Labs: https://docs.google.com/document/d/1fGtUcwb7131nRH1fk4nGSGXXOA4GkZb4n1snCJmlGeU/edit#heading=h.23gysb7e448l
IP Assignments:
- WAN IP (synonymous with fw interface 1/em0): 10.0.17.112/24
- LAN IP (synonymous with fw interface 2/em1): 10.0.5.2/24
- wks02-rune IP: 10.0.5.150/24 (or as assigned by DHCP)
- wks02/ad02/dhcp02/fs01/web01 default gateway: 10.0.5.2/24
- wks02/dhcp02/fs01/web01 dns: 10.0.5.6
- ad02-rune ip: 10.0.5.6/24
- dhcp02-rune ip: 10.0.5.4/24
- fs01-rune ip: 10.0.5.8/24
- blog01-rune ip: 10.0.5.22/24
Accounts:
- ad02-rune: rune\Administrator (password A)
- rune.local: rune.seregina (password A)
- rune.local: rune.seregina-adm (password A)
- rune.local: alice (password A)
- rune.local: bob (password A)
- dhcp-1-rune: rune (password A)
- fs01-rune: Administrator (password B)
- web01-rune: rune (password A)
PowerShell Commands
- Write-Host - write output directly to console (e.g. echo)
- Get-Content - view contents of an item at a specified location (e.g. cat)
- Set-Alias - create an alias (alternate name) for a command by specifying a new name and the existing command for the alias
-
- -Name
-
- -Value
- Set-ExecutionPolicy - change execution policy, which determines who can load execution files or run scripts
-
- -Scope - where this execution policy is applied
- Resolve-DnsName - perform a DNS query for a specified name (e.g. nslookup)
- Select-Object - select specified properties (e.g. grep)
- Get-ADComputer - retrieve information about computer(s) in AD
- Enter-PSSession - enter PowerShell session with a remote computer
-
- -ComputerName - name of computer to remote to
-
- -ScriptBlock - piece of script enclosed in curly brackets, either to store in a parameter or enter into a remote session, etc.
Troubleshooting
- No troubleshooting here!
Reflection
I think PowerShell commands and scripting are less intuitive than Bash to me, so I liked it less than the Bash exercises. Still, I am glad I got to learn some basic PS familiarity.