This function retrieves the total size (in GB) of mailbox databases in Exchange Organization. There is an optional parameter to filter databases by part of name. When you specify a value for the Name attribute and no databases could be found, it retrieves 0.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Function Get-MailboxDatabaseTotalSize { param ([Parameter(Mandatory=$false, ValueFromPipeline=$false)][string]$DBPartName) $Databases = Get-MailboxDatabase -Status | Where-Object {$_.Name -ilike '*'+$DBPartName+'*'} foreach($Database in $Databases) { $RawDBSize = $Database.DatabaseSize $CounterDBTotalSize = $RawDBSize + $CounterDBTotalSize } try { $CounterDBTotalSize = "{0:n2}" -f ($CounterDBTotalSize.ToBytes() / 1GB) } catch { Write-Host "0" } Return $CounterDBTotalSize } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Mailbox $Mailbox = "Mail@domain.com" # Exchange server contains tracking logs - by default CAS $Serv = "exch01.domain.com" $Now = Get-Date $DayBack = (7,6,5,4,3,2,1) Write-Host $Mailbox" report" Write-Host "====================" foreach ($DayIndex in $DayBack) { $CT = $Now.AddDays(-$DayIndex) $CTDayOfWeek = (Get-Date($CT)).DayOfWeek $CTToDisplay = Get-Date($CT) -Format dd.MM.yyyy $CT = Get-Date($CT) -Format MM/dd/yyyy $CTStart = $CT+" 0:00:00AM" $CTEnd = $CT+" 23:59:59PM" $MailCount = (Get-MessageTrackingLog -Recipients $Mailbox -server $Serv -start $CTStart -end $CTEnd -ResultSize 99999 | Where-Object {$_.Source -ilike "*STORE*" -and $_.EventID -ilike "*DELIVER*" -and $_.Sender -inotlike "*MicrosoftExchange*"} | Select-Object -Unique InternalMessageId).count Write-Host $CTDayOfWeek $CTToDisplay": "$MailCount } |
Import-Module Lync
$LyncServer = "server1.domain.com"
$LogDatePartName = Get-Date -format 'yyyy_MM_dd'
$Log = "c:\scripts\"+$LogDatePartName+"_LyncEnabledUsers.csv"
get-csaduser | Where-Object {
$_.Enabled -ne $True -and
$_.WindowsEmailAddress -ne '' -and
$_.UserAccountControl -inotlike '*disabled*' -and
$_.DistinguishedName -inotlike '*impersonal*' -and
$_.IPPhone -ne ''
} | Select-Object UserPrincipalName | Export-Csv "$Log" -Delimiter ',' -NoTypeInformation
$LogSize = Get-ChildItem $Log
if ($LogSize.Length -ne '0') {
$UserFile = "$Log"
$MyData = Import-Csv $UserFile -Delimiter ','
ForEach ($item in $MyData){
$UserPrincipalName = $($item.UserPrincipalName)
Enable-CsUser $UserPrincipalName -RegistrarPool $LyncServer -SipAddressType EmailAddress
}
} else {
remove-item -path $Log -force
}