Archive for the ‘Powershell’ Category

Often you need to create some users for test purposes. Here you have a PowerShell script, which will do this procedure for you.

# Get domain and distinguished name
$Domain = (Get-ADDomain).distinguishedname

# Where to place the created users
$TargetOU = “Test”

# distinguished name for OrgUnit
$OUDN = “OU=$TargetOU,$Domain”

# How many users should be created
$NumberUsers= 50

# fill up description field with text and date
$Datetime = get-date -format G
$DField = “TEST ENVIRONMENT USER $datetime”

# OrgUnit check
$OU = Get-ADOrganizationalUnit -Filter { name -eq $TargetOU }
if($OU -eq $null)
{New-ADOrganizationalUnit -Name $TargetOU -Path $Domain}
else
{write-host “OU” $OU ” already there”}

# User creation

$u = 1
While ($u -le $usercount)
{
$UserName = “User” + $u
$UserDisplayName = “Testuser ” + $u
New-ADUser –Name $UserName –SamAccountName $UserName –DisplayName $UserDisplayName `
-Path $OUDN –Enabled $true –ChangePasswordAtLogon $true -description $DField `
-AccountPassword (ConvertTo-SecureString “YOUR_PASSWORD” -AsPlainText -force) -PassThru
$u = $u + 1
}

Cheers,

Chris

Advertisements

By default the Exchange 2010 DAG replication port is set to 64327 TCP.

You can change the port with the following command:

Set-DatabaseAvailabilityGroup -Identity YOURDAG -ReplicationPort YOURPORT

Choose a valid value from 1 to 65535 and keep the firewall setup in mind.

Cheers,

Chris

Here comes the command to get an overview over recoverable items in a mailbox:

Get-MailboxFolderStatistics -Identity user@domain.com -FolderScope RecoverableItems | Format-Table Name,FolderPath,ItemsInFolder,FolderAndSubfolderSize

Regards,

Chris


									

With this command you get an overview over a certain user’s mailbox folders:

Get-MailboxFolderStatistics user@domain.com | ft folderpath, itemsinfolder

You can limit this to special folder, too:

Get-MailboxFolderStatistics -identity user@domain.com -FolderScope ‘DeletedItems’ | Select Identity, FolderPath, ItemsInFolder, FolderSize

Cheers,

Chris

An overview over mailbox sizes ordered by item size and conversion to MB

Get-Mailbox -RecipientType ‘UserMailbox’ -ResultSize unlimited | Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto

Cheers,

Chris

With this script you can get a quick overview over your DB’s replication health, queue length and status.

Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus -ConnectionStatus | Sort-Object -Property name,status | ft

Cheers,

Chris

This script generates a HTML report of all ActiveSync devices ordered by username.

Get-ActiveSyncDevicesHTML

Cheers,

Chris