Showing posts with label Office 2010. Show all posts
Showing posts with label Office 2010. Show all posts

Wednesday, June 11, 2014

PowerShell Script : Office 365 Mailbox Sizes and Mailbox Quotas Email Reporting.

 

Picture1

We all love office 365.

Especially I like the Exchange Online most.

On Exchange Online when we create any new mailboxes we do set the various storage limits on the user mailbox and we assign different mailbox size as per the user requirements or company policies.

Sometime, we need to know the reports of:

1.     How much mailbox space is assigned to the user?

2.     How much his currently mail box usage is.

3.     What is the name of mailbox database?

Monitoring and Reporting are the two key main areas in our IT industry. We should monitor our IT stuff and we should often generate and view the reports.

I have created this script to know about the mailbox status of my all Office 365 Exchange Online mailboxes and the current usage of them.  It also contains the information on, Users Last Login time , Log Off time, size of this issue warning quota limit and size of total deleted items.

How to run the script?

It’s simple.

1.     Configure, your SMTP server, TO, FROM, Subject filed in the script.

2.     Run the script

3.     It ask you for your Office 365 Administrator Credentials.

4.     After providing credential, it will send an HTML email to the provided TO email id.

That’s all J Simple. Isnt?

 

You can download the script from Technet Gallery : http://gallery.technet.microsoft.com/scriptcenter/Office-365-Mailbox-Sizes-92b94563

 

#==================| Satnaam Waheguru Ji |===============================   
#
# Author : Aman Dhally
# E-Mail : amandhally@gmail.com
# website : www.amandhally.net
# twitter : @AmanDhally
# blog : http://newdelhipowershellusergroup.blogspot.in/
# facebook: http://www.facebook.com/groups/254997707860848/
# Linkedin: http://www.linkedin.com/profile/view?id=23651495
#
# Creation Date : 03-June-2014
# File : Email Reporting on Office 365 mail Statictic
#
# Version : 3
#
#
# My Pet Spider : /^(o.o)^\
#

#------------------------------------------------------------------------------------------------------------


function Send-O365MailStats {



begin {

try {
Write-Output "$(get-date) : Script Start."
Write-Output "$(get-date) : Asking for Office365 Administrative Credentials."
$UserCredential = Get-Credential
Write-Output "$(get-date) : Creating a Online PS Session with Office 365."
$ouSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection -ErrorAction 'Stop' -ErrorVariable 'ConnectionError'
Write-Output "$(get-date) : Importing PS Session."
Import-PSSession $ouSession -AllowClobber -ErrorAction 'Stop' -ErrorVariable 'SessionError'
}

catch {
$ConnectionError
$SessionError

}
}


process {

try {
#Your SMTP sever
$smtp = 'YOUR EMAIL SERVER'
# To E-Mail Address
$to = 'AMANdhally@gmail.com'
# From E-Mail Address
$from = 'Scripter@YourDOMAIN.COM'
# Subject of the Email
$subject = 'Office 365 MailBox Stats Report'
#Empty Array String
$body2 = @()
#Just a Counter
$int = 1
#All Magic Done here
Write-Output "$(get-date) : Running the Get-Mailbox and Get-MailboxStatistics cmdlet"
$userList = Get-Mailbox -Filter " RecipientType -eq 'UserMailbox'" | Get-MailboxStatistics

#Processing
Write-Output "$(get-date) : Processing the Results."
foreach ( $user in $userList)
{
#$user | fl * -Force

$body2 += "<tr>"
$body2 += "<td>" + $int++ + "</td>"
$body2 += "<td>" + $user.DisplayName + "</td>"

#manuplating
$UserTa= $user.TotalItemSize.value.ToString().split(" ")[0]
$UserTb = $user.TotalItemSize.value.ToString().split(" ")[1]
$userTotalSize = $UserTa + " " + $UserTb

$body2 += "<td>" + $userTotalSize + "</td>"

$body2 += "<td>" + $user.LastLogonTime + "</td>"
$body2 += "<td>" + $user.LastLogoffTime + "</td>"
$body2 += "<td>" + $user.ServerName + "</td>"
$body2 += "<td>" + $user.DatabaseName + "</td>"

#Manuplating
$userDDLa = $user.TotalDeletedItemSize.value.ToString().split(" ")[0]
$userDDLb = $user.TotalDeletedItemSize.value.ToString().split(" ")[1]
$userDelted = $userDDLa + " " + $userDDLb

$body2 += "<td>" + $userDelted + "</td>"

#Manuplated
$userDBa = $user.DatabaseProhibitSendReceiveQuota.value.ToString().split(" ")[0]
$userDBb = $user.DatabaseProhibitSendReceiveQuota.value.ToString().split(" ")[1]
$userDBQuota = $userDBa + " " + $userDBb

$body2 += "<td>" + $userDBQuota + "</td>"

#Manuplating
$userWQa = $user.DatabaseIssueWarningQuota.value.ToString().split(" ")[0]
$userWQb = $user.DatabaseIssueWarningQuota.value.ToString().split(" ")[1]
$userWquota = $userWQa + " " + $userWQb

$body2 += "<td>" + $userWquota+ "</td>"

#Manuplating
$UserDBPa = $user.DatabaseProhibitSendQuota.value.ToString().split(" ")[0]
$UserDBPb = $user.DatabaseProhibitSendQuota.value.ToString().split(" ")[1]
$userDBPS = $UserDBPa + " " + $UserDBPb

$body2 += "<td>" + $userDBPS + "</td>"
$body2 += "</tr>"


}

$body = "<h3>Office 365 {Exchnage Online}, User Mailbox Statics Report.</h3>"
$body += "<br>"
$body += "<br>"
$body += "<table border=2 style=background-color:silver;border-color:black >"
$body += "<tr>"
$body += "<th>S. No</th>"
$body += "<th>Display Name</th>"
$body += "<th>Total Mailbox Size </th>"
$body += "<th>Last LogonTime</th>"
$body += "<th>Last Logoff</th>"
$body += "<th>Server Name </th>"
$body += "<th>Database Name</th>"
$body += "<th>Deleted Item Size</th>"
$body += "<th>Prohibit S/R Quota</th>"
$body += "<th>Issue Warning Quota </th>"
$body += "<th>Prohibit Send Quota</th>"
$body += "</tr>"
$body += $body2
$body += "</table>"

#Sending Email Message to the $to
Write-Output "$(get-date) : Sending the Email."
Send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -UseSsl

}

catch
{

}


}


end {

try {

#Remvoing the Session with Office 365
Write-Output "$(get-date) : Removing PS Session."
Remove-PSSession $ouSession
Write-Output "$(get-date) : Script End."
}

catch {
}
}
}

