PowerTip: Verify If File Changes by Computing Hash

Doctor Scripto

Summary: Use Windows PowerShell and compute a hash to verify if a file changes.

Hey, Scripting Guy! Question How can I use Windows PowerShell in Windows 8.1 to ensure that my Windows PowerShell profile
          does not change without me knowing it?

Hey, Scripting Guy! Answer Use the Get-FileHash cmdlet and store the returned object somewhere (for example, export it
          to an XML file, or store the hash in a file or in the registry). When you suspect changes, use the 
          Get-FileHash cmdlet again, and compare the two objects by using the Compare-Object cmdlet:

$hash = Get-FileHash $profile

$hash1 = Get-FileHash $profile

Compare-Object $hash $hash1 -Property hash

Note  If nothing has changed, nothing returns.


Discussion is closed.

Feedback usabilla icon