Skip to content
Caleb SmithCyberSecurityWithSmitti
Browse PowerShell example contentPowerShell example

08 · Get-FileHash: calculate SHA-256

Calculate a file digest for comparison with a trusted reference or investigation record.

How to use it

Replace the example path with an authorised local file.

Platform and permissions

Read permission to the chosen file.

What changes / what is read

Reads file bytes. No reputation service is contacted by this command.

Scope and interpretation

A hash is identity evidence, not a safety verdict. A changing file can invalidate later comparison; preserve provenance and time.

Practice task

Describe what makes a reference hash trustworthy.

Reference

Microsoft documentation. Review the documentation for your installed version and use only an authorised learning or investigation environment.

This is personal educational material. Review the complete code and your signing policy before use. PowerShell code is displayed and downloaded as text; WordPress does not run it. Collection caps limit rows/files, not every provider’s wall-clock execution time.

PowerShell · PowerShell 5.1+ syntax target; Windows collectors require the stated Windows modules. Full Windows acceptance testing remains required.Download .ps1
#requires -Version 5.1
Get-FileHash -LiteralPath 'C:\Lab\sample.exe' -Algorithm SHA256

Example code is displayed as text. Review it and test in your own lab before use.