PS: User Mailbox SMTP Alias Address Report

PS: User Mailbox SMTP Alias Address Report

Hi Everyone,

Here is a quick and dirty script that will produce a table within your terminal session showing you each user mailbox along with any additional SMTP addresses that are associated to each of the mailbox’s

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Collect Data from exchange and store into varible
$box = Get-Mailbox | Where {$_.name -NotLike ‘*DiscoverySearchMailbox*’} | Where-Object -Property RecipientType -eq -Value UserMailbox | select primarysmtpaddress,name,@{Name=”EmailAddresses”;Expression={ ($_.EmailAddresses | Where-Object {$_ -cmatch “s mtp:*”} | ForEach-Object {$_ -replace 'smtp:' }) -join ',' }}
# Perform Count of records in varible
$count = $box | measure
# Count Output
Write-Host "Result Count: " -NoNewline -ForegroundColor Green $count.Count
# Result Table Output
$box | ft -autosize

 


Old Code

$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session Get-Mailbox | Where {$_.name -NotLike ‘*DiscoverySearchMailbox*’} | Where-Object -Property RecipientType -eq -Value UserMailbox | select primarysmtpaddress,name,@{Name=”EmailAddresses”;Expression={ ($_.EmailAddresses | Where-Object {$_ -cmatch “s mtp:*”} | ForEach-Object {$_ -replace ‘smtp:’ }) -join ‘,’ }} | ft -AutoSize

Advertisements
PowerCLI: Search VM By MAC Address

PowerCLI: Search VM By MAC Address

The below snippet is pretty useful for when you have a mac address conflict between your VM’s. The VMware alarm/flag does not tell you the VM that it MAC conflicts with so time to open up PowerCLI and run the below example

 

Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq “00:59:59:c9:da:9a”} | select @{Name="VM";Expression={$_.Parent}},MacAddress | ft -AutoSize

 

PowerCLI: Memory Usage Report Script

PowerCLI: Memory Usage Report Script

The Below one liner will generate a CSV file containing the following

  • VM Host
  • VM Folder
  • VM Name
  • VM Memory Allocation
  • VM Memory Average Usage Last 30 Days
PowerCLI C:\> get-vm | Where {$_.PowerState -eq "PoweredOn"} | sort Name | Select-Object VMHost,Folder,Name,MemoryGB,@{N="Memory Usage (Average Over 30 Days), %" ; E={[Math]::Ro
und((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} | Format-Table -autosize -Property VMho
st,Folder,Name,MemoryGB,"Memory Usage (Average Over 30 Days), %" | Export-Csv C:\temp\MemoryUsage.CSV