Add in your powershell script (if you want to free memory) to call the garbade collector:

# Freeing up memory

[System.GC]::Collect()