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

BREAKING CHANGE: New Scope property breaks DSC Resource #14

Closed
jpogran opened this issue Feb 6, 2018 · 9 comments

Comments

Projects
None yet
6 participants
@jpogran
Copy link

commented Feb 6, 2018

Commit cacd235 added the Scope property to the xPowerShellExecutionPolicy DSC Resource, however according to the DMTF specification (page 37) Scope is a reserved keyword, and results in this DSC Resource being unusable. This change also prevents us from including this release in the Puppet dsc module. I replicated this on PowerShell 5.1 on a fresh machine, with a Install-Module -Name xPowerShellExecutionPolicy using the PowerShellGallery feed, which pulls down version 2.0.0.0.

Attempting to use the DSC Resource results in a failure to find it:

PS C:\> Invoke-DscResource -Name xPowerShellExecutionPolicy -Property @{ ExecutionPolicy = 'RemoteSigned' } -Verbose -Method Test -ModuleName xPowerShellExecutionPolicy
Invoke-DscResource : Resource xPowerShellExecutionPolicy was not found as one of the builtin resources. Please add -ModuleName
parameter to include external resources.
At line:1 char:1
+ Invoke-DscResource -Name xPowerShellExecutionPolicy -Property @{ Exec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-DscResource], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.InvokeDscResourceMethod
   Command

This is because it fails parsing with the syntax error from usage of the word scope:

PS C:\> Get-DscResource
ImportCimAndScriptKeywordsFromModule : Cim deserializer threw an error when deserializing file C:\Program Files\Windows
PowerShell\Modules\xPowerShellExecutionPolicy\2.0.0.0\DSCResources\MSFT_xPowerShellExecutionPolicy\MSFT_xPowerShellExec
utionPolicy.Schema.mof.
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:4143
char:29
+ ...     $null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resour ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], PSInvalidOperationException
    + FullyQualifiedErrorId : System.Management.Automation.PSInvalidOperationException,ImportCimAndScriptKeywordsFromM
   odule

ImportCimAndScriptKeywordsFromModule : Syntax error:
 At line:6, char:276
 Buffer:
erPolicy"}] String Scope^;
};
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:4143
char:29
+ ...     $null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resour ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], CimException
    + FullyQualifiedErrorId : Microsoft.Management.Infrastructure.CimException,ImportCimAndScriptKeywordsFromModule

The fix would be to choose a different name for the Scope property, something like ScopeLevel or ExecutionPolicyScope. I can put up a PR to fix that, but wanted to ask first what name to use.

@michaeltlombardi

This comment has been minimized.

Copy link

commented Feb 6, 2018

#9 is also impacted by this.

jpogran added a commit to jpogran/puppetlabs-dsc that referenced this issue Feb 7, 2018

(maint) Pin xPowerShellExecutionPolicy to v1.1.0.0
This commit pins xPowerShellExecutionPolicy because of PowerShell/xPowerShellExecutionPolicy#14
@TraGicCode

This comment has been minimized.

Copy link
Contributor

commented Feb 19, 2018

I was able to verify this was broken as well. ScopeLevel seems reasonable to me.

/cc @kwirkykat

@zjalexander

This comment has been minimized.

Copy link

commented Feb 20, 2018

@MattAllison

This comment has been minimized.

Copy link

commented Apr 23, 2018

I know I'm late to the party but I just hit this bug. Recommend "PolicyScope" or "ExecutionPolicyScope" as the parameter name. May be more intuitive than ScopeLevel.

@johlju

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2018

@MattAllison Never to late to come with suggestions! @TraGicCode is working on this in PR #15. @TraGicCode what is you opinion about @MattAllison's proposal?

@TraGicCode

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2018

I'm okay with the recommendation. No problem on my end with changing this. I'm in favor of long names so i shall pick ExecutionPolicyScope :). Sound good @MattAllison ?

@johlju

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2018

@TraGicCode we are three in favor of 'ExecutionPolicyScope' so I propose we go with that. 😃

@MattAllison

This comment has been minimized.

Copy link

commented Apr 25, 2018

I'm good with the verbose parameter name. Thank you!

@TraGicCode

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2018

I will work on this now.

@johlju johlju changed the title New Scope property breaks DSC Resource BREAKING CHANGE: New Scope property breaks DSC Resource Apr 26, 2018

@johlju johlju closed this in #15 May 4, 2018

johlju added a commit that referenced this issue May 4, 2018

BREAKING CHANGE: Rename Scope to ExecutionPolicyScope (#15)
- BREAKING CHANGE: Renamed the 'Scope' Parameter to 'ExecutionPolicyScope' since
  errors are thrown when the MOF file is parsed because 'Scope' is a reserved
  keyword in the DMTF Specification (issue #14).

@johlju johlju removed the in progress label May 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.