- Get the IP address
- ipconfig
- Get-NetIPAddress
- Get the mac address
- ipconfig /all
- Get-NetAdapter
- Get the DNS servers
- ipconfig /all
- Get-NetIPConfiguration
- Trace route
- tracert <destination>
- Test-NetConnection -TraceRoute <destination>
- Ping
- ping <destination>
- Test-Connection <destination>
- Netstat is a little more complicated because UDP and TCP are different commands
- netstat
- Get-NetTCPConnection / Get-NetUDPEndpoint
- Netstat but with process information attached (powershell uses pid, but you can fudge the names in there)
- netstat -b
- Get-NetTCPConnection | select localaddress,localport,remoteaddress,remoteport,state,@{N="Process";E={$(gps -pid $_.owningprocess).processname}}|ft
- Update group policy for domain computers (Powershell can do so remotely)
- gpupdate /force
- Invoke-GPUpdate -Computer <computername> -Force
- Rename a computer (Powershell works remotely here as well)
- WMIC computersystem where caption='OldComputerName' rename NewComputerName
- Rename-Computer -ComputerName <oldname> -NewName <newname> -Restart
This is hardly an extensive list. It is true that in most cases the CMD versions are shorter. It is also true that the CMD versions often times use very obscure abbreviated names, whereas Powershell is very verbose in naming. There is also a long list of very useful aliases that make a translation between CMD to Powershell and even Bash to Powershell, and some shortened common Powershell command. For example, list directory in Powershell Get-ChildItem is aliased to gci for short, dir for familiarity with cmd, and ls for familiarity with Bash. While it may seem inconvenient, Powershell is actually very good at dealing with large batch processes and very easily controlling data flow and even parallel processing (which may seem weird bit can be a huge time saver).
I hope this list helps some people get used to running some basic Powershell tasks, Throw in some basic loops and branching and you're already where you need to begin making very comprehensive automation scripts.
No comments:
Post a Comment