Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsc resource list with --adapter flag returns with Exit code 1 #714

Closed
3 tasks done
lescx opened this issue Mar 19, 2025 · 5 comments · Fixed by #715
Closed
3 tasks done

dsc resource list with --adapter flag returns with Exit code 1 #714

lescx opened this issue Mar 19, 2025 · 5 comments · Fixed by #715
Assignees
Labels
Issue-Bug Something isn't working Need-Review

Comments

@lescx
Copy link

lescx commented Mar 19, 2025

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

I am completely new to DSC and pretty new to Windows so please be kind if I'm missing something pretty obvious. I try my best.

Following the PowerShell team Getting Started devblog post, I'm experiencing the following issue:

dsc resource list --adapter Microsoft.Windows/WindowsPowerShell

2025-03-19T18:48:53.191333Z  WARN Command: Resource 'powershell' [Exit code 1] manifest description: Error

Type  Kind  Version  Caps  RequireAdapter  Description
------------------------------------------------------

I saw the error message with pwsh instead of powershell in #639 which links to #539

I'm working on a freshly installed Windows 11 Enterprise VM with DSC installed via winget:

winget list --id microsoft.dsc.preview

Name                              Id                    Version  Source
------------------------------------------------------------------------
DesiredStateConfiguration-Preview Microsoft.DSC.Preview 3.0.12.0 winget

I saw the same issue on the stable release but switched to the preview version to see if it has been fixed.

Get-ExecutionPolicy

RemoteSigned

Recursively calling Unblock-File did not seem to help me here:

PS C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe> Get-ChildItem -Recurse -File -Path .\psDscAdapter | Unblock-File

PS C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe> dsc resource list --adapter Microsoft.Windows/WindowsPowerShell
2025-03-19T19:03:30.991589Z  WARN Command: Resource 'powershell' [Exit code 1] manifest description: Error

Type  Kind  Version  Caps  RequireAdapter  Description
------------------------------------------------------

Not sure if this would be even required. Am I missing something?

Steps to reproduce

dsc --trace-level trace resource list --adapter Microsoft.Windows/WindowsPowerShell

