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

Comments

Projects
None yet
2 participants
@seizste
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 from Get-DscConfiguration returns an error for xSQLServerRole DscRessource to xSQLServerRole: Returns an error when calling Get-DscConfiguration Sep 1, 2017

@johlju

This comment has been minimized.

Show comment
Hide comment
@johlju

johlju Sep 1, 2017

Collaborator

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

Collaborator

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

@seizste

This comment has been minimized.

Show comment
Hide comment
@seizste

seizste Sep 5, 2017

Contributor

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

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

Contributor

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()

@seizste seizste referenced this issue Sep 5, 2017

Merged

xSQLServerRole: Fix for Issue #790 #791

5 of 5 tasks complete

@johlju johlju added in progress and removed help wanted labels Sep 5, 2017

@johlju johlju closed this in #791 Sep 7, 2017

johlju added a commit that referenced this issue Sep 7, 2017

xSQLServerRole: Fix for issue #790 (#791)
- 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 label Sep 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment