Introduction

PowerShell is a task automation and configuration management framework from Microsoft. It consists of a command-line shell and associated scripting language built on the .NET framework. Here are key points about PowerShell:

  1. Command-Line Interface (CLI): PowerShell provides a robust CLI for managing and automating the administration of Windows and other systems.

  2. Scripting Language: PowerShell’s scripting language enables administrators to write scripts to automate complex tasks and manage systems programmatically.

  3. Cmdlets: PowerShell uses cmdlets, which are specialized .NET classes, to perform specific operations. Examples include Get-Process, Stop-Service, and Set-Item.

  4. Pipelines: PowerShell allows the output of one cmdlet to be passed as input to another, enabling powerful and flexible data processing and task automation.

  5. Cross-Platform: PowerShell Core (now simply PowerShell) is cross-platform and available on Windows, macOS, and Linux.

  6. Integration: PowerShell integrates seamlessly with other Microsoft products and services, making it a valuable tool for managing environments that include Windows servers, Azure cloud services, and more.

  7. Modules: It supports modules, which are packages of cmdlets, scripts, functions, and other tools that can extend its functionality.

PowerShell is a versatile and powerful tool for system administrators and developers to automate and manage system tasks efficiently.

Getting Started

Quick: How to Open Command Prompt or Powershell In case you do not know how to open the Command Prompt or Powershell and you got here by search engine, the following is a quick guide that will work for Windows XP and beyond:

For non-administrative commands

  1. Press [Windows]+[R] or Click on the “Start” button
  2. Then, type powershell
  3. Press [OK] or hit enter

For administrative commands

  1. Click on the “Start” button
  2. Then, type powershell
  3. Choose “Run as Administrator” or right-click and choose “Run as Administrator”

Cool Commands

Update All Applications on Windows

You can update all applications on a Windows machines with two simple commands.

Type winget upgrade this will list all your applications, their current version, and available versions.

Type winget upgrade --all this will list all out-of-date applications, current versions, available version and start upgrading them.

You may also get a notice that some version cannot be determined, for these you would need to add the argument --include-unknown.

Type winget upgrade --include-unknown this will list all your applications, their current version, and available versions.

Type winget upgrade --all --include-unknown this will list all out-of-date applications, current versions, available version and start upgrading them.

Testing TCP Connectivity with Test-NetConnection

You can use the Test-NetConnection or tnc for short, which is a function to test connectivity to an address.

SYNTAX Test-NetConnection [[-ComputerName] ] [-TraceRoute] [-Hops ] [-InformationLevel {Quiet | Detailed}] []

Test-NetConnection [[-ComputerName] <string>] [-CommonTCPPort] {HTTP | RDP | SMB | WINRM} [-InformationLevel
{Quiet | Detailed}]  [<CommonParameters>]

Test-NetConnection [[-ComputerName] <string>] -Port <int> [-InformationLevel {Quiet | Detailed}]
[<CommonParameters>]

Test-NetConnection [[-ComputerName] <string>] -DiagnoseRouting [-ConstrainSourceAddress <string>]
[-ConstrainInterface <uint32>] [-InformationLevel {Quiet | Detailed}]  [<CommonParameters>]

A quick example I use most is something like this, where you specify the IP address and port you wish to test. Type Test-NetConnection 192.168.1.1 -port 443

This will test

Retrieving a File Hash

CertUtil -hashfile FileName MD5 The following rules are as of Windows 7 SP1, Windows Server 2012, and beyond. If they are known to work in older versions, they will be noted with: (independent of Windows version)

You will need to open a Command Prompt OR Powershell to run this command ** a quick guide to open CMD/Powershell is at the bottom of the answer

You can find the checksum for a file using ANY of the following hashing algorithms, not JUST MD5:

MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512 To get the current list of supported Hash Algorithms on your specific windows machine (independent of Windows version), run

CertUtil -hashfile -? The full Format is below, optional parameters are in braces - just replace [HashAlgorithm] with your desired hash from above:

CertUtil -hashfile FileName [HashAlgorithm] You can do the command line operation for ANY files, whether they provide a certificate or not (independent of Windows version)

If you leave off the [HashAlgorithm], it will default to the SHA1 checksum of your chosen file

Its HELPFUL to note that [HashAlgorithm] is case INsensitive in both CMD and Powershell meaning you can do any of the following (for example):

CertUtil -hashfile md5
Certutil -hashfile MD5
certUtil -hashfile sHa1
certutil -hashfile SHA256