Skip to content

Instantly share code, notes, and snippets.

@clly
Created April 11, 2012 19:03
Show Gist options
  • Save clly/2361440 to your computer and use it in GitHub Desktop.
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
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
}
@clly
Copy link
Author

clly commented Apr 11, 2012

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.

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