2025-03-19T18:56:43.985507Z  INFO dsc::util: 416: Trace-level is Trace
2025-03-19T18:56:43.986206Z DEBUG dsc: 38: Running dsc 3.0.0-preview.12
2025-03-19T18:56:43.986822Z TRACE dsc_lib::discovery::command_discovery: 362: Listing resources with type_name_filter '*' and adapter_name_filter 'Microsoft.Windows/WindowsPowerShell'
2025-03-19T18:56:43.987211Z  INFO dsc_lib::discovery::command_discovery: 170: Discovering resources using filter: *
2025-03-19T18:56:43.987598Z DEBUG dsc_lib::discovery::command_discovery: 173: Using regex ^.*?$ as filter for adapter name
2025-03-19T18:56:43.991386Z DEBUG dsc_lib::util: 88: Found setting 'resourcePath' in C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\dsc_default.settings.json
2025-03-19T18:56:43.993291Z DEBUG dsc_lib::util: 98: Found setting 'resourcePath' in C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\dsc.settings.json
2025-03-19T18:56:43.993951Z DEBUG dsc_lib::util: 112: Did not find setting 'resourcePath' in C:\ProgramData\dsc\dsc.settings.json
2025-03-19T18:56:43.994635Z DEBUG dsc_lib::discovery::command_discovery: 119: Appending PATH to resourcePath
2025-03-19T18:56:43.995238Z TRACE dsc_lib::discovery::command_discovery: 122: Original PATH: "C:\\Program Files\\PowerShell\\7;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Microsoft.DSC_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\\Users\\Desired Mage\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
2025-03-19T18:56:43.995896Z TRACE dsc_lib::discovery::command_discovery: 143: Adding exe home to path: C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe
2025-03-19T18:56:43.996535Z DEBUG dsc_lib::discovery::command_discovery: 154: Using Resource Path: "C:\\Program Files\\PowerShell\\7;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Microsoft.DSC_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\\Users\\Desired Mage\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe"
2025-03-19T18:56:44.452688Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\assertion.dsc.resource.json"
2025-03-19T18:56:44.454712Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.DSC/Assertion' found
2025-03-19T18:56:44.469283Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\echo.dsc.resource.json"
2025-03-19T18:56:44.470817Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.DSC.Debug/Echo' found
2025-03-19T18:56:44.472464Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\group.dsc.resource.json"
2025-03-19T18:56:44.473862Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.DSC/Group' found
2025-03-19T18:56:44.474587Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\osinfo.dsc.resource.json"
2025-03-19T18:56:44.476528Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft/OSInfo' found
2025-03-19T18:56:44.477754Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\powershell.dsc.resource.json"
2025-03-19T18:56:44.478628Z TRACE dsc_lib::discovery::command_discovery: 227: Resource adapter 'Microsoft.DSC/PowerShell' found
2025-03-19T18:56:44.479412Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\reboot_pending.dsc.resource.json"
2025-03-19T18:56:44.480157Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.Windows/RebootPending' found
2025-03-19T18:56:44.481004Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\registry.dsc.resource.json"
2025-03-19T18:56:44.481779Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.Windows/Registry' found
2025-03-19T18:56:44.482751Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\RunCommandOnSet.dsc.resource.json"
2025-03-19T18:56:44.483390Z TRACE dsc_lib::discovery::command_discovery: 230: Resource 'Microsoft.DSC.Transitional/RunCommandOnSet' found
2025-03-19T18:56:44.484350Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\windowspowershell.dsc.resource.json"
2025-03-19T18:56:44.484940Z TRACE dsc_lib::discovery::command_discovery: 227: Resource adapter 'Microsoft.Windows/WindowsPowerShell' found
2025-03-19T18:56:44.485698Z TRACE dsc_lib::discovery::command_discovery: 209: Found resource manifest: "C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\\wmi.dsc.resource.json"
2025-03-19T18:56:44.486448Z TRACE dsc_lib::discovery::command_discovery: 227: Resource adapter 'Microsoft.Windows/WMI' found
2025-03-19T18:56:44.487771Z DEBUG dsc_lib::discovery::command_discovery: 241: Found 7 matching non-adapter-based resources
2025-03-19T18:56:44.497861Z DEBUG dsc_lib::discovery::command_discovery: 257: Using regex ^Microsoft\.Windows/WindowsPowerShell$ as filter for adapter name
2025-03-19T18:56:44.499218Z DEBUG dsc_lib::discovery::command_discovery: 265: Using regex ^.*?$ as filter for resource name
2025-03-19T18:56:44.500503Z  INFO dsc_lib::discovery::command_discovery: 289: Enumerating resources for adapter 'Microsoft.Windows/WindowsPowerShell'
2025-03-19T18:56:44.501834Z DEBUG dsc_lib::dscresources::command_resource: 663: Invoking command 'powershell' with args Some(["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", "./psDscAdapter/powershell.resource.ps1 List"])
2025-03-19T18:56:45.511165Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360: ./psDscAdapter/powershell.resource.ps1 : File C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\psDscAdapter\powershell.resource.ps1 cannot be loaded because running scripts is disabled on this system. For more
2025-03-19T18:56:45.512496Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360: information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
2025-03-19T18:56:45.513326Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360: At line:1 char:1
2025-03-19T18:56:45.513788Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360: + ./psDscAdapter/powershell.resource.ps1 List
2025-03-19T18:56:45.514420Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-03-19T18:56:45.515064Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360:     + CategoryInfo          : SecurityError: (:) [], PSSecurityException
2025-03-19T18:56:45.515651Z TRACE dsc_lib::dscresources::command_resource: 871: PID 2360:     + FullyQualifiedErrorId : UnauthorizedAccess
2025-03-19T18:56:45.542762Z DEBUG dsc_lib::dscresources::command_resource: 624: Process 'powershell' id 2360 exited with code 1
2025-03-19T18:56:45.544118Z  WARN dsc_lib::discovery::command_discovery: 314: Command: Resource 'powershell' [Exit code 1] manifest description: Error
2025-03-19T18:56:45.546756Z DEBUG dsc_lib::discovery::command_discovery: 661: Read 0 items into lookup table from "C:\\Users\\Desired Mage\\AppData\\Local\\dsc\\AdaptedResourcesLookupTable.json"

Expected behavior

dsc resource list --adapter Microsoft.Windows/WindowsPowerShell

Type                                                   Kind      Version   Caps      RequireAdapter                       Description
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PSDesiredStateConfiguration/Archive                    Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Environment                Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/File                       Resource  1.0.0     gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Group                      Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/GroupSet                   Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Log                        Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Package                    Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/ProcessSet                 Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Registry                   Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Script                     Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Service                    Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/ServiceSet                 Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/SignatureValidation        Resource  1.0.0     gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/User                       Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WaitForAll                 Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WaitForAny                 Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WaitForSome                Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsFeature             Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsFeatureSet          Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsOptionalFeature     Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsOptionalFeatureSet  Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsPackageCab          Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/WindowsProcess             Resource  1.1       gs--t---  Microsoft.Windows/WindowsPowerShell
PSDscResources/Archive                                 Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/Environment                             Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/Group                                   Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/MsiPackage                              Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/Registry                                Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/Script                                  Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/Service                                 Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/User                                    Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/WindowsFeature                          Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/WindowsOptionalFeature                  Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/WindowsPackageCab                       Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.
PSDscResources/WindowsProcess                          Resource  2.12.0.0  gs--t---  Microsoft.Windows/WindowsPowerShell  This module contains the standard DSC resources.

Actual behavior

dsc --trace-level debug resource list --adapter Microsoft.Windows/WindowsPowerShell

