When using an Advanced Deployment step in Chocolatey Central Management, installed PowerShell modules throw an error when attempting to load into the PowerShell host after the first time at doing so.
What is Expected?
Advanced Deployment step code is executed on a target machine every time it is needed
How Did You Get This To Happen? (Steps to Reproduce)
To reproduce, run the following deployment against your targets twice
What You Are Seeing?
When using an Advanced Deployment step in Chocolatey Central Management, installed PowerShell modules throw an error when attempting to load into the PowerShell host after the first time at doing so.
What is Expected?
Advanced Deployment step code is executed on a target machine every time it is needed
How Did You Get This To Happen? (Steps to Reproduce)
To reproduce, run the following deployment against your targets twice
System Details
Output Log
error.log
~~~sh 2023-11-27 19:13:27,989 [DEBUG ] - Calling Chocolatey PowerShell agent (tag: '34') 2023-11-27 19:13:27,989 [DEBUG ] - Running the following (may differ slightly from provided): ## 2023-11-27 19:13:27,989 [DEBUG ] - $hostname = hostname Write-Host "Hostname: $hostname" Import-Module NetSecurity -Force Get-NetFirewallSetting -PolicyStore ActiveStore | Select-Object -ExpandProperty ActiveProfile ## exit $LASTEXITCODE 2023-11-27 19:13:28,035 [INFO ] - Hostname: DemoServer 2023-11-27 19:13:28,035 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetSecurity\NetSecurity.psd1'. 2023-11-27 19:13:28,035 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetSecurity\NetSecurity.types.ps1xml'. 2023-11-27 19:13:28,035 [VERBOSE] - Loading 'FormatsToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetSecurity\NetSecurity.formats.ps1xml'. 2023-11-27 19:13:28,066 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetSecurity\Microsoft.Windows.Firewall.Commands.dll'. 2023-11-27 19:13:28,066 [ERROR ] - Value cannot be null. Parameter name: source at, : line 3 2023-11-27 19:13:28,066 [DEBUG ] - Chocolatey PowerShell agent exited with '1'. ~~~
Workarounds
Proposed Solution
Related Issues and Tickets
Done Checklist
TBD
┆Issue is synchronized with this Gitlab issue by Unito