PowerShell Windows server 2022 Access is denied

I am currently working through upgrading from Windows Server 2016 to Windows Server 2022. During the upgrade process I am experiencing Access is denied when using powershell_script that passes in domain, user, and password. They're many powershell_scripts in our Cookbooks that work that don't need to pass in and run as a different identify. This works just fine on our Window Server 2016.

Has anyone experienced this and know what things to try here? I've done a bunch of searching online, but this is a very vague error.

Here's the complete error:

powershell_script[Apply XXXX License] (xxx_xx_xxxxx_xxxx::default line 95) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None  -File "C:/Windows/Temp/chef-script20220401-4548-scgxea.ps1" ----
STDOUT: 
STDERR: C:\Windows\Temp\chef-script20220401-4548-scgxea.ps1 : Win32 internal error "Access is denied" 0x5 occurred while 
reading the console output buffer. Contact Microsoft Customer Support Services.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,chef-script20220401-4548-scgxea.ps1
---- End output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None  -File "C:/Windows/Temp/chef-script20220401-4548-scgxea.ps1" ----
Ran "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None  -File "C:/Windows/Temp/chef-script20220401-4548-scgxea.ps1" returned 1

Chef version details:
Chef Workstation version: 22.2.807
Chef Infra Client version: 17.9.52
Chef InSpec version: 4.52.9
Chef CLI version: 5.6.1
Chef Habitat version: 1.6.420
Test Kitchen version: 3.2.2
Cookstyle version: 7.32.0

Thanks!
Mike

Are you able to run the powershell script directly on the node with the user you are passing from Chef? It appears from thew error that the "Access Denied" may be from the script itself trying to write out an exception to write-error.

1 Like