When running on Windows, the default script handler in Azure DevOps uses cmd.exe, unless you explicitly change it.
Which is causing your partial outputs for strings that contains cmd-reserved characters, cmd is trying to parse %...% as an environment variable or uses & to chain commands.
Either switch to PowerShell on Windows or escape it properly.
Me personally, I'd recommend you to use the PowerShell approach.