A simple script module for checking if there were changes to your Powershell profile between sessions.
ℹ️ NOTE
This module is exploring development and may have frequent breaking changes. Please be sure to read the changelog and consider this module to NOT be production-ready.
You can install the module from the PowerShell Gallery.
Install-PSResource -Name PSProfileWatcher -Repository PSGallery
# Or, install using PowerShellGet module, which is no longer in active development.
# Install-Module -Name PSProfileWatcher -Repository PSGalleryAlternatively, you can download the latest release, extract the archive, then import the module.
Expand-Archive -Path "$($env:HOME)\Downloads\PSProfileWatcher-0.2.0.tar.gz"
Import-Module ".\PSProfileWatcher-0.2.0\PSProfileWatcher"Once you've imported the module, get started by using Get-Command -Module PSProfileWatcher to discover the functions, or by reading the docs. Some common scenarios are covered below for your convenience.
This will prepend the contents of your PowerShell profile with the requisite commands for checking the profile.
Register-PSProfileSnapshotTestCreating a snapshot is as simple as this.
New-PSProfileSnapshotOptionally, you can name your snapshot and include notes.
New-PSProfileSnapshot -Name "backup" -Notes "Before major changes"To get a list of the available profile snapshots:
Get-PSProfileSnapshotRemove-PSProfileSnapshot -Name "Example"You can also get a specific snapshot and pipe it to the removal function.
Get-PSProfileSnapshot | Where-Object { $_.GUID -eq '00000000-0000-0000-0000-000000000000' } | Remove-PSProfileSnapshotYou can remove any profile snapshots except the most recent X snapshots.
Remove-PSProfileSnapshot -KeepLast 5You can also remove any profile snapshots that are older than X days.
Remove-PSProfileSnapshot -OlderThan 7If you look in your profile directory and see a large number of files hanging around, they could be orphaned. You can clean those up like so:
Clear-PSProfileSnapshotOrphansIf you want to go back to a specific snapshot, you can do that by name, GUID, or by selecting the first/last, etc..
Restore-PSProfileSnapshot -GUID '00000000-0000-0000-0000-000000000000'Restore-PSProfileSnapshot -Name 'Example'Get-PSProfileSnapshot | Select-Object -First 1 | Restore-PSProfileSnapshotYou can compare two snapshots against each other by name or GUID.
Compare-PSProfileSnapshot -Name1 'Example' -Name2 'Baseline'Compare-PSProfileSnapshot -GUID1 '00000000-0000-0000-0000-000000000000' -GUID2 '00000000-0000-0000-0000-000000000000'You can also test the hash of your current profile against the hash of the last snapshot.
Test-PSProfileSnapshotIf you've enabled profile checking with the Register-PSProfileSnapshotTest function, then this will happen each time your profile loads.
Finally, if you no longer want your profile checked at load:
Unregister-PSProfileSnapshotTestThis will remove the related code from the beginning of your profile.
Please ⭐ star this repository if it is helpful. Constructive feedback is always welcome, as are pull requests. Feel free to open an issue on the repository if needed.

