You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Powershell omits certain fields in foreach-object -parallel code block, for example Get-ADComputer correctly displays computer name in code block, but return empty string for any extra fields requested in Properties argument. When calling without -Parallel argument everything works as expected.
The Parallel parameter doesn't actually serialize anything since it's thread based instead of process based.
This is due to the ActiveDirectory module defining it's own PSPropertyAdapter and registering it on module import.
Paul Higinbotham (@PaulHigin) I know RunspaceFactory.CreateRunspace has some overloads that take a TypeTable. I'm guessing no, but is there a publicly accessible way to obtain the current TypeTable? Eh that's probably not feasible anyway without some method of removing things like script members.
somescout Yeah that should work. You said it's inconsistent, do you have an example that doesn't work? Or can otherwise elaborate? (I may be able to suggest a more consistent alternative if I know what doesn't work)
This is another consequence of the fact that each foreach -parallel loop iteration runspace is intialized (or reset) to its default state, rather than the state of the current runspace running the cmdlet.
I have created an Issue (#12240) to track this, and have linked this issue to that one.
Closing this issue.
Activity
SeeminglyScience commentedon Apr 1, 2020
The
Parallelparameter doesn't actually serialize anything since it's thread based instead of process based.This is due to the
ActiveDirectorymodule defining it's ownPSPropertyAdapterand registering it on module import.Paul Higinbotham (@PaulHigin) I know
RunspaceFactory.CreateRunspacehas some overloads that take aTypeTable. I'm guessing no, but is there a publicly accessible way to obtain the currentTypeTable? Eh that's probably not feasible anyway without some method of removing things like script members.somescout commentedon Apr 1, 2020
So basically I could use something like this, as workaround
It is working, but it's inconsistent.
SeeminglyScience commentedon Apr 1, 2020
somescout Yeah that should work. You said it's inconsistent, do you have an example that doesn't work? Or can otherwise elaborate? (I may be able to suggest a more consistent alternative if I know what doesn't work)
PaulHigin commentedon Apr 1, 2020
This is another consequence of the fact that each foreach -parallel loop iteration runspace is intialized (or reset) to its default state, rather than the state of the current runspace running the cmdlet.
I have created an Issue (#12240) to track this, and have linked this issue to that one.
Closing this issue.