May 8th, 2014

PowerTip: Verify If File Changes by Computing Hash

Doctor Scripto
Scripter

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.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.