Sunday, November 21, 2010

Powershell commands pt 3

Chapter 5 Moving users and implemementing bulk management

Set access rights on mailboxes

[PS] C:\>Get-Mailbox | Add-MailboxPermission -user kima -accessrights fullaccess

Creating a template

[PS] C:\>new-mailbox _Template -UserPrincipalName _Template@tailspintoys.external -database "first storage group\db1"
-OrganizationalUnit Users -ResetPasswordOnNextLogon $true

cmdlet New-Mailbox at command pipeline position 1
Supply values for the following parameters:
Password: *********

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
_Template _Template glasgow unlimited


Creating new users and mailboxes from a CSV using a Template

[PS] C:\>$template = Get-Mailbox _Template
[PS] C:\>$TempPassword = ConvertTo-SecureString Password1 -AsPlainText -Force

[PS] C:\>Import-Csv c:\newusers.csv | ForEach-Object -Process { New-Mailbox -name $_.Name
-UserPrincipalName $_.upn -OrganizationalUnit $_.ou -Database "first storage group\db1"
-Password $tempPassword -TemplateInstance $template}

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Angela Barbariol Angela.Barbariol glasgow unlimited
Mark Harrington Mark.Harrington glasgow unlimited
Keith Harris Keith.Harris glasgow unlimited
Tony Allen Tony.Allen glasgow unlimited
Isabel Martins Isabel.Martins glasgow unlimited


Part of the CSV file

name,UPN,ou
Angela Barbariol,Angela.Barbariol@tailspintoys.internal,tailspintoys.internal/users
Mark Harrington, Mark.Harrington@tailspintoys.internal,tailspintoys.internal/users

Create new Mailbox Database and Move users to it

[PS] C:\>New-MailboxDatabase "First Glasgow Mailbox Database" -storagegroup "First storage Group"

Name Server StorageGroup Recovery
---- ------ ------------ --------
First Glasgow Mai... GLASGOW First Storage Group False


[PS] C:\>Mount-Database "First Glasgow Mailbox database"

Summary: 5 item(s). 5 succeeded, 0 failed.
Elapsed time: 00:00:47


Summary: 5 item(s). 5 succeeded, 0 failed.
Elapsed time: 00:00:47


Move one user
'tailspintoys.internal/Users/Keith Harris' | move-mailbox -BadItemLimit '5'
-TargetDatabase 'GLASGOW\First Storage Group\First Glasgow Mailbox Database'

Move all users from one mail database to another

[PS] C:\>Get-Mailbox -Database "first storage group\first glasgow mailbox database" | Move-Mailbox
-TargetDatabase "First storage group\db1"

Setting Mailbox quotas

[PS] C:\>Import-Csv c:\setquotas.csv | ForEach-Object -process { Set-Mailbox $_.identity -ProhibitSendReceiveQuota
$_.recieve -ProhibitSendQuota $_.send -IssueWarningQuota $_.warning }

Setting users departments

[PS] C:\>Import-Csv c:\userdepartment.csv | ForEach-Object -process { Set-user $_.name -Department $_.department }

No comments:

Post a Comment