How to export user photos in O365 / Exchange Inline using Exchange Online Powershell

Below small script can be use to export photos from O365 / Exchange Online using powershell.

First you need to connect to exchange online.

#############################################

get-mailbox -ResultSize Unlimited | % {Get-UserPhoto $_.identity} | % {Set-Content -path “C:\Photos\$($_.identity).jpg” -value $_.picturedata -Encoding byte}

####################################################

How to export thumbnail/photos from Active Directory using powershell

Below is smal powershell script to export photos from the Active Directory using AD powershell.

#########################################################

$list=GET-ADuser –filter * -properties thumbnailphoto

Foreach ($User in $list)

{

$Directory=’C:\Photos\’

If ($User.thumbnailphoto)

  {

  $Filename=$Directory+$User.samaccountname+’.jpg’

  [System.Io.File]::WriteAllBytes($Filename, $User.Thumbnailphoto)

  }

}

#########################################################

How to view current mailbox size, message count and last logon

You can use the Exchange Management Console to view who last logged on to a mailbox, the last logon date and time, the mailbox size, and the message count by completing these steps:

1. Expand the Recipient Configuration node and then select the Mailbox node.
2. Double-click the mailbox with which you want to work.
3. On the General tab, the Last Logged On By text box shows who last logged on to the mailbox, and the Modified entry shows the date and time the mailbox was last modified.
4. On the General tab, the Total Items and Size (KB) areas show the number of messages in the mailbox and the current mailbox size in kilobytes, respec¬tively.

If you want to view similar information for all mailboxes on a server, the easiest way is to use the Get-MailboxStatistics cmdlet. Here are some examples of using this cmdlet.

Get-MailboxStatistics -Server ‘corpsvr127’
Get-MailboxStatistics -Database ‘Engineering Primary’
Get-MailboxStatistics –Identity ‘cpandl\williams’

How to allow permissions on another user mailbox using powershell

Users need to access someone else’s mailbox, and in certain situations this is appropriate and preferable. You can grant permissions for a mailbox in two ways: grant access to a mailbox and its content or grant the right to send messages as the mailbox owner.

If you want to grant access to a mailbox and its contents but not grant Send As permissions, you can use the Manage Full Access Permission Wizard. In the Exchange Management Console, right-click the mailbox you want to work with and then select Manage Full Access Permission.

In the Manage Full Access Permission Wizard, click Add, and then use the Select User Or Group dialog box to choose the user or users who should have access to the mailbox. To revoke the authority to access the mailbox, select an existing user name in the Security Principal list box and then click Remove. Click Manage to set the desired access permissions.

In the Exchange Management Shell, you can use the Add-MailboxPermission and Remove-MailboxPermission cmdlets to manage full access permissions.

Adding full access permissions

Add-MailboxPermission -Identity UserWhoseMailboxIsBeingConfigured -User UserBeingGrantedPermission -AccessRights ‘FullAccess’


Add-MailboxPermission -Identity ‘Manager@hitechcandy.com’ -User ‘hiotechcandy\premr’ -AccessRights ‘FullAccess’


Removing full access permissions

Remove-MailboxPermission -Identity ‘UserBeingGrantedPermission’ -User ‘UserWhoseMailboxIsBeingConfigured’ -AccessRights ‘FullAccess’ -InheritanceType ‘All’


Remove-MailboxPermission -Identity ”Manager@hitechcandy.com’ -User ‘hiotechcandy\premr’ -AccessRights ‘FullAccess’ -InheritanceType ‘All’

If you want to grant Send As permissions, you can use the Manage Send As Permission Wizard. In the Exchange Management Console, right-click the mailbox you want to work with and then select Manage Send As Permission. In the Manage Send As Permission Wizard, click Add, and then use the Select Recipient dialog box to choose the user or users who should have this permission. To revoke this permission, select an existing user name in the Security Principal list box and then click Remove. Click Manage to set the desired Send As permissions.

In the Exchange Management Shell, you can use the Add-ADPermission and Remove-ADPermission cmdlets to manage Send As permissions.

Adding Send As permissions

Add-ADPermission -Identity UserBeingGrantedPermission -User UserWhoseMailboxIsBeingConfigured -ExtendedRights ‘Send-As’


Add-ADPermission -Identity ”Manager@hitechcandy.com’ -User ‘hiotechcandy\premr’ -ExtendedRights ‘Send-As’
or

Add-RecipientPermissions -identity ‘Manager@hitechcandy.com’ -Trustee ‘hiotechcandy\premr’ -AccessRights SendAs

Removing Send As permissions

Remove-ADPermission -Identity UserBeingRevokedPermission -User UserWhoseMailboxIsBeingConfigured -ExtendedRights ‘Send-As’ -InheritanceType ‘All’ -ChildObjectTypes $null -InheritedObjectType $null -Properties $null


Remove-ADPermission -Identity ”Manager@hitechcandy.com’ -User ‘hiotechcandy\premr’ -ExtendedRights ‘Send-As’ -InheritanceType ‘All’ -ChildObjectTypes $null -InheritedObjectTypes $null -Properties $null

How to create a user account with a mailbox by using the New-Mailbox cmdlet in exchange 2010

Use below power shell in exchange shell to create a mailbox and account at the same time

New-Mailbox -Name “Prem Rana” -Alias “premr” -OrganizationalUnit “hitechcandy.com/People”
-Database “mbxDatabase1” -UserPrincipalName premr@hitechcandy.com -SamAccountName “shanek” -FirstName “Prem”
-Initials “P” -LastName “Rana” -ResetPasswordOnNextLogon $true

How to Change maximum Office 365 attachment size with PowerShell

The default Office 365 maximum message size for messages is 35MB. Because the email text is usually small, this setting essentially restricts the maximum attachment size. You can change the maximum message size for an individual mailbox in the Office 365 admin center or with PowerShell.

To check the current message sending/receiving limt

Get-Mailbox -Identity “UserName@YourDomain.com” | fl maxsendsize,maxreceivesize

To set the message sending/receiving limit to 150 MB

Set-Mailbox -Identity “UserName@YourDomain.com” -MaxReceiveSize 150MB -MaxSendSize 150MB

how to install Azure RM module for powershell

You need to download and install the module for azure DNS first

First check the power shell version because Azure RM module need power shell 5.0 at least.

$PSVersionTable.PSVersion

Install-Module -Name AzureRM

By default, the PowerShell gallery isn’t configured as a trusted repository for PowerShellGet. The first time you use the PSGallery you see the following prompt:
Untrusted repository

You are installing the modules from an untrusted repository. If you trust this repository, change its Installation Policy value by running the

Set-PSRepository cmdlet.

Are you sure you want to install the modules from ‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “N”):

# Import the module into the PowerShell session
Import-Module AzureRM
# Connect to Azure with an interactive dialog for sign-in
Connect-AzureRmAccount

Update-Module -Name AzureRM

How to connect to Exchange Online using Powershell

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection

Set-ExecutionPolicy -ExecutionPolicy unrestricted

Import-PSSession $Session

How to Disable IPv6 Using Command Prompt

Start a command prompt with administrative permissions and enter the following command:

reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0xFFFFFFFF