I had to create a mechanism to purge a directory that is built out of builds in format of version e.g. 18.104.22.168.
The requirement was to save last X builds and other should be purged, so i created the following PS script for it
The code iterate on the input folder and extracting all the folders in the pattern of the version, sort it by flattening the version to full string (static size) and than skipping the first X
I still find my self struggling with powershell (its not as easy as i though it would be)