I have created the following script:<\/p>\n
$Mailboxes = Get-Mailbox -Filter {Alias -notlike \"*.onmicrosoft.com\"} | Select-Object -Property displayname\n$Mailboxes | sort | get-unique > $HOME\\Desktop\\Missing_Domain.txt\n<\/code><\/pre>\n
Advertisement
I am trying to create a script that will show all mailboxes in exchange without certain alias. This will be used to create a script that will add the alias on to each of the mailboxes. This is for a migration from exchange to Office 365.<\/p>\n
Advertisement
the script to add everything looks like:<\/p>\n
$Mailboxes = Get-Mailbox -Filter {Alias -notlike \"*onmicrosoft.com\"} | Select-Object -Property displayname\n$Mailboxes | sort | get-unique > $HOME\\Desktop\\Missing_Domain.txt\n\n$MissingDomain = Get-Content $HOME\\Desktop\\Missing_Domain.txt\n\nForEach ($MisDom in $MissingDomain) {\n \n $email = Get-Mailbox $MisDom | Select-Object -Property PrimarySmtpAddress\n\n $parts = $email.split(\"@\")\n $parts[0] | Out-File $HOME\\Desktop\\output.txt -Append\n\n Set-Mailbox $MisDom -EmailAddresses @{add= $parts[0] + \"@xxx.onmicrosoft.com\"}\n}\n<\/code><\/pre>\nIf you have any advice, have done this previously, or know that something in my scripts are incorrect. please let me know.<\/p>","upvoteCount":5,"answerCount":7,"datePublished":"2019-06-19T14:49:04.000Z","author":{"@type":"Person","name":"firemixtap3","url":"https://community.spiceworks.com/u/firemixtap3"},"suggestedAnswer":[{"@type":"Answer","text":"
I have created the following script:<\/p>\n
$Mailboxes = Get-Mailbox -Filter {Alias -notlike \"*.onmicrosoft.com\"} | Select-Object -Property displayname\n$Mailboxes | sort | get-unique > $HOME\\Desktop\\Missing_Domain.txt\n<\/code><\/pre>\nI am trying to create a script that will show all mailboxes in exchange without certain alias. This will be used to create a script that will add the alias on to each of the mailboxes. This is for a migration from exchange to Office 365.<\/p>\n
the script to add everything looks like:<\/p>\n
$Mailboxes = Get-Mailbox -Filter {Alias -notlike \"*onmicrosoft.com\"} | Select-Object -Property displayname\n$Mailboxes | sort | get-unique > $HOME\\Desktop\\Missing_Domain.txt\n\n$MissingDomain = Get-Content $HOME\\Desktop\\Missing_Domain.txt\n\nForEach ($MisDom in $MissingDomain) {\n \n $email = Get-Mailbox $MisDom | Select-Object -Property PrimarySmtpAddress\n\n $parts = $email.split(\"@\")\n $parts[0] | Out-File $HOME\\Desktop\\output.txt -Append\n\n Set-Mailbox $MisDom -EmailAddresses @{add= $parts[0] + \"@xxx.onmicrosoft.com\"}\n}\n<\/code><\/pre>\nIf you have any advice, have done this previously, or know that something in my scripts are incorrect. please let me know.<\/p>","upvoteCount":5,"datePublished":"2019-06-19T14:49:04.000Z","url":"https://community.spiceworks.com/t/finding-all-users-without-a-specific-alias/717135/1","author":{"@type":"Person","name":"firemixtap3","url":"https://community.spiceworks.com/u/firemixtap3"}},{"@type":"Answer","text":"
Welcome!<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n