Sunday, November 21, 2010

Powershell commands pt 4

[PS] C:\>get-adsite

Name HubSiteEnabled
---- --------------
Default-First-Site-Name False


[PS] C:\>New-EdgeSubscription -FileName c:\edgesubexport.xml -site "default-first-site-name"

Name Site Domain
---- ---- ------
EdgeServer tailspintoys.inte... tailspintoys.exte...
WARNING: EdgeSync requires that the Hub Transport servers in Active Directory
site default-first-site-name must be able to resolve the IP address for
EdgeServer.tailspintoys.external, and be able to connect to that host on ports
50636.


[PS] C:\>Get-SendConnector

Identity AddressSpaces Enabled
-------- ------------- -------
EdgeSync - Default-First-Site-Name to Internet {smtp:*;100} True
EdgeSync - Inbound to Default-First-Site-Name {smtp:--;100} True


[PS] C:\>Start-EdgeSynchronization


Result : Success
Type : Configuration
Name : CN=EdgeServer,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,C
N=tailspintoys,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tailspintoys,DC=internal
FailureDetails :
StartUTC : 5/28/2010 4:23:48 AM
EndUTC : 5/28/2010 4:23:49 AM
Added : 7
Deleted : 1
Updated : 0
Scanned : 345
TargetScanned : 339

Result : Success
Type : Recipients
Name : CN=EdgeServer,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,C
N=tailspintoys,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tailspintoys,DC=internal
FailureDetails :
StartUTC : 5/28/2010 4:23:48 AM
EndUTC : 5/28/2010 4:23:49 AM
Added : 33
Deleted : 0
Updated : 0
Scanned : 33
TargetScanned : 0



[PS] C:\>Test-EdgeSynchronization


Name : EdgeServer
LeaseHolder : GLASGOW
LeaseType : Option
ConnectionResult : Succeeded
FailureDetail :
LeaseExpiry : 5/27/2010 10:23:49 PM
LastSynchronized : 5/27/2010 9:23:49 PM
CredentialStatus : Synchronized
TransportServerStatus : Synchronized
TransportConfigStatus : Synchronized
AcceptedDomainStatus : Synchronized
SendConnectorStatus : Synchronized
MessageClassificationStatus : Synchronized
RecipientStatus : Synchronized
CredentialRecords : Number of credentials 3

[PS] C:\>Test-EdgeSynchronization -verify "text@tailspintoys.internal"


Name : EdgeServer
LeaseHolder : GLASGOW
LeaseType : Option
ConnectionResult : Succeeded
FailureDetail :
LeaseExpiry : 5/27/2010 10:23:49 PM
LastSynchronized : 5/27/2010 9:23:49 PM
CredentialStatus : Skipped
TransportServerStatus : Skipped
TransportConfigStatus : Skipped
AcceptedDomainStatus : Skipped
SendConnectorStatus : Skipped
MessageClassificationStatus : Skipped
RecipientStatus : Synchronized
CredentialRecords : Number of credentials 3

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 }

Powershell command pt 2

Create and mount public folders database

new-publicfolderdatabase -StorageGroup 'GLASGOW\First Storage Group' -Name 'First Glasgow Database' -EdbFilePath 'C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage Group\First Glasgow Database.edb'


mount-database -Identity 'CN=First Glasgow Database,CN=First Storage Group,CN=InformationStore,CN=GLASGOW,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=tailspintoys,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tailspintoys,DC=internal'


Creating new public folders and enable them
[PS] C:\>New-PublicFolder -name management

Name Parent Path
---- -----------
management \


[PS] C:\>New-PublicFolder -name "manage reports" -path \management

Name Parent Path
---- -----------
manage reports \management

[PS] C:\>Enable-MailPublicFolder \management
[PS] C:\>Enable-MailPublicFolder "\management\manage reports"

[PS] C:\>Set-MailPublicFolder \management -EmailAddressPolicyEnabled $false
[PS] C:\>Set-MailPublicFolder "\management\manage reports" -EmailAddressPolicyEnabled $false


