Closed axelitus closed 3 years ago
Mmmmm I think I got it:
$msolUser | Merge-Object $azureADUser -Property @{ '*' = 'Left.*' }
Would this yield the result I am expecting? (I think so from the documentation of the Property parameter)
I reviewed the resulting object and it seems to e what I was looking for, so I'm going to close this issue.
Thanks for this great script!
Just to clarify, if I needed to replace the values (as I said before) from the object on the right I would do this:
$msolUser | Merge-Object $azureADUser -Property @{ '*' = 'Right.*' }
Hello @Axelitus,
I am sorry that I missed your issue (basically because you closed it yourself).
Please, let me know if the issue still exists.
In that case, it would help if you supply me with a Minimal, Reproducible Example, something like two csv
lists and what you would expect as an outcome.
btw, the Merge-Object
command already has the Property = @{ '*' = 'Right.*' }
as a default parameter, meaning that you might just have to swap the left and right object: $azureADUser | Merge-Object $msolUser
(and leave any parameter).
Hi, thanks for getting back to me.
I would think that it already has it properly configured looking at the line below, but when I don't put it in the call it does not work as intended (I'm not sure why, though. Maybe it's not recognizing the default parameter properly).
Copy-Command -Command $JoinCommand -Name Merge-Object -Default @{ JoinType = 'Full'; Property = @{ '*' = 'Right.*' } }; Set-Alias Merge Merge-Object
This command (summed up) works as I wanted:
$users = Get-MsolUser -UserPrincipalName $UserPrincipalName -ErrorAction Stop | Merge-Object (Get-AzureADUser -All $true -ErrorAction Stop) -On UserPrincipalName -Property @{ '*' = 'Left.*' }
Using does not work because of a conversion error as the ObjectId
properties on each object are of a different type:
Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ObjectId'. Specified method is not supported.
But that is not a problem of the merge-object function. I'm happy with the outcome so far, though. Thanks for the help and the brilliant code!
I've been using your script to join the results of Get-MsolUser and Get-AzureADUser.
The problem I am facing is that I want to merge all attributes from both sides, but replace the values of the ones that already exist in the left object, not create a merged entry with the values.
I would expect the object merger would yield an object with the following attributes instead: UserType: Member UsageLocation: MX Country: Mexico
Is this possible right now (I seem to have tested all command aliases without luck)? Or is there a way to define which attributes should be replaced instead of merged? If not, that would be a great feature for me.