Tag: Reporting

PS: List Exchange Mailbox’s with Out of Office Enabled

PS: List Exchange Mailbox’s with Out of Office Enabled

The below snippet will produce a quick table showing users with Out of office enabled

Get-Mailbox -ResultSize Unlimited | Get-MailboxAutoReplyConfiguration | Where-Object { $_.AutoReplyState -ne "Disabled" } | Select Identity,StartTime,EndTime,AutoReplyState
Advertisements
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

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
PowerCLI: SAN Usage Report

PowerCLI: SAN Usage Report

 

Okay, today I have been tasked to find out where all of our storage has gone and because this SAN LUN is shared between a multiple of systems I have decided to generate the report based on Folder size within the LUN. Please see below for the script to run from PowerCLI

$searchSpec1 = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
$searchSpec1.details = New-Object VMware.Vim.FileQueryFlags
$searchSpec1.details.fileSize = $true
$searchSpec1.query += New-Object VMware.Vim.FolderFileQuery
$searchSpec2 = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
$searchSpec2.details = New-Object VMware.Vim.FileQueryFlags
$searchSpec2.details.fileSize = $true
$searchSpec2.query += New-Object VMware.Vim.FileQuery
$report = @()
Get-Datastore | Get-View | % {
$browser = Get-View -Id ($_.Browser)
$dsPath = "[" + $_.Summary.Name + "] /"
$folderList = $browser.SearchDatastore($dsPath, $searchSpec1)foreach($folder in $folderList.File){
$folderPath = $dsPath + $folder.Path
$fldresult = $browser.SearchDatastore($folderPath, $searchSpec2)
$fldSize = 0
foreach($file in $fldresult.File){$fldSize += $file.FileSize}
$row = "" | select DSName, FolderName, FolderSize
$row.DSName = $folderList.FolderPath
$row.FolderName = $folder.Path
$row.FolderSize = $fldSize
$report += $row
}
}
$report | Export-Csv "c:\powershell\Foldersize.csv" -noTypeInformation

Once you have harvested your CSV import it into excel and use the following on the custom format for file size

[<500000]#,##0" B ";[<500000000]#,##0,," MB";#,##0,,," GB"