Azure Release Pipeline Fails Using Expand-Archive Command Sometime in the last week, our pipeline started using Expand-Archive to open the .zip file during the &quot;IIS Web App Deployment&quot; step instead of 7-Zip. It does not appear that this was done by our team, so I'm presuming this may have been changed in DevOps.
We are deploying to Server 2012R2.
Several of our apps are okay with this, however one of them fails to expand. It seems as if this might be related to path length (this app uses some very deep folder nesting with Angular) since I can manually run the command successfully if I shorten the destination path.
The command that fails to runs on the server is:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command &quot;Expand-Archive -Path &quot;C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip&quot; -DestinationPath &quot;C:\azagent\A3\_work\_temp\temp_web_package_8157628602055582&quot; -Force&quot;

If I reduce it to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command &quot;Expand-Archive -Path &quot;C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip&quot; -DestinationPath &quot;C:\azagent\A3\_work\_temp\short&quot; -Force&quot;

...it appears to work fine.
Obviously, I am speculating that it's a path-length issue, but evidence does seem to support it. Also, I reconstructed what would have been the 7-Zip command and it worked as expected:
C:\azagent\A3\_work\_tasks\IISWebAppDeploymentOnMachineGroup_1b467810-6725-4b6d-accd-886174c09bba\0.184.0\node_modules\webdeployment-common-v2\7zip\7z.exe x -oC:\azagent\A3\_work\_temp\temp_web_package_8157628602055582 C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip

I looked at the advice here and found we are already using the setting:
https://igorpuhalo.wordpress.com/2019/08/29/overcoming-long-path-problem-in-powershell/
My hope is that someone knows what may have changed, can suggest a straightforward way to go back to using 7-Zip, or a way to make Expand-Archive to work.
This was answered via StackOverflow by Kevin Lu:
https://stackoverflow.com/a/66739852/1224614
In short, the second suggestion he made to update to PowerShell 7 and adding the environment information worked. I also had to run the script to reregister the Azure agent on the target server.