Sie sind auf Seite 1von 15

PowerShell Scripting In Exchange 2007

This topic covers some of the PowerShell concepts related to Exchange Server
2007. The use of PowerShell with Exchange Server 2007 can do a great deal to ease the task of server
administration as well as user administration.
Introduction to PowerShell Scripts
PowerShell is a scripting tool provided by Microsoft, for complex automation tasks in windows servers and
clients. PowerShell scripts function like batch files in the traditional console. A PowerShell script is nothing
more than a text file containing PowerShell code. f the text file is executed, PowerShell steps through its
statements and executes them. !ou can create PowerShell scripts with much the same simplicity you
could use batch files..PowerShell facilitates scripting in "indows servers through effective commands.
PowerShell internal commands are called#cmdlets#.The mother of all cmdlets is called Get-Command$t
retrieves a list of all available cmdlets. %mdlet names always consist of an action &verb' and something
that is acted on &noun'. This naming convention helps you to find the right command. n other words each
cmdlet in PowerShell has a verb and noun
(g$ n the command )et*+elp, )et is the verb. +elp is the noun. (xecution f a cmdlet in PowerShell
window is shown in fig$
PowerShell also supports pipelining of instructions &cmdlets'. The PowerShell pipeline chains together a
number of commands similar to a production assembly.
So, one command hands over its result to the next, and at the end, you receive the result.
,or example$ -ir . Sort*/b0ect 1ength . Select*/b0ect 2ame, 1ength .%onvertTo*+tml . /ut*,ile
report.htm.3report.htm
1
t returns an +TM1 report on the current directory contents sorted by file si4e. All of this starts with a Dir
command, which then passes its result to Sort-Object. The sorted result then gets limited to only the
properties you want in the report. ConvertTo-tml converts the ob0ects to +TM1 which is then written to a
file.
Powershell in Exchange 2007
Microsoft (xchange Server 5667 introduces a new management platform called the (xchange
Management Shell, based on "indows PowerShell. This provides a list of fre8uently used cmdlets,
important conventions, and useful tips. The information is presented by feature area, such as recipient,
transport, and database administration. (xchange management shell helps in simplifying the user and
server administration task in (xchange 5667.The common PowerShell parameters and usage of cmdlets
in exchange management shell is explained below.
Common Cmdlet Actions
The following verbs are supported by most cmdlets and are associated with a specific action.
New: The 2ew verb creates a new instance of something, such as a new configuration setting, a new
database, or a new SMTP connector.
Remove$ The 9emove verb removes an instance of something, such as a mailbox or transport rule.
All 9emove cmdlets support the "hatf and %onfirm parameters.
Enable: The (nable verb enables a setting or mail*enables a recipient.
Disable: The -isable verb disables an enabled setting or mail*disables a recipient. All -isable tasks also
support the "hatf and %onfirm parameters.
Set: The Set verb modifies specific settings of an ob0ect, such as the alias of a contact or the deleted
item retention of a mailbox database.
Get: The )et verb 8ueries a specific ob0ect or a subset of a type of ob0ect, such as a specific mailbox, all
mailbox users, or mailbox users in a domain.
2
Important Parameters
The following parameters help you control how your commands run and indicate exactly what a command
will do before it affects data.
Identity $ The dentity parameter identifies the uni8ue ob0ect for the task. t is typically used with (nable,
-isable, 9emove, Set, and )et cmdlets. dentity is also a positional parameter, which means that you
don:t have to specify dentity when you specify the parameter:s value on the command line.
,or example$ )et*Mailbox *dentity user; 8ueries for the mailbox of user;.
WhatIf: The "hatf parameter instructs the cmdlet to simulate the actions that it would take on the
ob0ect. <y using the "hatf parameter, you can view what changes would occur without actually applying
any of the changes. The default value is =True.
Confirm $ The %onfirm parameter causes the cmdlet to pause processing and re8uires the administrator
to acknowledge what the cmdlet will do before processing continues. The default value is =True.
Validate: The >alidate parameter causes the cmdlet to check that all rere8uisites for running the
operation are satisfied and that the operation will complete successfully.
Tips and Tricks
)et*%ommand$ This cmdlet retrieves all tasks that can be executed in (xchange Server 5667.
)et*%ommand ?keyword?$ This cmdlet retrieves tasks that have keyword in the cmdlet.
)et*task . )et*Member$ This cmdlet retrieves all properties and methods of task.
)et*task . ,ormat*1ist $ This cmdlet displays the output of the 8uery in a formatted list. !ou can pipe the
output of any )et cmdlet to ,ormat*1ist to view the whole set of properties that exist on the ob0ect
returned by that command, or you can specify specific properties that you want to view, separated by
commas, as in the following example$
)et*Mailbox ?0ohn? . ,ormat*1ist alias,?8uota
(xecution of cmdlet in (xchange Management Shell is shown in below.
3
Server administration in Exchange 2007 sing Exchange !anagement
Shell
This section describes some of the general administrative tasks that can be easily accomplished using
Power"hell, such as -atabase and Storage )roup Management, mail trcking and monitoring different
parameters of exchange 5667 server
!anaging Storage "roups
PowerShell provides effective commands &cmdlets' to make the storage management easier in exchange
5667. .This section discuss some of the cmdlets used for storage management
Creating a Storage "roup
This can be achieved by the cmdlet New-StorageGro!. The syntax of the 2ew*Storage)roup cmdlet is
the following$ !ou can use the 2ew*Storage)roup cmdlet to create a new storage group or a new
recovery storage group on a Microsoft (xchange Server 5667 Mailbox server. To run the 2ew*
Storage)roup cmdlet, the account you use must be delegated the (xchange Server Administrator role
and local Administrators group for the target server. t provides different parameters to enable various
options in creating the storage groups, such as, Standby Machine parameter&specifies the server where
the copy of storage group is located', Template nstance parameter &Specifies the template that was used
to create the storage group',etc$ The Parameters in the s8uare bracket@ A ,as given in syntax are optional
4
Synta"
#ew-StorageGro$% -#ame &String' (-Circ$lar)oggingEnabled &*tr$e + *,al"e'-
(-Con,irm (&SwitchParameter'--
(-Co%.)og/olderPath &#on0oot)ocal)ong/$llPath'-
(-Co%.S."tem/olderPath &#on0oot)ocal)ong/$llPath'-
(-DomainController & /1dn'-
(-a")ocalCo%. &*tr$e + *,al"e'-
(-)og/olderPath &#on0oot)ocal)ong/$llPath'-
(-0e%la.)agTime &#$llable'-
(-Server &Server2dParameter'-
(-Standb.3achine &String'-
(-S."tem/olderPath &#on0oot)ocal)ong/$llPath'-
(-Tem%late2n"tance &PSObject'-
(-Tr$ncation)agTime &#$llable'-
(-4hat2, (&SwitchParameter'--
(-5eroDataba"ePage" &*tr$e + *,al"e'- (&CommonParameter"'-
Example
@PSA %$3B 2ew*Storage)roup *2ame My2ewStorage)roup *Server (xchangeServer; *1og,older
Path$C-$3Mailbox3,irst Storage )roupC *System,olderPath$C-$3Mailbox3,irst S torage )roupC
This will crate a storage group named DMy2ewStorage)roup# in the exchange server D(xchangeServer;#
with data and log file in the path D-$3Mailbox3,irst S torage )roup#
#emoving a Storage "roup
The cdmlet D Remove-StorageGro!# is used to delete a storage group.Syntax is shown below.
Synta"
0emove-StorageGro$%-2dentit.&StorageGro$%2dParameter'(-Con,irm(&SwitchParameter'--
(-DomainController &/1dn'- (-4hat2, (&SwitchParameter'-- (&CommonParameter"'-
Example
@PSA %$3B9emove*Storage)roup *dentity C(xchange*Server*;.Testdomain.com3Storage )roup EC
#etrieving Storage "roups Properties
Get-StorageGro! : This cmdlet is used to retrieve a storage group ob0ect from the .Active -irectory
directory service..This command retrieves a summary list of all storage groups in the server
5
Synta"
Get-StorageGro$%-2dentit.&StorageGro$%2dParameter'-(-DomainController&/1dn'-
(-incl$dePreExchange2007 &SwitchParameter'- (-Stat$" &SwitchParamete r'- (&CommonParameter"'-
Example
@PSA %$3B )et*Storage)roup *dentity C(xchange*Server*;.Testdomain.com3,irst Storage )roupC . ,or
mat*1ist
<elow are the other common cmdlets that are used for storage group management.
Set-StorageGro!: This command modifies the properties of storage group named Storage)roup
Enable-StorageGro!Co!y -Identity StorageGro!$ This command enables local continuous backup
on storage group named Storage)roup.
Disable-StorageGro!Co!y -Identity StorageGro!$ This command disables the continuous backup of
storage group named Storage)roup
$ata%ase !anagement
This section discusses some of the cmdlets used for database management with syntax and examples.
Setting !ail%ox$ata%ase properties
Set&!ail%ox$ata%ase$This cmdlet is used to set the attributes of a mailbox database, such as mailbox
retention period,mailbox 8uata limit etc
Synta"
Set-3ailboxDataba"e -2dentit. &Databa"e2dParameter' (-6llow/ile0e"tore &*tr $e + *,al"e'- (-Con,irm
(&SwitchParameter'-- (-Deleted2tem0etention &Enhanc edTimeS%an'- (-DomainController &/1dn'- (-
Eventi"tor.0etentionPeriod &EnhancedTimeS%an'- (-2ndexEnabled &*tr$e + *,al"e'- (-$e4arning7$ota
&8nlimi ted'- (-9o$rnal0eci%ient &0eci%ient2dParameter'- (-3ailbox0etention &EnhancedTimeS%an'- (-
3aintenanceSched$le &Sched$le'- (-3o$nt6tStart$% &*tr$e + *, al"e'- (-#ame &String'- (-
O,,line6ddre"":oo; &O,,line6ddre"":oo;2dParameter '- (-ProhibitSend7$ota &8nlimited'- (-
ProhibitSend0eceive7$ota &8nlimited'- (-P$blic/olderDataba"e &Databa"e2dParameter'- (-
7$ota#oti,icationSched$le &Sched$le'- (-0etainDeleted2tem"8ntil:ac;$% &*tr$e + *,al"e'-
(-4hat2, (&SwitchParameter'-- (&CommonParameter"'-
Example
Set*Mailbox-atabase CMailbox -atabase6;C *-eletedtem9etention 7.66$66$66
'isting data%ases
Get-#ailbo"Database$ This command retrieves a summary list of all mailbox databases in the server
named Server.
6
Synta"
Get-3ailboxDataba"e (-2dentit. &Databa"e2dParameter'- (-DomainController &/ 1dn'-
(-incl$dePreExchange2007 &SwitchParameter'- (-Stat$" &SwitchParameter '- (&CommonParameter"'-
Example
@PSA %$3B get*mailboxdatabase
2ame Server Storage)roup 9ecovery
**** ****** ************ ********
Mailbox -atabase (xchange*Server; ,irst Storage )roup ,alse
Mailboxdatabase5 (xchange*Server; ,irst Storage )roup ,alse
<elow are the other common cmdlets that are used for database management.
New-MailboxDatabase -Name MailboxDatabase -StorageGroup
StorageGroup: This command creates a new mailbox database named
MailboxDatabase in the storage group StorageGroup.
Mount-Database -Identity MailboxDatabase: This command mounts the
existing mailbox database named MailboxDatabase.
Dismount-Database -Identity MailboxDatabase: This command dismounts the
existing mailbox database named MailboxDatabase
!anaging (ueues
This section discuss some of the cmdlets used for managing the smtp 8ueue in exchange server 5667
with syntax and examples.This helps in troubleshooting the mailflow related issues.
!onitoring )ueue
Get-$ee: Fse the )et*Gueue cmdlet to view configuration information for 8ueues on a
computer that has the +ub Transport server role or the (dge Transport serve r role installed.
S*ntax
Get-7$e$e (-:oo;mar;2ndex &2nt<2'- (-:oo;mar;Object &7$e$e2n,o'- (-/ilter & String'-
(-incl$de:oo;mar; &*tr$e + *,al"e'- (-0e"$ltSi=e &8nlimited'- (-0et$rnPage2n,o &*tr$e + *,al"e'- (-
Search/orward &*tr$e + *,al"e'- (-Server & Server2dParameter'- (-SortOrder &SortOrderEntr.(-'-
(&CommonParameter"'-
7
Example
@PSA %$3B get*8ueue
dentity -eliveryType Status Message%ount 2ext+op-omain
******** ************ ****** ************ *************
(xchange*server; Fndefined 9eady 6 server
Suspending (ueue
Ss!end-$ee $ Fse the Suspend*Gueuecmdlet to stop outbound activities for a 8ueue on a
c computer that has the +ub Transport server role or the (dge Transport server role installed.
Synta"
S$"%end-7$e$e -2dentit. &7$e$e2dentit.' (-Con,irm (&SwitchParameter'-- (-4hat2,
(&SwitchParameter'-- (&CommonParameter"'-
Example
Suspend*Gueue *Server (xchSrv;.Testdomain.com
<elow are the other common cmdlets that are used for 8ueue management.
Get-Queue | Freeze-Queue: This command freees all !ueues on the local ser"er.
!essage Tracking
This section discuss some of the cmdlets used for message tracking in exchange server 5667
Traking Emails
Get-#essage%ra&'ing(og$ This cmdlet used to search message information that is stored in the
message tracking log.
S*ntax
Get-3e""ageTrac;ing)og (-DomainController &/1dn'- (-End &DateTime'- (-Event2d &String'- (-
2nternal3e""age2d &String'- (-3e""age2d &String'- (-3e""ageS$bject &String'- (-0eci%ient" &String(-'- (-
0e,erence &String'- (-0e"$ltSi=e &8nlimited'- (-Sender &String'- (-Server &Server2dParameter'- (-Start
&Da teTime'- (&CommonParameter"'-
#
Example
@PSA %$3B get*messagetrackinglog *9ecipients$testHtestdomain.com *Sender CtestHtestdomain.comC
*Server C(xchange*Server;C *(vent- C9(%(>(C
'isting properties o+ the ExchangeServer
Get-E"&hangeServer$ This cmdlet is used to obtain the attributes of a specified s
erver. f a server is not specified, the cmdlet obtains the attributes of a
ll of the servers in the (xchange organi4ation.
Synta"
Get-ExchangeServer (-2dentit. &Server2dParameter'- (-DomainController &/1dn'- (-Stat$"
&SwitchParameter'- (&CommonParameter"'-
Example
@PSA %$3B )et*(xchangeServer . where I&=J.Admin-isplay>ersion *like C?K.;?C' *and &=J.Server9ole *like
CMailboxC'L
ser Administration in Exchange 2007 sing Exchange !anagement
Shell
This section provides some of the user administrative tasks,such as Mailbox management,group
management, that can be performed by using powershell.
!ail%ox !anagement
Creating mail%oxes
,ew&!ail%ox$ cmdlet to create a new user in the Active -irectory dir ectory service and mailbox*enable
this new user.
S*ntax
2ew*Mailbox *2ame MStringB *-atabase M-atabasedParameterB *Password MSecur
$
eStringB *FserPrincipal2ame MStringB @*ActiveSyncMailboxPolicy MMailboxPoli
cydParameterBA @*Alias MStringBA @*%onfirm @MSwitchParameterBAA @*-isplay2
ame MStringBA @*-omain%ontroller M,8dnBA @*,irst2ame MStringBA @*nitials M
StringBA @*1ast2ame MStringBA @*Managed,olderMailboxPolicy MMailboxPolicyd
ParameterBA @*Managed,olderMailboxPolicyAllowed MSwitchParameterBA @*/rgani
4ationalFnit M/rgani4ationalFnitdParameterBA @*9esetPassword/n2ext1ogon M=
true . =falseBA @*SamAccount2ame MStringBA @*Templatenstance MPS/b0ectBA @
*"hatf @MSwitchParameterBAA @M%ommonParametersBA
Example
@PSA %$3B #ew-3ailbox -databa"e >Storage Gro$% ?@3ailbox Databa"e ?> -#ame Con,0oom?
-Organi=ational8nit >Con,erence 0oom"> -Di"%la.#ame >Con,0oom?> -8"erPrinci%al#ame
Con,0oom?ATe"tdomain.com B0oom
!odi+*ing Calendar settings
Set-#ailbo"CalendarSettings $ This cmdlet used to enable calendar processing for a mailbox. "ith this
cmdlet you can configure many parameters on the resource mailbox &maximum meeting duration allowed,
default reminder time, etc...'
S*ntax
Set-3ailboxCalendarSetting" -2dentit. &3ailbox2dParameter' (-6dd6dditional0 e"%on"e &*tr$e + *,al"e'-
(-6dditional0e"%on"e &String'- (-6dd#ew0e1$e"t"Tentativel. &*tr$e + *,al"e'- (-6ddOrgani=erToS$bject
&*tr$e + *,al"e'- (-6ll :oo;2nPolic. &*tr$e + *,al"e'- (-6llowCon,lict" &*tr$e + *,al"e'-
(-6llow0ec$rring3eeting" &*tr$e + *,al"e'- (-6ll0e1$e"t2nPolic. &*tr$e + *,al"e'-
(- 6ll0e1$e"tO$tO,Polic. &*tr$e + *,al"e'- (-6$tomateProce""ing &#one + 6$to8%date + 6$to6cce%t'- (-
:oo;ing4indow2nDa." &2nt<2'- (-:oo;2nPolic. &0eci%ient2dParameter(-'- (-Con,irmSwitchParameter'--
(-Con,lictPercentage6llowed &2nt<2'- (-De,a$lt0eminderTime &2nt<2'-
(-Delete6ttachment" &*tr$e + *,al" e'- (-DeleteComment" &*tr$e + *,al"e'- (-Delete#onCalendar2tem"
&*tr$e + *, al"e'- (-DeleteS$bject &*tr$e + *,al"e'- (-Di"able0eminder" &*tr$e + *,al"e '-
(-dmainController &/1dn'- (-Enable0e"%on"eDetail" &*tr$e + *,al"e'-
(-E n,orceSched$lingori=on &*tr$e + *,al"e'- (-/orward0e1$e"t"ToDelegate" &*tr $e + *,al"e'- (-
2gnoreDe,a$ltSco%e &SwitchParameter'- (-3axim$mCon,lict2n"t ance" &2nt<2'-
(-3axim$mD$ration2n3in$te" &2nt<2'- (-Organi=er2n,o &*tr$e + *,al"e'-
(-Proce""External3eeting3e""age" &*tr$e + *,al"e'-
(-0emove/orwarded3eeting#oti,ication" &*tr$e + *,al"e'- (-0emoveOld3eeting3e""age" &*tr$e +
*,al"e'-
(-0emovePrivatePro%ert. &*tr$e + *,al"e'- (-0e1$e"t2nPolic. &0eci%ient2dParameter(-'- (-
0e1$e"tO$tO,Polic. &0eci%ient2dParameter(-'-
1%
(-0e"o$rceDelegate" &0eci%ient2dParameter(-'- (-Sched$leOnl.D$ring4or;o$r" &*tr$e + *,al"e'- (-
TentativePending6%%roval &*tr$e + *,al"e'- (-4hat2, (&Switc hParameter'-- (&CommonParameter"'-
Example
@PSA %$3B Set*Mailbox%alendarSettings *dentity C%onference 9oomC *AutomateProcessing AutoAccept

Checking Calendar settings
Get-#ailbo"CalendarSettings $ This cmdlet is used to retrieve the %alendar Attendant configuration on
the target mailbox
S*ntax
Get-3ailboxCalendarSetting" (-2dentit. &3ailbox2dParameter'- (-Credential & PSCredential'- (-
DomainController &/1dn'- (-2gnoreDe,a$ltSco%e &SwitchParameter'- (-Organi=ational8nit
&Organi=ational8nit2dParameter'- (-0ead/romDomainController &SwitchParameter'- (-0e"$ltSi=e
&8nlimited'- (-Sort:. &String' - (&CommonParameter"'-
Example
@PSA %$3B)et*Mailbox%alendarSettings *dentity test3testcalendar .,1
AutomateProcessing $ AutoAccept
Allow%onflicts $ ,alse
<ooking"indown-ays $ ;K6
Maximum-urationnMinutes $ ;NN6
Allow9ecurringMeetings $ True
(nforceScheduling+ori4on $ True
Schedule/nly-uring"ork+ours $ ,alse
%onflictPercentageAllowed $ 6
!oving !ail%ox
!ove&mail%ox$!ou can use the Move*Mailbox cmdlet to perform the following tasks$
? Move a mailbox between servers in an organi4ation. This move might be use ful during hardware or
software upgrades.
? Move a mailbox between servers in different organi4ations. This move migh
t be useful when organi4ations merge network infrastructures.
S*ntax
11
move-3ailbox -2dentit. &3ailbox2dParameter'-TargetDataba"e&Databa"e2dParameter' (-:ad2tem)imit
&2nt<2'-(-Con,irm(&SwitchParameter'--(-DomainContoller&/1dn'-(-GlobalCatalog&/1dn'-
(-2gnorePolic.3atch &SwitchParameter' - (-3axThread" &2nt<2'- (-0e%ort/ile &)ocal)ong/$llPath'- (-
CalidateOnl. &S witchParameter'- (-4hat2, (&SwitchParameter'-- (&CommonParameter"'-
Example
@PSA %$3B Move*Mailbox testHTestdomain.com *Target-atabase 2ewMailbox-atabase
!odi+*ing mail%ox settings
Set&!ail%ox$ This cmdlet to modify the settings of an existing mailbox. !ou can use this cmdlet for one
mailbox at a time. To perform bulk management, you can pipeline the output of various )et* cmdlets.this
cmdlet can be used to %onfigure 9esource Mailbox Properties
set*Mailbox *dentity MMailboxdParameterB @*AcceptMessages/nly,rom M9ecipientdParameter@ABA @*
AcceptMessages/nly,rom-1Members M9ecipientdParameter@ABA
@*Alias MStringBA @*Antispam<ypass(nabled M=true . =falseBA
@*ApplyMand atoryProperties MSwitchParameterBA @*%onfirm @MSwitchParameterBAA
@*%reate-TM,Map M=true . =falseBA @*%ustomAttribute; MStringBA
@*%ustomAttribute;6 M StringBA @*%ustomAttribute;; MStringBA
@*%ustomAttribute;5 MStringBA @*%ustomAttribute;E MStringBA @*%ustomAttribute;N MStringBA
@*%ustomAttribute;O M StringBA @*%ustomAttribute5 MStringBA @*%ustomAttributeE MStringBA
@*%ustom AttributeN MStringBA @*%ustomAttributeO MStringBA
@*%ustomAttributeP MStringBA @*%ustomAttribute7 MStringBA
@*%ustomAttributeK MStringBA @*%ustomAttri buteQ MStringBA @*-eliverToMailboxAnd,orward M=true .
=falseBA @*-isplay2am e MStringBA @*-omain%ontroller M,8dnBA @*
-og0mwngrade+ighPriorityMessages(nabled M=true . =falseBA @*(mailAddresses
MProxyAddress%ollectionBA @*(mailAddressPolicy(nabled M=true . =falseBA @*(nd-ate,or9etention+old
M2ullableBA @*(xtensions MMulti>aluedPropertyBA @*(xternal/of/ptions Mnternal/nly . (xternalBA
@*,orwardingAddress M9ecipientdParameterBA
@*)rantSend/n<ehalfTo MM ailbox/rMailFserdParameter@ABA @*+idden,romAddress1ists(nabled M=true .
=falseBA @*gnore-efaultScope MSwitchParameterBA @*ssue"arningGuota MFnlimitedBA @*1anguages
MMulti>aluedPropertyBA @*1inked%redential MPS%redentialBA
12
@*1inked-omain%ontroller MStringBA @*1inkedMasterAccount MFserdParameterBA @*
Managed,olderMailboxPolicy MMailboxPolicydParameterBA @*Managed,olderMailboxPolicyAllowed
MSwitchParameterBA @*Max<lockedSenders M2ullableBA @*Max9eceiveSi4e MFnlimitedBA @*
MaxSafeSenders M2ullableBA @*MaxSendSi4e MFnlimitedBA @*2ame MStringBA @*/ffice MStringBA @*
/fflineAddress<ook M/fflineAddress<ookdParameterBA @*PrimarySmtpAddress MSmtpAddressBA @*
ProhibitSendGuota MFnlimitedBA @*ProhibitSend9eceiveGuota MFnlimitedBA
@*9ecipient1imits MFnlimitedBA @*9e0ectMessages,rom M9ecipientdParameter@ABA
@*9e0ectMessages,rom-1Members M9ecipientdParameter@ABA
@*9emoveManaged,olderAndPolicy MSwit chParameterBA @*9e8uireSenderAuthentication(nabled M=true
. =falseBA @*9esource%apacity M2ullableBA @*9esource%ustom MMulti>aluedPropertyBA
@*9etain-eletedtems,or M(nhancedTimeSpanBA @*9etain-eletedtemsFntil<ackup M=true .
=falseBA @*9etention+old(nabled M=true . =falseBA @*9ulesGuota M<yteGuantif iedSi4eBA @*
SamAccount2ame MStringBA @*S%1-elete(nabled M2ullableBA
@*S%1-eleteThreshold M2ullableBA @*S%1Runk(nabled M2ullableBA
@*S%1RunkThreshold M 2ullableBA @*S%1Guarantine(nabled M2ullableBA @*S%1GuarantineThreshold M2ul
lableBA @*S%19e0ect(nabled M2ullableBA @*S%19e0ectThreshold M2ullableBA
Example
@PSA %$3BSet*Mailbox *dentity C9esourceMailbox6;C *9esource%ustom &CT>C,C>%9C' *9esource%apacity
O6
-iewing mail%ox o%.ects
)et*Mailbox $ This cmdlet used to view mailbox ob0ects and attributes, to popul
ate property pages, or to supply mailbox information to other tasks.
Synta"
get*Mailbox @*dentity MMailboxdParameterBA @*%redential MPS%redentialBA @
*-omain%ontroller M,8dnBA @*gnore-efaultScope MSwitchParameterBA @*/rgani4
ationalFnit M/rgani4ationalFnitdParameterBA @*9ead,rom-omain%ontroller MSw
itchParameterBA @*9ecipientType-etails M9ecipientType-etails@ABA @*9esultSi
Example
@PSA %$3B )et*Mailbox */rgani4ationalFnit Fsers
13
<elow are the other common cmdlets that are used for Mail management
Get-MailboxStatistis -Database MailboxDatabase: This command retrie"es
the mailbox statistics for all mailboxes that are located in the mailbox database
named MailboxDatabase.
!nable-Mailbox -Identity "estdomain#user$ -Database MailboxDatabase:
This command mailbox&enables an existing 'cti"e (irector) user with the domain
and alias combination Testdomain\user1 b) creating a mailbox in the mailbox
database named MailboxDatabase
Disable -Mailbox -Identity user$: This command mailbox&disables the user with
the alias user1 b) remo"ing its associated mailbox.
!anging "roups
!odi+*ing $istri%ution "roup Settings
Set-DistribtionGro!$cmdlet to modify the settings of an existing distribution group,such as
name,display name,delivery restrictions etcS.
S*ntax
Set-Di"trib$tionGro$%-2dentit.&Di"trib$tionGro$%2dParameter'(-6cce%t3e""age"Onl./rom
&0eci%ient2dParameter(-'- (-6cce%t3e""age"Onl./romD)3ember" &0eci%ient2dParameter(-'- (-6lia"
&String'- (-Con,irm (&SwitchParameter'-- (-CreateDT3/3a% &*tr$e + *,al"e'- (-C$"tom6ttrib$te?
&String'- (-C$"tom6ttrib$te?0 &String'- (-C$"tom6ttrib$te?? &String'- (-C$"tom6ttrib$te?2 &String'-
(-C$"tom6ttrib$te?< &String'- (-C$"tom6ttrib$te?D &String'- (-C$"tom6ttrib$te?E &String'- (-
C$"tom6ttrib$te2 &String'- (-C$"tom6ttrib$te< &String'- -C$"tom6ttrib$teD &String'- (-C$"tom6ttrib$teE
&String'- (-C$"tom6ttrib$teF &String'- (-C$"tom6ttrib$te7 &String'- (-C$"tom6ttrib$teG &String'- (-C$"t
om6ttrib$teH &String'- (-Di"%la.#ame &String'- (-DomainController &/1dn'-
-Email6ddre""e" &Prox.6ddre""Collection'- (-Email6ddre""Polic.Enabled &*tr$ e + *,al"e'- (-
Ex%an"ionServer&String'-(-GrantSendOn:ehal,To&3ailboxOr3ail8"er2dParameter(-'-
(-idden/rom6ddre"")i"t"Enabled &*tr$e + *,al"e'- (-2gnoreDe,a$ltSco%e &SwitchParameter'- (-
3anaged:. &General0eci%ient2dParameter'- (-3ax0eceiveSi=e &8nlimited'- (-3axSendSi=e
&8nlimited'- (-#ame &String'- (-Primar.Smt%6ddre"" &Smt%6ddre""'- (-0eject3e""age"/rom
&0eci%ient2dParameter(-'- (-0eject3e""age"/romD)3ember" &0eci%ient2dParameter(-'- (-0e%or
tTo3anagerEnabled&*tr$e+*,al"e'-(-0e%ortToOriginatorEnabled&*tr$e+*,al"e'-
(-0e1$ireSender6$thenticationEnabled&*tr$e+*,al"e'-(-Sam6cco$nt#ame&String'-
(-SendOo,3e""ageToOriginatorEnabled &*tr$e + *,al"e'- (-Sim%l eDi"%la.#ame &String'- (-83Dtm,3a%
14
&3$ltiCal$edPro%ert.'- (-4hat2, (&Switch Parameter'-- (-4indow"Email6ddre"" &Smt%6ddre""'-
(&CommonParameter"'-
Get-DistribtionGro!$ This cmdlet used to 8uery for existing distribution gro ups.
Synta"
Get-Di"trib$tionGro$% (-2dentit. &Di"trib$tionGro$%2dParameter'- (-Credenti
al &PSCredential'- (-DomainController &/1dn'- (-2gnoreDe,a$ltSco%e &SwitchP
arameter'- (-3anaged:. &General0eci%ient2dParameter'- (-Organi=ational8nit
&Organi=ational8nit2dParameter'- (-0ead/romDomainController &SwitchParamete
r'- (-0eci%ientT.%eDetail" &0eci%ientT.%eDetail"(-'- (-0e"$ltSi=e &8nlimite
d'- (-Sort:. &String'- (&CommonParameter"'-

Ena%le&$istri%ution"roup &Identit* )%estdomain*Distribtion Gro!I J This command mail*enables
the existing universal distribution group named Di"trib$tion Gro$% that is in the Te"tdomain domain.
$isa%le&$istri%ution"roup &Identit* DGJ This command mail*disables the mail*enabled universal
distribution group named DG.
#e+erences
!astering Exchange 2007 %* /arr* "er%er
0indows PowerShell -2 ser "uide
Exchange !anagement Shell (uick #e+ernce
15

Das könnte Ihnen auch gefallen