[PS] C:\>Set-MailPublicFolder "\management\manage reports" -PrimarySmtpAddress managereport@tailspintoys.internal


[PS] C:\>Set-MailPublicFolder \management -PrimarySmtpAddress management@tailspintoys.internal

[PS] C:\>get-publicfolder

Name Parent Path
---- -----------
IPM_SUBTREE


[PS] C:\>get-publicfolder -recurse

Name Parent Path
---- -----------
IPM_SUBTREE
accounts \
management \
manage reports \management


[PS] C:\>get-publicfolder -recurse format-list name


Name : IPM_SUBTREE

Name : accounts

Name : management

Name : manage reports

[PS] C:\>Disable-MailPublicFolder "\management\manage reports"

Confirm
Are you sure you want to perform this action?
Disabling mail public folder "\management\manage reports".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y
[PS] C:\>Remove-PublicFolder "\management\manage reports"

Confirm
Are you sure you want to perform this action?
Removing public folder "\management\manage reports".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y
[PS] C:\>

Powershell commands pt 1

Since quite a few of the examples in the Microsoft 70-236 book have typo's, I'm posting the ones I have used. Some include the output


new-AcceptedDomain -Name 'Tailspin Toys .com' -DomainName 'tailspintoys.com'
-DomainType 'Authoritative'


enable-OutlookAnywhere -Server 'GLASGOW'
-externalHostname 'outlkany.tailspintoys.com'
-DefaultAuthenticationMethod 'Basic' -SSLOffloading $false


Create new storage group

new-StorageGroup -Server 'GLASGOW' -Name 'second storage group'
-LogFolderPath 'C:\Program Files\Microsoft\Exchange Server\Mailbox\second storage group' -SystemFolderPath 'C:\Program Files\Microsoft\Exchange Server\Mailbox\second storage group'


Create a mailbox database and mount it:

new-mailboxdatabase -StorageGroup 'GLASGOW\second storage group' -Name 'Second Mailbox database' -EdbFilePath 'C:\Program Files\Microsoft\Exchange Server\Mailbox\second storage group\Second Mailbox database.edb'


mount-database -Identity 'CN=Second Mailbox database,CN=second storage group ,CN=InformationStore, CN=GLASGOW,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups ,CN=tailspintoys,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tailspintoys,DC=internal'

New mailbox enable user

[PS] C:\>$password = read-host "Enter Password" -AsSecureString
Enter Password: *********

[PS] C:\>new-mailbox -UserPrincipalName annie.hall@tailspintoys.internal
-Database "first storage group\db1" -name annieh -organizationalunit users
-displayname "Annie Hall" -password $password
-ResetPasswordOnNextLogon $false

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
annieh annie.hall glasgow unlimited


Below since no user password is supplied you will be asked for one

New-Mailbox -Name 'Don Hall' -Alias 'donh'
-OrganizationalUnit 'tailspintoys.internal/Users'
-UserPrincipalName 'donh@tailspintoys.internal' -SamAccountName 'donh'
-FirstName 'Don' -Initials '' -LastName 'Hall'
-Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $true
-Database 'GLASGOW\First Storage Group\DB1'

[PS] C:\>Disable-Mailbox -identity bobbyh

Confirm
Are you sure you want to perform this action?
Disabling Mailbox "bobbyh" will remove the Exchange properties from the Windows
user object and mark the mailbox in the database for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y
[PS] C:\>
[PS] C:\>Enable-Mailbox -identity bobbyh

cmdlet Enable-Mailbox at command pipeline position 1
Supply values for the following parameters:
Database: db2

Name Alias ServerName ProhibitSendQuo
ta
---- ----- ---------- ---------------
bobbyh bobby.hall glasgow unlimited

[PS] C:\>Remove-Mailbox -identity bobbyh

Confirm
Are you sure you want to perform this action?
Removing the Mailbox "bobbyh" will remove the Windows user object and mark the
mailbox in the database for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y


