Created
April 11, 2012 19:03
-
-
Save clly/2361440 to your computer and use it in GitHub Desktop.
Make XML configuration file for powershell based on properties of the .NET object entered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Make-Config($obj) { | |
$gm = $obj|Get-Member -MemberType Property | |
$config = "<?xml version='1.0'?> | |
<config> | |
<include> | |
</include> | |
<exclude> | |
" | |
foreach($prop in $gm) { | |
$config += "`t`t<add property='" + $prop.name + "' />`n" | |
} | |
$config += "</exclude> | |
</config>" | |
return $config | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
an example for using this would be getting an active directory user object and using it as an argument against this function. It would print out all the available properties in the object and make it available as a configuration file. Then all you would have to do is move or copy the properies from the exclude section to the include section to use them.