Send-O365MailStats

# end of the script.


The output should be look like the below screenshot.


09-06-2014 12-57-09


You can download the script from Technet Gallery : http://gallery.technet.microsoft.com/scriptcenter/Office-365-Mailbox-Sizes-92b94563



Regards



Aman Dhally


Come and join my journey of : “100 Days of Self Improvement” on


 


Facebook: https://www.facebook.com/100DoSI 



If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.


Friday, August 31, 2012

Setting Microsoft Office 2012 Trust Center's Trusted Location Paths using Powershell.

Hi Everyone.

If you are working in a Telecom Industry, and if your Analysts and Consultants are using in house built templates then i am sure that you are 98% facing the “Trust Centre warning”.

We are using custom in house built Office Templates for Word,Excel, and PowerPoint.  and the problem was whenever we open our in house templates is Office 2012 we were facing the below error.

We can click on it but it is a quite annoying.

31-08-2012 14-47-12

To resolved this error, the solution is to add our custom built templates directory to the  trusted location in trust center manually on every laptop and desktop.

31-08-2012 15-14-10

Did i mentioned MANUALLY???

Naaaaaa !!!!!!! I thought that we can script this.

And to resolve this is wrote a simple script. you can download the script from this link :
http://gallery.technet.microsoft.com/scriptcenter/Setting-office-2010-31d6a5f4

This script is very simple.,

You only need to provide the path of your templates or the location which you want to add as trusted to  $trustlocation variable.
$trustlocation = 'C:\Mylocation\Templates'
and that’s all , when you run the script , the script will create a location registry  named as “Location99” in to the registry.
and the Registry Keys will be look like this .
31-08-2012 15-33-48
and i have added comments in the script for easy understanding,
Functionality.
  1. First script test the path of the “Location99” registry key
  2. and if the Test path fails that will create a New Registry  Folder “Location99” and the the following registry keys
      • AllowSubfolders this is DWORD registry key and the value is 1 to allow subfolders as a trusted location too.
      • Date  = Date of creation
      • Description = Description for location etc.
      • Path  =  Path to the folder
  3. and if folder found it just write a confirmation message in the console that folder do exists.
  4. The script will do the same process for WORD,EXCEL and Powerpoint.
After running the script the location is added to the Word.
31-08-2012 15-15-24

Thanks
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter