Non-ascii characters are malformed when PHP configuration script of External APS application is run on Windows provisioning gateway.
For example, BackupAgent script fails with the following error message:
SOAP-ERROR: Encoding: string 'S+\xfa...' is not a valid utf-8 string
The 'City' field was São Paulo, and non-ascii symbol was broken.
Windows has 2 code pages: ACP (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP) and OEMCP (MS DOS code page, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP).
By default, they are different.
Settings are passed to PHP script via Windows batch script, which uses OEMCP codepage, while php.exe interpreter uses ACP, so there is encoding conflict.
Problem does not occur if configuration script is vbscript or jscript instead of PHP.
To fix the problem, set OEMCP to the same value as ACP.
Change OEMCP in registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage) and reboot node.