Set-CASMailbox -identity adam@contoso.com -OWATasksEnabled:$true -POPEnabled:$true


New Mail-enabled user



New-MailUser -Name 'Sean p. Alexander' -Alias 'sead.p.alexander'
-OrganizationalUnit 'tailspintoys.internal/Users'
-UserPrincipalName 'sead.p.alexander@tailspintoys.internal'
-SamAccountName 'sead.p.alexander' -FirstName 'Sean' -Initials 'p'
-LastName 'Alexander' -Password 'System.Security.SecureString'
-ResetPasswordOnNextLogon $false -ExternalEmailAddress 'SMTP:sean.p.alexander@adato.com'

also remove-mailuser, disable-mailuser, enable-mailuser to enable you must supple e-mail address
[PS] C:\>Enable-MailUser -identity "Bobby Hall" -ExternalEmailAddress bobbyh@contoso.com

Set-MailUser "bobbyh" -ExternalEmailAddress bobbyh@seaworld.com to configure e-mail properties

New Mail Contact

New-MailContact -ExternalEmailAddress 'SMTP:s.pearson@adatum.com' -Name 'Simon Pearson' -Alias 'SimonPearson' -OrganizationalUnit 'tailspintoys.internal/Users'
-FirstName 'Simon' -Initials ''-LastName 'Pearson'

also enable-mailcontact, disable-mailcontact, and remove-mailcontact
Enable-MailContact -identity "Bobby Hall" -ExternalEmailAddress bobbyh@contoso.com


Create Dynamic Distribution Group

new-DynamicDistributionGroup -Name 'Contoso employees'
-IncludedRecipients 'MailUsers' -ConditionalCompany 'contoso, ltd.'
-OrganizationalUnit 'tailspintoys.internal/Users' -Alias 'Contosoemployees'
-RecipientContainer 'tailspintoys.internal/Users'

Create distribution group

[PS] C:\>New-DistributionGroup -name sales -Type 'distribution' -OrganizationalUnit 'tailspintoys.internal/users' -SamAccountName Sales -alias sales

Name DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
sales sales Universal sales@tailspinto...


[PS] C:\>Add-DistributionGroupMember sales -member "annie hall"

[PS] C:\>Get-DistributionGroupMember sales

Name RecipientType
---- -------------
annieh UserMailbox

[PS] C:\>Remove-DistributionGroupMember sales -member annieh

Confirm
Are you sure you want to perform this action?


new-DistributionGroup -Name 'Service Techs' -Type 'Distribution'
-OrganizationalUnit 'tailspintoys.internal/Users' -SamAccountName 'Service Techs'
-Alias 'ServiceTechs'

also have remove-distributiongroup and disable-distributiongroup, enable-distributiongroup

set-distributiongroup to configure e-mail setting for group



Create Room Mailbox

New-Mailbox -Name 'Auditorium' -Alias 'Auditorium'
-OrganizationalUnit 'tailspintoys.internal/Users'
-UserPrincipalName 'Auditorium@tailspintoys.internal' -SamAccountName 'Auditorium'
-FirstName '' -Initials '' -LastName '' -Database 'GLASGOW\First Storage Group\DB1'
-Room -ManagedFolderMailboxPolicy 'deleted folders service'

set-MailBoxCalenderSettings Auditorium -automateProcessing:AutoAccept

set-MailBoxCalenderSettings Auditorium -automateProcessing:none

set-MailboxCalendarSettings -identity Auditorium -ResourceDelegates "annie hall"

Create equipment mailbox

New-Mailbox -Name 'Projector' -Alias 'Projector'
-OrganizationalUnit 'tailspintoys.internal/Users'
-UserPrincipalName 'Projector@tailspintoys.internal' -SamAccountName 'Projector'
-FirstName '' -Initials '' -LastName '' -Database 'GLASGOW\First Storage Group\DB1'
-Equipment

Create a custom property

[PS] C:\>Set-ResourceConfig -DomainController glasgow.tailspintoys.internal -Res
ourcePropertySchema room/NetworkProjector