Merge-Object
A function to merge or join two objects. For example, to merge an entry from “Get-MailboxStatistics” with information about storage limits set on the account in Active Directory. This small function demonstrates how the Property members of two objects might be merged. Common properties on the additional object are discarded.
Function Merge-Object($Base, $Additional) {
ForEach ($Property in $($Additional | Get-Member -Type Property, NoteProperty))
{
$Base | Add-Member -MemberType NoteProperty -Name $Property.Name `
-Value $Additional.$($Property.Name) -ErrorAction SilentlyContinue
}
Return $Base
}
Usage example
$MailboxStats = Get-MailboxStatistics "Chris Dent" $UserInfo = Get-QADUser "Chris Dent" ` -IncludedProperties mDBUseDefaults, mDBOverQuotaLimit | ` Select-Object DN, mDBUseDefaults, mDBOverQuotaLimit Merge-Object $MailboxStats $UserInfo
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
Respond to this post