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

Cannot Mock Get-ADGroup #294

Closed
ephracis opened this issue Mar 19, 2015 · 3 comments · Fixed by #295
Closed

Cannot Mock Get-ADGroup #294

ephracis opened this issue Mar 19, 2015 · 3 comments · Fixed by #295

Comments

@ephracis
Copy link

The following code fails for me:

Describe "Mock" {
  It "Should mock Get-ADGroup" {
    Mock Get-ADGroup
    Get-ADGroup "Test"
  }
}

It fails with the error:

Cannot retrieve the dynamic parameters for the cmdlet.

I am running Pester 3.3.5 on PowerShell 3.0 on Windows 7.

@dlwyatt
Copy link
Member

dlwyatt commented Mar 19, 2015

Hmm, it worked for me when I ran that code on my system, but that's PowerShell 5.0 on Windows 8.1. I'll see if I can reproduce it on a system similar to yours when I have time.

@ephracis
Copy link
Author

Thanks for the quick response. I can't give you the full error message since it's in a darknet but it seems to try to convert a Dictionary of ADPropertyValueCollection to a KeyValuePair of ADPropertyValueCollection.

@dlwyatt
Copy link
Member

dlwyatt commented Mar 20, 2015

Well, the good news is that I was able to reproduce it, and blindly stumble over a fix. I can even tell you more or less why I didn't see the problem on my Windows 8.1 system: the AD module changed quite a bit in that version of the RSAT tools, and the object returned by the AD cmdlets' GetDynamicParameters() methods no longer implements any interfaces (including IEnumerable, which was part of the problem.)

Beyond that, I'm scratching my head. I'm not sure why this exception came up, even with the goofy old AD module code. Seems like it should have worked, but oh well, we can work around it.

dlwyatt added a commit to dlwyatt/Pester that referenced this issue Mar 20, 2015
Weird ActiveDirectory module is weird.

Fixes pester#294.  There are no automated tests to verify this yet; we either need to run the test on a 2008 R2 system with the RSAT feature installed, or write some C# code to reproduce the behavior of the AD module.  (The latter would be preferable, but will take some more time.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants