PowerShell: Import-PSSession and memory leak

Import-PSsession does cause memory leak because memory is not released when your script ends.
So use Remove-PSsession to clean up at end of the script. Works well except if your script terminates then the session is still left there. So use Try to encapsulate your code and use finally
In this day and age we assume garbage collection is automatic in Windows and the days of memory management when coding is gone. Well it isn’t. Its better than the C/C++ days when you code had to be memory efficient but the gaps of today are hidden because we have tons of memory to play with. And besides its still standard best practice to reboot your servers periodically.
Seems like a good idea for IoT to solve.