Get all SMTP Address from Public Folders or Groups or anything in Exchange!

Here is a quick one, just change your mail domain where it says “MyDomain.com”

Public Folders Only:

Get-recipient -RecipientTypeDetails PublicFolder | select Name -ExpandProperty EmailAddresses | ? {$_.SMTPAddress -like “*MyDomain.com*”} | select Name, SMTPAddress

To pump to CSV:

Add this to the end: | Export-CSV C:\Filename.csv

Other  RecipientTypeDetails types? Just change the RecipientTypeDetails to one or more of the following (comma delimited):

  • MailUniversalDistributionGroup
  • MailUniversalSecurityGroup
  • DynamicDistributionGroup
  • MailNonUniversalGroup
  • MailUser
  • UserMailbox
  • PublicFolder
  • MailContact
  • DiscoveryMailbox
  • SharedMailbox
  • RoomMailbox

Set Processor Affinity with Powershell

Hey all I know its been far to long since my last post. I have been doing a lot of great things with powershell and I am going to start sharing them as they come up. Here was a helpful one this morning…

So the Backup Server is going nuts with these storageservice.exe processes consuming 100% of the CPU. It makes it very hard to troubleshoot when the server doesn’t have enough CPU to let the OS run.

image

Below is a script I just created that takes all of them and sets them to only use cores 1 – 4 (basically only allowing it 50% of the total CPU power.


# Set Processor Affinity by adding the number together. For cores 1 – 4 its 15 for example.
# 1 (CPU 1)
# 2 (CPU 2)
# 4 (CPU 3)
# 8 (CPU 4)
# 16 (CPU 5)
# 32 (CPU 6)
# 64 (CPU 7)
#128 (CPU 8 )

$instances = Get-Process storageservice
foreach ($i in $instances) {
    $i.ProcessorAffinity=15
}


Ah much better, now time to figure out why its going nuts….

image