Forum Discussion
Use cmdlet output as variables for next cmdlet
- Mar 23, 2022I think the "| ft -hidetableheaders UserPrincipalName" is something you shouldn't use. Run it without that and try
$Var1 | foreach-object {
set-mailbox -identity $_.UserPrincipalName -customattribute1 "Some_Text"
}
If that doesn't work, just run $var1 to show us the contents of that
$Var1 | foreach-object {
set-mailbox -identity $_.UserPrincipalName -customattribute1 "Some_Text"
}
If that doesn't work, just run $var1 to show us the contents of that
- ShawnEGMar 23, 2022Copper Contributor
When I run it with "| ft -hidetableheaders UserPrincipalName" it spits out a list of email addresses, e.g,Email address removedEmail address removedWhen I remove the "ft" portion it spits out all the info for each mailbox, e.g.ObjectId DisplayName UserPrincipalName UserType-------- ----------- ----------------- --------abc123def-ab12-12ab-34cd-efghijk Patrick Star Email address removed MemberWhen I try to add the customattribute I get massive error codes for each line item. The beginning of each error code starts with:Cannot process argument transformation on parameter 'Identity'. Cannot convert value "class User {DeletionTimestamp:EDIT: NEVERMIND! It worked. I didn't catch the $_.UserPrincipalName at first. After I replied I noticed it and tried again. It worked. Thank you very much!!!
- Mar 23, 2022😁 No problem, glad to help