chocolatey / chocolatey-licensed-issues

Issues for Licensed Editions of Chocolatey
19 stars 13 forks source link

ScheduledTasks module fails to import on Server 2012 R2 when run as an advanced deployment from CCM #273

Open sync-by-unito[bot] opened 2 years ago

sync-by-unito[bot] commented 2 years ago

When running an Advanced deployment from CCM to a Server 2012 R2 system and attempting to use the ScheduledTasks module from Windows, the import of the module fails. This behaviour is not seen when installing a Chocolatey package that issues the exact same commands.

Sample CCM Advanced deployment script on Server 2012 R2 system:

Import-Module ScheduledTasks

CCM Deployment log:

2021-11-05 01:23:29,948 [DEBUG  ] - Calling Chocolatey PowerShell agent (tag: '199')
2021-11-05 01:23:29,948 [DEBUG  ] -  Running the following (may differ slightly from provided):
2021-11-05 01:23:29,948 [DEBUG  ] - 
-----------
Import-Module ScheduledTasks
-----------

2021-11-05 01:23:30,246 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\ScheduledTasks.psd1'.
2021-11-05 01:23:30,246 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask.types.ps1xml'.
2021-11-05 01:23:30,246 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ScheduledTask.types.ps1xml'.
2021-11-05 01:23:30,246 [VERBOSE] - Loading 'FormatsToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask.format.ps1xml'.
2021-11-05 01:23:30,293 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask_v1.0.cdxml'.
2021-11-05 01:23:30,481 [VERBOSE] - Exporting function 'Get-ScheduledTask'.
2021-11-05 01:23:30,481 [VERBOSE] - Exporting function 'Unregister-ScheduledTask'.
2021-11-05 01:23:30,481 [VERBOSE] - Importing function 'Get-ScheduledTask'.
2021-11-05 01:23:30,481 [VERBOSE] - Importing function 'Unregister-ScheduledTask'.
2021-11-05 01:23:30,481 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ScheduledTask_v1.0.cdxml'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Disable-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Enable-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Export-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Get-ScheduledTaskInfo'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'New-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'New-ScheduledTaskAction'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Register-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Set-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Start-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Exporting function 'Stop-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Disable-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Enable-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Export-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Get-ScheduledTaskInfo'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'New-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'New-ScheduledTaskAction'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Register-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Set-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Start-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Importing function 'Stop-ScheduledTask'.
2021-11-05 01:23:30,545 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ClusteredScheduledTask_v1.0.cdxml'.
2021-11-05 01:23:30,575 [VERBOSE] - Exporting function 'Get-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Exporting function 'Register-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Exporting function 'Set-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Exporting function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Importing function 'Get-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Importing function 'Register-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Importing function 'Set-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Importing function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:23:30,575 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSScheduledJob\PSScheduledJob.psd1'.
2021-11-05 01:23:30,591 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSScheduledJob\PSScheduledJob.types.ps1xml'.
2021-11-05 01:23:30,591 [VERBOSE] - Loading 'FormatsToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSScheduledJob\PSScheduledJob.Format.ps1xml'.
2021-11-05 01:23:30,795 [ERROR  ] - Value cannot be null.
Parameter name: source
at <ScriptBlock>, <No file>: line 1
2021-11-05 01:23:30,795 [DEBUG  ] - Chocolatey PowerShell agent exited with '1'.

Sample log on Server 2019 system:

2021-11-05 01:24:11,714 [DEBUG  ] - Calling Chocolatey PowerShell agent (tag: '197')
2021-11-05 01:24:11,714 [DEBUG  ] -  Running the following (may differ slightly from provided):
2021-11-05 01:24:11,714 [DEBUG  ] - 
-----------
Import-Module ScheduledTasks
-----------

2021-11-05 01:24:11,980 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\ScheduledTasks.psd1'.
2021-11-05 01:24:11,996 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask.types.ps1xml'.
2021-11-05 01:24:11,996 [VERBOSE] - Loading 'TypesToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ScheduledTask.types.ps1xml'.
2021-11-05 01:24:11,996 [VERBOSE] - Loading 'FormatsToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask.format.ps1xml'.
2021-11-05 01:24:12,012 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\MSFT_ScheduledTask_v1.0.cdxml'.
2021-11-05 01:24:12,106 [VERBOSE] - Exporting function 'Get-ScheduledTask'.
2021-11-05 01:24:12,106 [VERBOSE] - Exporting function 'Unregister-ScheduledTask'.
2021-11-05 01:24:12,106 [VERBOSE] - Importing function 'Get-ScheduledTask'.
2021-11-05 01:24:12,106 [VERBOSE] - Importing function 'Unregister-ScheduledTask'.
2021-11-05 01:24:12,106 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ScheduledTask_v1.0.cdxml'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Disable-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Enable-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Export-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Get-ScheduledTaskInfo'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'New-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'New-ScheduledTaskAction'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'New-ScheduledTaskTrigger'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Register-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Set-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Start-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Exporting function 'Stop-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Disable-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Enable-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Export-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Get-ScheduledTaskInfo'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'New-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'New-ScheduledTaskAction'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'New-ScheduledTaskTrigger'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Register-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Set-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Start-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Importing function 'Stop-ScheduledTask'.
2021-11-05 01:24:12,154 [VERBOSE] - Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ScheduledTasks\PS_ClusteredScheduledTask_v1.0.cdxml'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Get-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Register-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Set-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Get-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Register-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Set-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Get-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Unregister-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Disable-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Enable-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Export-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Get-ScheduledTaskInfo'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'New-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'New-ScheduledTaskAction'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'New-ScheduledTaskTrigger'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Register-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Set-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Start-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Stop-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Get-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Register-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Set-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Exporting function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Disable-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Enable-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Export-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Get-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Get-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Get-ScheduledTaskInfo'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'New-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'New-ScheduledTaskAction'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'New-ScheduledTaskPrincipal'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'New-ScheduledTaskSettingsSet'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'New-ScheduledTaskTrigger'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Register-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Register-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Set-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Set-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Start-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Stop-ScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Unregister-ClusteredScheduledTask'.
2021-11-05 01:24:12,185 [VERBOSE] - Importing function 'Unregister-ScheduledTask'.
2021-11-05 01:24:12,200 [DEBUG  ] - Chocolatey PowerShell agent exited with '0'.

┆Issue is synchronized with this Gitlab issue by Unito