Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

new object with the properties of another object

$
0
0

I’m trying to make a new object that has all the properties of three other objects. I’d like the new object’s property names to be prefaced by the other objects name. For example, If I have the object $ad (shown below) and it has the property “DisplayName”. I’d like to add a property to my new object with the property name ad_DisplayName and the value of course to be the value of the "DisplayName". I'm comfortable making objects and iterating with foreach-object, but I can't seem to figure this one out. I've tried some weird things with $ad | Get-Member -MemberType Property | ForEach-Object {$_.name}, where in the {} I begin to build the properties of my new object. But that's where things get weird and I get lost :(.

$ad = Get-QADUser -UserPrincipalName $UserUPN



Viewing all articles
Browse latest Browse all 2562

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>