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

FormatPx 1.0.0.1 does not work with the Microsoft AD cmdlets #2

Closed
KirkMunro opened this issue Jan 8, 2015 · 2 comments
Closed

FormatPx 1.0.0.1 does not work with the Microsoft AD cmdlets #2

KirkMunro opened this issue Jan 8, 2015 · 2 comments

Comments

@KirkMunro
Copy link
Owner

Issue reported via email from a FormatPx user:

I'm using your great FormatPx module (added to my profile), but I'm getting some errors when working with the Active Directory module. Here is an example when running Get-ADDomain:

Out-Default : Unable to cast object of type 'Microsoft.ActiveDirectory.Management.ADPropertyValueCollection' to type 'System.Collections.Generic.Stack`1[FormatPx.FormatRecord]'.
+ CategoryInfo : NotSpecified: (:) [Out-Default], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,FormatPx.OutDefaultCommand

Any thoughts?

@KirkMunro
Copy link
Owner Author

It turns out that the AD cmdlets provide their own "special" treatment on the PSObject Properties collection. For normal cmdlets, if you use the Properties indexer to check if a property is there or not, the indexer will simply return null for properties that do not exist. For AD objects returned by the Microsoft AD module, the indexer will return a property with a null value for properties that do not exist. Since there is no way to distinguish between a real property that exists but has a null value and a property that does not exist, a different mechanism must be used to determine if properties exist when working with objects returned from the Microsoft AD module.

The new logic is to check the type of the member that is returned from the indexer. If the member type is PSAdaptedPropertyInfo, then an additional check must be performed, using Linq with the enumerator to see if the property actually exists in the collection. If the type is not PSAdaptedPropertyInfo, then the old type check logic works just fine.

This issue has been fixed and it is included in release 1.0.1.2 of FormatPx.

@KirkMunro
Copy link
Owner Author

FYI if you tried this yesterday...turns out I missed a step in the release processing, so this didn't get properly posted as a release on GitHub until today. But I also pushed out release 1.0.2.3 today, so just update your module to that version and you'll have this fix plus another one that was reported and fixed today as well.

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

No branches or pull requests

1 participant