Archive

Posts Tagged ‘Exchange 2010’

Get a list of Office365 users with License attached, Primary SMTP address and Aliases


To get an list of all users that has an Office365 license assigned and with Displayname, Primary SMTP address and all other adresses registrated on the users use this one-liner in PowerShell! 🙂

get-mailbox | Where-Object {$_.SKUAssigned -eq “TRUE”} | Select-Object Displayname, PrimarySMTPAddress, EmailAddresses | Export-Csv c:\temp\noah2.csv -Encoding UTF8

Powershell: Exchange – List all mailboxes in one database


To list all mailboxes in one database and sort it by size, use this nice PowerShell line:

Get-MailboxStatistics -Database <DATABASENAME> | select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending

 

If you want to export the list to an CSV file, put “| Export-CSV C:\MailBoxSize.CSV” at the end of the PowerShell line.

Powershell: Exchange – Check database size


Here is a one liner to check the database size for exchange databases.

Start Exchange management shell. Then run the following command:

Get-MailboxDatabase | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter (‘name=”’ + $_.edbfilepath.pathname.replace(“\”,”\\”) + ””)).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

Source:
http://blogs.technet.com/b/gary/archive/2009/08/11/get-exchange-mailbox-database-size-one-liner-version-2.aspx

Exchange tips: Out of Office on users


To check information about Out Of Office for mailbox users we can run an powershell “one liner” and get useful information.

The PS, Get-MailboxAutoReplyConfiguration “username” will show you this useful information:

  • AutoReplyState (Disabled/Enabled)
  • Start date (date and time)
  • End date (date and time)
  • External Message (in HTML format)
  • Internal Message (in HTML format)

OOO_ps

With this command you can easily change the message as wel!

Get-MailboxAutoReplyConfiguration julras | Set-MailboxAutoReplyConfiguration -ExternalMessage “Hi, I`m testing OOO” -InternalMessage “Hi, I`m testing OOO” -Autoreplystate Enabled

As you can see in my PS command i here GET the results of “julras” user and pipe it throug an SET command to change the External and internal message and then Enable the Out of Office for the user.

Exchange 2010 – Export mailbox to pst

December 30, 2013 Leave a comment

Start Exchange Management Shell.
Give your self rights to do export and import
Command:
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User Administrator

Then close Exchange Management Shell and restart it.

Now export mailbox using this command:
Command:
New-MailboxExportRequest -mailbox user@domain.no -FilePath \\localhost\temp$\user.pst

The export command needs a UNC path for the filepath. I have just created a hidden temp share. Remember to delete temps after job is completed 🙂

Get-Inboxrule – easy way to get rules from mailboxes

November 11, 2013 Leave a comment

An easy command for checking if there are any automatic rules on an Exchange Mailbox is to use PowerShell and Get-InboxRule, this commandlet will give you an output of all the rules and what the rule does with emails that`s arriving in the mailbox.

Example: Get-InboxRule -Mailbox “account” | Select Name, Description | fl

exc_ps

Usefull PowerShell commands


PowerShell is a powerfull tool when administrating Microsoft products and personally i like using Windows PowerShell ISE that is an powershell tool provided from Microsoft.
It can be found on Windows 8, Windows Server 2012, Windows Server 2008 R2 and Windows Server 2008.

Here are som usefull PS one-liners that i use often 🙂

# Connect to remote server
Enter-PSSession “yourdomaincontroller”

# Disconnect remote session
exit-pssession

# Import the ActiveDirectory cmdlets
Import-Module ActiveDirectory

# List available snapins on your system
Get-PSSnapin

# Add snapins examples
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin # Exchange 2007
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 # Exchange 2010
Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager # WMM (Hyper-V)
Add-PSSnapin Quest.Activeroles.ADManagement # Quest commandlets

# List registered snapins
Get-PSSnapin -Registered

# List Active Directory Computers that have never logged in within time span (-TimeSpan 365.00:00:00, this is 365 days), first line counts the result, second line shows the result, line three sends output to an txt file.
(Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 35.00:00:00 | select name | sort-object name).count
Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90.00:00:00 | select name | sort-object name
Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 65.00:00:00 | select name | sort-object name | out-file c:\temp\computers.txt

# The following example demonstrates how to find user accounts that have been inactive for 90 days:
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | where {$_.ObjectClass -eq ‘user’} | FT Name,ObjectClass –A

# The following example demonstrates how to find inactive user accounts
Search-ADAccount -AccountInactive | where {$_.ObjectClass -eq ‘user’} | FT Name,ObjectClass –A

# The following example demonstrates how to find user accounts that have been inactive since 01/01/2013
Search-ADAccount -AccountInactive -DateTime 01/04/2013 | where {$_.ObjectClass -eq ‘user’} | FT Name,ObjectClass –A

# The following example demonstrates how to find locked-out users in your domain
Search-ADAccount -LockedOut | where {$_.ObjectClass -eq ‘user’} | FT Name,ObjectClass -A

#The following example demonstrates how to unlock the user account U1 in the organizational unit (OU) Test in your domain.
Unlock-ADAccount -Identity “CN=U1,OU=Test,DC=FABRIKAM,DC=COM”

# The following example demonstrates how to unlock the user account U1 in your domain.
Unlock-ADAccount -Identity U1

# Reset pasword on spesific user where “bob” is changed to the username of the user you want to change password on
Set-ADAccountPassword -Identity bob -Reset

%d bloggers like this: