Been a while since I had to use this, and recently found myself back doing this sort of thing. The script failed with the message "The term 'Get-S3Object' is not recognized as the name of a cmdlet, ...." etc.
The issue is a missing file called "SQLPS.exe.config" in C:\Program Files (x86)\Microsoft SQL Server\<version>\Tools\Binn
Contents is pretty simple:
<probing privatePath="ManagementStudio" />