2025-03-19T18:39:11.922427Z  INFO dsc::util: 416: Trace-level is Debug
2025-03-19T18:39:11.923154Z DEBUG dsc: 38: Running dsc 3.0.0-preview.12
2025-03-19T18:39:11.924180Z  INFO dsc_lib::discovery::command_discovery: 170: Discovering resources using filter: *
2025-03-19T18:39:11.926815Z DEBUG dsc_lib::discovery::command_discovery: 173: Using regex ^.*?$ as filter for adapter name
2025-03-19T18:39:11.928149Z DEBUG dsc_lib::util: 88: Found setting 'resourcePath' in C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\dsc_default.settings.json
2025-03-19T18:39:11.928869Z DEBUG dsc_lib::util: 98: Found setting 'resourcePath' in C:\Program Files\WindowsApps\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe\dsc.settings.json
2025-03-19T18:39:11.929948Z DEBUG dsc_lib::util: 112: Did not find setting 'resourcePath' in C:\ProgramData\dsc\dsc.settings.json
2025-03-19T18:39:11.930591Z DEBUG dsc_lib::discovery::command_discovery: 119: Appending PATH to resourcePath
2025-03-19T18:39:11.931288Z DEBUG dsc_lib::discovery::command_discovery: 154: Using Resource Path: "C:\\Program Files\\PowerShell\\7;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Desired Mage\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Microsoft.DSC_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\\Users\\Desired Mage\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\WindowsApps\\Microsoft.DesiredStateConfiguration-Preview_3.0.12.0_x64__8wekyb3d8bbwe"
2025-03-19T18:39:12.346213Z DEBUG dsc_lib::discovery::command_discovery: 241: Found 7 matching non-adapter-based resources
2025-03-19T18:39:12.347609Z DEBUG dsc_lib::discovery::command_discovery: 257: Using regex ^Microsoft\.Windows/WindowsPowerShell$ as filter for adapter name
2025-03-19T18:39:12.350723Z DEBUG dsc_lib::discovery::command_discovery: 265: Using regex ^.*?$ as filter for resource name
2025-03-19T18:39:12.351847Z  INFO dsc_lib::discovery::command_discovery: 289: Enumerating resources for adapter 'Microsoft.Windows/WindowsPowerShell'
2025-03-19T18:39:12.353158Z DEBUG dsc_lib::dscresources::command_resource: 663: Invoking command 'powershell' with args Some(["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", "./psDscAdapter/powershell.resource.ps1 List"])
2025-03-19T18:39:13.318082Z DEBUG dsc_lib::dscresources::command_resource: 624: Process 'powershell' id 6520 exited with code 1
2025-03-19T18:39:13.319220Z  WARN dsc_lib::discovery::command_discovery: 314: Command: Resource 'powershell' [Exit code 1] manifest description: Error
2025-03-19T18:39:13.320763Z DEBUG dsc_lib::discovery::command_discovery: 661: Read 0 items into lookup table from "C:\\Users\\Desired Mage\\AppData\\Local\\dsc\\AdaptedResourcesLookupTable.json"

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

3.0.0-preview.12

Visuals

No response

@lescx lescx added Issue-Bug Something isn't working Need-Review labels Mar 19, 2025
@lescx lescx changed the title dsc resource list with --adapter flag returns powershell with Exit code 1 dsc resource list with --adapter flag returns with Exit code 1 Mar 19, 2025
@Gijsreyn
Copy link
Contributor

So basically it is a bit hidden in the trace message @lescx and hasn't directly something to do with dsc. Instead, it is PowerShell:

cannot be loaded because running scripts is disabled on this system. For more ...

If you open a Windows PowerShell session and type in Set-ExecutionPolicy -ExecutionPolicy Bypass and try again, it should work. Do note, it is not a best practice to put it on Bypass.

@lescx
Copy link
Author

lescx commented Mar 19, 2025

Setting the ExecutionPolicy to bypass does indead remove the error

Set-ExecutionPolicy Bypass -Scope Process
dsc resource list --adapter Microsoft.Windows/WindowsPowerShell
                                                                                                                                                                                 
Type                                                   Kind      Version  Caps      RequireAdapter                       Description
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PSDesiredStateConfiguration/Archive                    Resource  1.1      gs--t---  Microsoft.Windows/WindowsPowerShell
PSDesiredStateConfiguration/Environment                Resource  1.1      gs--t---  Microsoft.Windows/WindowsPowerShell
...
  • but shouldn't the Powershell scripts be signed? Is there a "better" way to solve this issue without lowering the Execution Policy?

@Gijsreyn
Copy link
Contributor

I'm not 100% sure, but I think these scripts that are builtin, so the powershell.resource.ps1 are signed. That would mean you can change the scope. Just try it out, and you will probably find out the right scope :)

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Mar 20, 2025

You should set the execution policy to remotesigned or allsigned (by default, it's remotesigned on Windows Server and restricted on Windows client (meaning scripts can't run but individual commands can), although I wonder if we should consider specifying remotesigned when we call pwsh or powershell...

Actually, that won't work for CI or local testing since the script won't be signed until we release.

@SteveL-MSFT SteveL-MSFT self-assigned this Mar 20, 2025
@SteveL-MSFT
Copy link
Member

Discussed internally my proposal to explicitly set execution policy to bypass and that should be ok here as it does not override Group Policy if that is set for something more restrictive and dsc has some validation already and isn't running some arbitrary script, so will make this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Need-Review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants