0% found this document useful (0 votes)
151 views16 pages

Herz Commands 1

The document contains PowerShell commands for managing mailboxes and permissions in Office 365. It includes commands to get mailbox details for users in a specific location, add and remove mailbox permissions, create distribution groups, disable ActiveSync access, set up automatic replies for conference rooms, and forward mailboxes to external addresses. It also contains commands for searching mailboxes, exporting mailbox details, and identifying stale mailboxes for review.

Uploaded by

Mohammed Anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views16 pages

Herz Commands 1

The document contains PowerShell commands for managing mailboxes and permissions in Office 365. It includes commands to get mailbox details for users in a specific location, add and remove mailbox permissions, create distribution groups, disable ActiveSync access, set up automatic replies for conference rooms, and forward mailboxes to external addresses. It also contains commands for searching mailboxes, exporting mailbox details, and identifying stale mailboxes for review.

Uploaded by

Mohammed Anas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Get-Mailbox -ResultSize unlimited | Select-Object DisplayName, UserprincipalName, Usagelocation |

Where-Object {($_.usagelocation -like "germany")} | Export-Csv C:\temp\germanyusers.csv

Mailbox permission:
Add-MailboxPermission -Identity "[email protected]" -User "[email protected]" -
AccessRights FullAccess -AutoMapping:$true

Add-RecipientPermission "AU Rental Extensions" -AccessRights SendAs -Trustee "[email protected]"

Add-MailboxPermission -Identity "[email protected]" -User "[email protected]" -


AccessRights FullAccess -AutoMapping:$true

Add-RecipientPermission "[email protected]" -AccessRights SendAs -Trustee


[email protected]

Remove Mailbox access:

gc .\1.txt | %{remove-MailboxPermission -Identity $_ -User "[email protected]" -AccessRights


FullAccess -Confirm:$false}

gc .\1.txt | %{remove-RecipientPermission $_ -AccessRights SendAs -Trustee


"[email protected]" -Confirm:$false}

remove-MailboxPermission -Identity "ITMIL50" -User "[email protected]" -AccessRights


FullAccess
Remove-RecipientPermission "ITMIL50" -AccessRights SendAs -Trustee [email protected]

remove-MailboxPermission -Identity "[email protected]" -User


"[email protected]" -AccessRights FullAccess
Remove-RecipientPermission "[email protected]" -AccessRights SendAs -Trustee
"[email protected]"

New-DL

New-DistributionGroup -Name "NZ RAC People Managers" -Alias NZRACPeopleManagers

Set-DistributionGroup "RM Training Support" -ManagedBy @{Add="Robert P. Fingar"}

Add-MailboxPermission -Identity "[email protected]" -User "[email protected]" -


AccessRights FullAccess -AutoMapping:$trueAdd-RecipientPermission "[email protected]" -
AccessRights SendAs -Trustee "[email protected]"Add-MailboxPermission -Identity
"[email protected]" -User "[email protected]" -AccessRights FullAccess -
AutoMapping:$trueAdd-RecipientPermission "[email protected]" -AccessRights SendAs -Trustee
[email protected]

Remove ActiveSync access:


set-casmailbox -ActiveSyncEnabled $false

New-Contcat:
PS C:\Windows\system32> New-MailContact -Name "oracletest" -ExternalEmailAddress
[email protected]

Search location wise

Get-Mailbox -ResultSize unlimited | Select-Object DisplayName, UserprincipalName, Usagelocation |


Where-Object {($_.usagelocation -like "germany")} | Export-Csv C:\temp\germanyusers.csv

Getting Users Object details and Immutable ID

Get-MsolUser -UserPrincipalName [email protected]

From FIM side

get-aduser HZ153426 (objectguid)

http://guid-convert.appspot.com/

remove Mailbox:

Remove-MsolUser -UserPrincipalName [email protected]

DL creation:

New-DistributionGroup -Name "China Customer Care Centre" -Alias cccchina

Create Shared mailbox:


New-Mailbox -Shared -Name "GEBOX62SM" -DisplayName "GEBOX62SM" -Alias gebox62sm
Mailbox creation date:

import-csv c:\temp\neverloggedinlist.csv | foreach {Get-Mailbox -identity $_.username } |select


displayname, userprincipalname, whenmailboxcreated | Export-Csv c:\temp\result.csv

Forwarding to Google account :

[email protected] --sample Google account:

[email protected] to [email protected]

Message trace:

PS C:\Windows\system32> Get-MessageTrace -SenderAddress "[email protected]" -


StartDate "01/02/2017 00:00:00" -EndDate "01/09/2017 14:00:00"

PS C:\office365\Reports> Get-MessageTrace -RecipientAddress "apauinvoices@hertz.


com" -StartDate "03/06/2017 00:00:00" -EndDate "03/09/2017 23:00:00"|Export-Csv
apauinvoices.csv

Mailboz size details:

PS C:\Hertz> Get-Mailbox [email protected] |Get-MailboxStatistics|Select Displa


yname,Itemcounts,{$_.TotalItemSize.Value.ToKB()}, {$_.TotaldeleteditemSize.Value
.ToKB()}

Get-Content .\Hercusers.txt| foreach { Get-Mailbox -ResultSize unlimited $_ | select


displayn*,alias,whenmailboxcrea*,primarysmt* ,@{n="TotalItemsize";e={$ms=Get-MailboxStatistics
$_.primarysmtpaddress;$ms.totalitemsize}},@{n="LastLogontime";e={$ms=Get-MailboxStatistics
$_.primarysmtpaddress;$ms.lastlogontime}}}

PS C:\Hertz\Chinausers> Get-Content .\Hercusers.txt| foreach { Get-Mailbox -ResultSize unlimited $_ |


select displayn*,u
serprincipalname,alias,whenmailboxcrea*,primarysmt* ,@{n="TotalItemsize";e={$ms=Get-
MailboxStatistics $_.primarysmtpaddr
ess;$ms.totalitemsize}},@{n="LastLogontime";e={$ms=Get-MailboxStatistics
$_.primarysmtpaddress;$ms.lastlogontime}}}|expo
rt-csv test.csv

Get-Mailbox -ResultSize unlimited| Get-MailboxStatistics | ?{$_.totaldeleteditemsize.toGB() -gt "90"}

Get-Mailbox a* -resultsize unlimited|Get-MailboxStatistics|Sort-Object TotalItemSize -descending|Select


Displayname,Itemcounts,{$_.TotalItemSize.Value.ToGB()},
{$_.TotaldeleteditemSize.Value.ToGB()}|export-csv c:\Hertz\MBXSize\mailboxsize_A.csv

Get-Mailbox B* -ResultSize Unlimited | Get-MailboxStatistics |Sort "TotalItemSize (GB)" -


Descending|Select DisplayName,IsArchiveMailbox,@{name="TotalItemSize
(GB)";expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},@{name="TotalDeletedItemSize
(GB)";expression={[math]::Round((($_.TotalDeletedItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},ItemCount,DeletedItemCount,{(Get-Mailbox $_).primarysmtpaddress}
|Export-CSV "E:\Gopi\Mailboxes_B.csv" -NoTypeInformation

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending |


Select-Object DisplayName,{$_.TotalItemSize.value.toGB()},{$_.TotaldeleteditemSize.Value.ToGB()},{(Get-
Mailbox $_).primarysmtpaddress}|export-csv e:\Gopi\totalItemSize.csv

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending |


Select-Object DisplayName,TotalItemSize,lastlogontime -First 200

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotaldeleteditemSize -


Descending | Select-Object DisplayName,TotalItemSize,TotaldeleteditemSize,lastlogontime -First 200

180Days Inactive users list:

Get-StaleMailboxDetailReport -resultsize unlimited | Sort username -Unique | SELECT username,


DaysInactive | Export-Csv c:\temp\stale\inactiveuser22jan2017.csv

Run the above command


open that output file and filter greater than 180 Days
Again filter with userName begin with HZ or Begin with NH(custom Filter)
next column: =(COCATENATE(a1,"@hertz.net") then drop down same
edit title as UPN from username

Sort as per Daysinactive. Select entries older than 180 days. Filter the usernames with Employee ID and
Stamp them with correct UPN

import-csv c:\temp\stale\jan22.csv | foreach {Get-Msoluser -userprincipalname $_.upn } | select


DisplayName, signinName, BlockCredential, IsLicensed, Licenses | Export-Csv c:\temp\stale\upnjan22.csv

Microsoft Word 97
- 2003 Document
while running above will get not found for few IDs, we can ignore
Booking calendar Conference room:

Set-CalendarProcessing -Identity "WHQ Executive 3" -AutomateProcessing AutoAccept -AllBookInPolicy


$false -AllRequestInPolicy:$false

Set-CalendarProcessing -Identity "WHQ Executive 3" -AutomateProcessing AutoAccept -BookInPolicy


"Laura J. Peters","Colleen Lindgren", "Patricia Lira", "Yvonne A. Schell", "Jennifer L. Pagano", "Nance
Smith", "Tiffany N. Bolton", "Petra Sullivan

Ref: http://practical365.com/exchange-server/output-list-policy-users-resource-mailbox-using-
powershell/

Forward forwarded multiple times


Get-CalendarProcessing -Identity "[email protected]" | fl *forward*

Set-Calendarprocessing -Identity [email protected] -RemoveForwardedMeetingNotifications $true

Disable Active sync:

Set-CASMailbox NH24285 -ActiveSyncEnabled $False

PS C:\Hertz> Get-Content .\Activesyncrem.txt |Set-CASMailbox -ActiveSyncEnabled $false


set-casmailbox -ActiveSyncEnabled $false -MAPIEnabled $false -OWAEnabled $false

MX Record idenetification:

dig mx Hercrentals.com (using Open terminals)


dig mx hertz.com
dig mx hertzequiprentals.com
Outlook Forward and Deleted Rule:
Set-Mailbox -Identity "[email protected]" -DeliverToMailboxAndForward $fasle -
ForwardingSMTPAddress "[email protected]"
Set-Mailbox -Identity "[email protected]" -DeliverToMailboxAndForward $true
-ForwardingSMTPAddress president.salesforce.com

Set-Mailbox -Identity "[email protected]" -DeliverToMailboxAndForward $false -


ForwardingSMTPAddress [email protected]

Set-Mailbox <Identity> -ForwardingAddress $Null


Set-Mailbox [email protected] -ForwardingSmtpAddress $Null

PS C:\office365\Change> Get-Content .\test.txt|Get-Mailbox|Set-Mailbox -ForwardingSmtpAddress


$Null
Get-Content .\test.txt|Get-Mailbox|Set-Mailbox -ForwardingSmtpAddress $Null -
DeliverToMailboxAndForward $false
PS C:\office365\Change> Get-Content .\test.txt|Get-Mailbox|Set-Mailbox -Forward
ingSmtpAddress $Null -DeliverToMailboxAndForward $false

PS C:\temp\Stale> import-csv c:\temp\17Feb2017_180Days.csv | foreach {Get-Mailbox -identity


$_.username } | select displayname, userprincipalname, whenmailboxcreated, ForwardingAddress,
ForwardingSmtpAddress, @{l="mailboxsize";e={(Get-Mailb
oxStatistics $_.alias).totalitemsize}} | Export-Csv c:\temp\stale\17Feb180DaysFR
WDresult.csv

Get-InboxRule -Mailbox [email protected]


Get-Mailbox [email protected]|select displayname, userprincipalname,
whenmailboxcreated, ForwardingAddress, ForwardingSmtpAddress

PS C:\office365\Change> Get-Content .\test.txt|Get-Mailbox|fl display*,forward*


DisplayName : Amber Walkov
ForwardingAddress :
ForwardingSmtpAddress : smtp:[email protected]
http://o365info.com/forward-mail-powershell-commands-quick/

Ref: https://technet.microsoft.com/en-us/library/dd351062%28v=exchg.160%29.aspx

Specific Domain email address searching:

Get-Recipient | where {$_.EmailAddresses -match "cinelease.com"} | fl Name, RecipientType,


EmailAddresses
Get-Recipient | where {$_.EmailAddresses -match "mining88.com"} | fl Name, RecipientType,
EmailAddresses
Get-Recipient | where {$_.EmailAddresses -match "mining88.com"} | fl Name, RecipientType,
EmailAddresses

Get-Mailbox -Filter { WindowsEmailAddress -like "*@cinelease.com" }


PS C:\temp\Stale> Get-Mailbox -Filter { WindowsEmailAddress -like "*@Hercrentals
.com" }|select Name,UserPrincipalName,DisplayName,EmailAddresses,PrimarySmtpAddr
ess,RecipientType,Forwarding*|export-csv Hercrentalsemailaddress.csv

PS C:\temp\Stale> Get-DistributionGroup -Filter { WindowsEmailAddress -like "*@Hercrentals.com"


}|select
Name,UserPrincipalName,DisplayName,EmailAddresses,PrimarySmtpAddress,RecipientType,Forwarding*
|export-csv DLHercrentalsemailaddresses.csv

PS C:\Hertz\Fax> Get-Recipient -ResultSize unlimited|where {$_.emailaddresses -l

ike "*@cinelease*"}

Remove DL:

import-csv C:\Temp\DL\orphanDLs\deletionbatch3.csv | foreach {Remove-DistributionGroup -Identity


$_.groupname -confirm:$false }
You don't have sufficient permissions" error when you try to remove or make a change to a
distribution group"

Try below command and able to delete it.

Remove-DistributionGroup <NameOfGroup> -BypassSecurityGroupManagerCheck

Remove-DistributionGroup [email protected] -
BypassSecurityGroupManagerCheck

PS C:\Hertz\DL> Get-Content .\Input.txt|Remove-DistributionGroup -


BypassSecurityGroupManagerCheck

https://support.microsoft.com/en-in/help/2731947/-you-don-t-have-sufficient-permissions-error-when-
you-try-to-remove-or-make-a-change-to-a-distribution-group
Remove Domains:

11:55:07 PM: Sangeetha V: Remove-MsolDomain -DomainName cinelease.com -Verbose

PS C:\Windows\system32> Get-MsolUser -DomainName hercrentals.com | ?{$_.islicens

ed -eq $true}

Remove License:

PS C:\Hertz> .\Termination-LegalHold.ps1 .\Term.txt

Autodiscovery URL:

nslookup autodiscover.hertz.net

http://autodiscover.hertz.net/autodiscover/autodiscover.xml
https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml

DL Owner adding:

Set-DistributionGroup [email protected] -ManagedBy @{Add=”[email protected]”} -


BypassSecurityGroupManagerCheck

https://support.microsoft.com/en-in/help/2731947/-you-don-t-have-sufficient-permissions-error-when-
you-try-to-remove-or-make-a-change-to-a-distribution-group

Sequense:

get-DistributionGroupmember -Identity "[email protected]" | ft name > c:\temp\dl\[email protected]

get-DistributionGroup -Identity "[email protected]" | fl name, alias, managedby, windowsemailaddress | ft


name > c:\temp\dl\[email protected]

DELETE THE DL AND SYNC TO O365


New-DistributionGroup -Name "Canadian Thrifty Licensees" -Alias CanadianThriftyLicensees

Set-DistributionGroup "Canadian Thrifty Licensees" -ManagedBy @{Add="Robert G. White"}

import-csv c:\temp\dl\CanadianThriftyLicensees.csv | foreach {Add-DistributionGroupMember -Identity


"Canadian Thrifty Licensees" -Member $_.username}

Check the DL and remove my name from Owner list and set address to hertz.com

Below is getting empty members:


$dls = Get-DistributionGroup -ResultSize Unlimited
foreach($dl in $dls)
{
$mem = get-distributiongroupmember -identity $dl.name
if($mem.count -eq 0)
{
write-host $dl.name
}
}
Below is getting ManagedBy(owners) then filter ManagedBy :
Get-DistributionGroup -ResultSize Unlimited | Select-object DisplayName, WindowsEmailaddress,
ManagedBy | Export-Csv c:\temp\groupdetails.csv

DirSync errors:

Get-MsolDirSyncProvisioningError -ErrorCategory PropertyConflict -PropertyName UserPrincipalName |


ft userprincipalname, ProxyAddresses > c:\temp\dirsyncerrorupn.txt
Get-MsolDirSyncProvisioningError -ErrorCategory PropertyConflict -PropertyName ProxyAddresses | ft
userprincipalname, ProxyAddresses > c:\temp\dirsyncerrorproxy.txt

Get-MsolDirSyncProvisioningError -ErrorCategory PropertyConflict -PropertyName UserPrincipalName |


ft userprincipalname, ProxyAddresses > c:\temp\UPNConflictseror_14032017.txt
Get-MsolDirSyncProvisioningError -ErrorCategory PropertyConflict -PropertyName ProxyAddresses | ft
userprincipalname, ProxyAddresses > c:\temp\DuplicateProxyAddress_14032017.txt

https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-
aadconnectsyncservice-duplicate-attribute-resiliency

Bulk user removals:


Import-Csv C:\temp\extraHercrental1.csv | %{Get-MsolUser -UserPrincipalName $_.userprincipalname -
ea 0 | Remove-MsolUser -Force;$i++; write-host "Removing $i out of 465"}

Rename DL:
PS C:\Windows\system32> Import-Csv C:\office365\Reports\test.csv | %{$newemail =
"DeletionPending_"+$_.samaccountname; Set-DistributionGroup $_.samaccountname -
PrimarySmtpAddress $newemail}

PS C:\Windows\system32> Get-DistributionGroup global_marketing_team_group|select


name,displayname,grouptype,primarysmtp*,isdirsyn*

PS C:\office365\Reports> Get-Content .\Test1.txt|Get-DistributionGroup -result u


nlimited |select name,displayname,grouptype,primarysmtp*,isdirsyn*|export-csv 35
4dldetails.csv
Get-DistributionGroup -result unlimited |select
name,displayname,grouptype,primarysmtp*,Organiz*,isdirsyn*|export-csv 354dldetailsNew.csv

Name : global_marketing_team_group
DisplayName : Global Marketing Team
GroupType : Universal
PrimarySmtpAddress : [email protected]
IsDirSynced : True
MS Office 365 URLs and IP address ranges:

https://support.office.com/en-us/article/Office-365-URLs-and-IP-address-ranges-8548a211-3fe7-47cb-
abb1-355ea5aa88a2?ui=en-US&rs=en-US&ad=US

Yammer service Disable:

https://gallery.technet.microsoft.com/office/disable-yammer-in-office-432f584d

E3 License Report ;

Using Portal, pull the report.


https://portal.office.com/adminportal/home#/reportsUsage/LicenseActivity

using above output file filter E3 only


Copy UserPrincipal Name and run below query:
import-csv c:\Hertz\stale\E3Licensereport.csv | foreach {Get-Msoluser -userprincipalname $_.upn } |
select DisplayName, signinName, BlockCredential, IsLicensed, Licenses,Title | Export-Csv
c:\Hertz\stale\E3LicenseReportwithTitle.csv

Litigation Hold enabled:

Set-Mailbox [email protected] -LitigationHoldEnabled $true


https://technet.microsoft.com/en-us/library/dn743673%28v=exchg.160%29.aspx

Add White listing:

o whitelist a sender please follow the below steps:


In the Exchange admin center (EAC), navigate to Protection > Spam filter.
Do one of the following on the general page:
Double-click the default policy in order to edit this company-wide policy.

3. On the Allow Lists page, you can specify entries, such as senders or domains, that will always be
delivered to the inbox. Email from these entries is not processed by the spam filter.

o Add trusted senders to the Sender allow list. Click Add , and then in the selection dialog box, add the
sender addresses you wish to allow. You can separate multiple entries using a semi-colon or a new line.
Click ok to return to the Allow Lists page.

o Add trusted domains to the Domain allow list. Click Add , and then in the selection dialog box, add the
domains you wish to allow. You can separate multiple entries using a semi-colon or a new line. Click ok to
return to the Allow Lists page.

4. Click save.

Password for Cloud user:

Set-MsolUser -UserPrincipalName [email protected] -PasswordNeverExpires $true

Audit Logs:

PS C:\temp\DL> Set-CASMailbox -Identity "Roy Ritenour" -ActiveSyncDebugLogging:$


True

PS C:\temp\DL> Set-Mailbox -Identity "Roy Ritenour" -AuditEnabled $true

Set-Mailbox [email protected] -AuditOwner MailboxLogin,Move,SendAs,SendOnBehalf


Deleted Items Size:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select
DisplayName,StorageLimitStatus,@{name="TotalItemSize
(MB)";expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1MB),2)}},@{name="TotalDeletedItemSize
(MB)";expression={[math]::Round((($_.TotalDeletedItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1MB),2)}},ItemCount,DeletedItemCount | Sort "TotalItemSize (MB)" -Descending |
Export-CSV "C:\My Documents\All Mailboxes.csv" -NoTypeInformation

PS C:\Hertz\MBXSize> Get-Content .\MBXSize.txt|Get-Mailbox -ResultSize Unlimited | Get-


MailboxStatistics | Select DisplayName,IsArchiveMailbox,@{name="TotalItemSize
(GB)";expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},@{name="TotalDeletedItemSize
(GB)";expression={[math]::Round((($_.TotalDeletedItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},ItemCount,DeletedItemCount | Sort "TotalItemSize (GB)" -Descending |
Export-CSV "C:\hertz\MBXSize\Mailboxes.csv" -NoTypeInformation
Get-Mailbox A* -ResultSize Unlimited | Get-MailboxStatistics | Select
DisplayName,IsArchiveMailbox,@{name="TotalItemSize
(GB)";expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},@{name="TotalDeletedItemSize
(GB)";expression={[math]::Round((($_.TotalDeletedItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},ItemCount,DeletedItemCount | Sort "TotalItemSize (GB)" -Descending |
Export-CSV "C:\hertz\MBXSize\Mailboxes_A.csv" -NoTypeInformation

Get-content Input_S.txt|Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics |Sort "TotalItemSize


(GB)" -Descending|Select DisplayName,IsArchiveMailbox,@{name="TotalItemSize
(GB)";expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},@{name="TotalDeletedItemSize
(GB)";expression={[math]::Round((($_.TotalDeletedItemSize.Value.ToString()).Split("(")[1].Split("
")[0].Replace(",","")/1GB),2)}},ItemCount,DeletedItemCount,{(Get-Mailbox $_).primarysmtpaddress}
|Export-CSV "E:\Gopi\Mailboxes_S.csv" -NoTypeInformation

for individual users


Get-MailboxStatistics <Identity> | Format-List
StorageLimitStatus,TotalItemSize,TotalDeletedItemSize,ItemCount,DeletedItemCount

Get-MailboxStatistics <Identity> | Format-List


StorageLimitStatus,TotalItemSize,TotalDeletedItemSize,ItemCount,DeletedItemCount

Get-Mailbox -ResultSize unlimited|Get-MailboxStatistics | Select


StorageLimitStatus,TotalItemSize,TotalDeletedItemSize,ItemCount,DeletedItemCount|Export-Csv
C:\Hertz\DeletedItemSize.csv

PS C:\Hertz\MBXSize> Import-Csv .\Input.csv|foreach {Get-Mailbox -identity $_.upn } | select


displayname, userprincipaln
ame,PrimarySMTPAddress, whenmailboxcreated, @{l="totalitemsize";e={(Get-MailboxStatistics
$_.alias).totalitemsize}},@{l=
"totaldeleteditemsize";e={(Get-MailboxStatistics
$_.alias).totaldeleteditemsize}},@{l="Lastlogontime";e={(Get-MailboxSta
tistics $_.alias).lastlogontime}},@{l="IsArchiveMailbox";e={(Get-MailboxStatistics
$_.alias).IsArchivemailbox}}|Sort-Obj
ect TotalItemSize -descending | Export-Csv c:\hertz\MBXSize\Totalmailboxsize.csv

Get-Mailbox S* -ResultSize Unlimited | select displayname, userprincipalname,PrimarySMTPAddress,


whenmailboxcreated,@{l="totalitemsize";e={(Get-MailboxStatistics
$_.alias).totalitemsize}},@{l="totaldeleteditemsize";e={(Get-MailboxStatistics
$_.alias).totaldeleteditemsize}},@{l="Lastlogontime";e={(Get-MailboxStatistics
$_.alias).lastlogontime}},@{l="IsArchiveMailbox";e={(Get-MailboxStatistics
$_.alias).IsArchivemailbox}}|Sort-Object TotalItemSize -descending | Export-Csv
c:\hertz\MBXSize\Totalmailboxsize_S.csv
Script configure with SMTP mail notification(refer Empty_mem.ps1)
$Username = "[email protected]"
$pass =
"01000000d08c9ddf0115d1118c7a00c04fc297eb01000000f404a8fd1b5f1a46944d39d7059c3f0e000000
0002000000000010660000000100002000000089d633ee8cdb6b722d5f455dc1714a8adda18626dfdcb0a
6f82bf3e069a8d31b000000000e80000000020000200000006ec3e42758743a0bcfd9da5f3908955ed8115
d13cbdfbc2b3623af1429e37521200000004247bec33c93f1da5f66dd36bafe53fcef364fd8e8e5cf1a6b688
e5d74067a034000000023a810f91ca687aa4505e0b2160c97577f9bb4f2fbe575e2059060153d4aae60769
075319352b1db565f7c5bea798bda94a94484da475ad83fa97785e28a7812"
$password = $pass | ConvertTo-SecureString
$Credentials = New-Object System.Management.Automation.PSCredential($Username, $password)

"qwer123$" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString

Test mail using O365 SMTP server :


PS C:\> Send-MailMessage -From [email protected] -To [email protected] -Body t
est -Subject test2 -SmtpServer smtp.office365.com -Port 587 -UseSsl -Credential:
(Get-CredentiaL)

https://www.google.co.in/?gws_rd=ssl#q=office365.microsoft.com+port+number

AutoArchive:

Enable-Mailbox <user mailbox> -AutoExpandingArchive


get-Mailbox [email protected] | FL
AutoExpandingArchiveEnabled,ArchiveQuota,ArchiveWarningQuota

https://support.office.com/en-us/article/Enable-unlimited-archiving-in-Office-365-e2a789f2-9962-4960-
9fd4-a00aa063559e

Enable-Mailbox "Tony Smith" -Archive:$True

The following error occurred during validation in agent 'Windows LiveId Agent': 'Can't enable the archive for
'psheldon' because this user object is synchronized with the on-premises directory. To enable a cloud-based archive
mailbox for this user, you must use your on-premises Exchange admin center or Exchange Management Shell.'
+ CategoryInfo : NotSpecified: (:) [Enable-Mailbox], ProvisioningValidationException
+ FullyQualifiedErrorId : [Server=BY2PR07MB664,RequestId=21ad14a2-d440-42da-a175-
430fbd42d704,TimeStamp=5/25/2017
6:48:18 PM] [FailureCategory=Cmdlet-ProvisioningValidationException]
D03AA3F7,Microsoft.Exchange.Management.Recipi
entTasks.EnableMailbox
+ PSComputerName : ps.outlook.com

Message Folder Assistant:


$i=0
do{
write-host "running MFA"
Start-ManagedFolderAssistant -ErrorAction SilentlyContinue -Identity [email protected];
Start-ManagedFolderAssistant -ErrorAction SilentlyContinue -Identity [email protected];
Start-ManagedFolderAssistant -ErrorAction SilentlyContinue -Identity [email protected];
$i++;
start-sleep -s 30;
}while($i=200)
Mailbox size Increase:

PS C:\Hertz> Get-Mailbox [email protected] | fl displ*,primarys*,ProhibitSendQuota,


ProhibitSendReceiveQuota, IssueWarningQuota
DisplayName : Jeffrey C. Nieman1
PrimarySmtpAddress : [email protected]
ProhibitSendQuota : 99 GB (106,300,440,576 bytes)
ProhibitSendReceiveQuota : 100 GB (107,374,182,400 bytes)
IssueWarningQuota : 98 GB (105,226,698,752 bytes)
PS C:\Hertz> Set-Mailbox [email protected] -ProhibitSendQuota 99GB -
ProhibitSendReceiveQuota 100GB -IssueWarningQuota 98GB
PS C:\Hertz> Get-Mailbox [email protected] | fl ProhibitSendQuota, ProhibitSendReceiveQuota,
IssueWarningQuota
ProhibitSendQuota : 99 GB (106,300,440,576 bytes)
ProhibitSendReceiveQuota : 100 GB (107,374,182,400 bytes)
IssueWarningQuota : 98 GB (105,226,698,752 bytes)
Archive status:
Get-Content .\Input.txt|Get-Mailbox| select displ*,primarysm*,archivestatus

Recall Message:

https://uwindsor.teamdynamix.com/TDClient/KB/ArticleDet?ID=10746

You might also like