Forum Discussion
luanoprz
Jul 10, 2023Copper Contributor
Alias auslesen ohne Primäre Adresse
Hallo zusammen, ich möchte gerne die Alias Adressen einer Mailbox via PowerShell auslesen und in eine SharePoint Liste schreiben. Dabei sollen auch nur Aliase ausgelesen werden und nicht die prim...
kevkelly
Jul 13, 2023MCT
The following should get you just the aliases, without the smtp:
Get-Mailbox -Identity <mailbox_id> | Select-Object Identity, @{Name='AliasAddresses';Expression={($_.EmailAddresses | Where-Object {$_ -cmatch 'smtp'}) -replace 'smtp:', $null}}
luanoprz
Jul 13, 2023Copper Contributor
Das klappt schonmal - danke! Wie kann ich jetzt die Werte aus der Spalte AliasAdresses in eine Variable schreiben.
- kevkellyJul 13, 2023MCT
So there are multiple ways you could achieve this and it'll depend on the format of your SharePoint list, and how you're looking to store the aliases.
Are you looking to add the collection of all aliases for a single mailbox into a single list item, or does each alias need to be its own list item?
But to answer your question, you could assign the just the aliases to a variable doing something like:
$variable = Get-Mailbox -Identity <mailbox_id> | Select-Object Identity, @{Name='AliasAddresses';Expression={($_.EmailAddresses | Where-Object {$_ -cmatch 'smtp'}) -replace 'smtp:', $null}} | Select-Object -ExpandProperty AliasAddresses