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

xSQLServerRole: Returns an error when calling Get-DscConfiguration #790

Closed
seizste opened this issue Aug 31, 2017 · 2 comments · Fixed by #791
Closed

xSQLServerRole: Returns an error when calling Get-DscConfiguration #790

seizste opened this issue Aug 31, 2017 · 2 comments · Fixed by #791
Labels
bug The issue is a bug.

Comments

@seizste
Copy link
Contributor

seizste commented Aug 31, 2017

xSQLServerRole DscRessource returns an error when running Get-DscConfiguration

Get-DscConfiguration : GetConfiguration did not succeed.

Event Log give some more details

Message Unable to cast object of type 'System.String' to type 'System.Collections.IList'.
Parameter name: value

Implicitly casting Return Value to a String Array fixes this issue, but there's probably a better way to do this.

$returnValue = @{
    Ensure           = $ensure
    Members          = [System.String[]]$membersInRole
    MembersToInclude = [System.String[]]$MembersToInclude
    MembersToExclude = [System.String[]]$MembersToExclude
    ServerRoleName   = $ServerRoleName
    SQLServer        = $SQLServer
    SQLInstanceName  = $SQLInstanceName
}
@johlju johlju changed the title Get-DscConfiguration returns an error for xSQLServerRole DscRessource xSQLServerRole: Returns an error when calling Get-DscConfiguration Sep 1, 2017
@johlju
Copy link
Member

johlju commented Sep 1, 2017

Does this only happen when there is only one member in the group? If so, then $membersInRole is cast to a [System.String] instead of [System.String[]].
Because the other two are already typed to arrays in the parameter declaration.

If so it should suffice to make sure this line always cast to a [System.String[]].

https://github.com/PowerShell/xSQLServer/blob/375ead160420c2f9cb262609a825370887b7fcee/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1#L70

@johlju johlju added bug The issue is a bug. easy fix help wanted The issue is up for grabs for anyone in the community. labels Sep 1, 2017
@seizste
Copy link
Contributor Author

seizste commented Sep 5, 2017

Still get an error even if adding multiple Groups to MembersToInclude but your suggested fix works ...

[System.String[]]$membersInRole = $sqlServerRoleObject.EnumMemberNames()

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Sep 5, 2017
johlju pushed a commit that referenced this issue Sep 7, 2017
- Changes to xSQLServerRole
  - Running Get-DscConfiguration no longer throws an error saying property
    Members is not an array (issue #790).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants