The output transformation you need (spaces to %20, forward slashes to %2F) is called URL encoding. It replaces (escapes) characters that have a special meaning when part of a URL with their hex equivalent preceded by a % sign.
https://stackoverflow.com/questions/23548386/how-do-i-replace-spaces-with-20-in-powershell