Home > Articles > Microsoft > MCTS

Exchange Server 2010 Portable Command Guide: Advanced Techniques

This chapter provides information and commands covering working with pipelines, running programs, creating and running scripts, registry modifications with PowerShell, and understanding quotes in Exchange Server 2010.
This chapter is from the book

This chapter provides information and commands concerning the following topics:

  • Working with pipelines
  • Running programs
  • Creating and running scripts
  • Registry modifications with PowerShell
  • Understanding quotes

Working with Pipelines

When you pipeline, you take the output of one cmdlet and use it in a subsequent cmdlet to perform another operation. This simple act ensures that you can string together very simple cmdlets into complex operations. Some of the reasons you may wish to pipeline include the following:

  • You need to pass data from the output of one cmdlet to a subsequent cmdlet.
  • You need to perform multiple actions on one or more Exchange objects without having to do so individually.
  • You need to pass data output between dissimilar nouns.
  • You need the system to report errors or warnings.

You can use pipelining to pass data from the output of one cmdlet to a subsequent cmdlet in order to perform another operation. This operation might work like what's shown in the following table.

Get-User
-OrganizationalUnit OUName
| Enable-Mailbox
-Database "DatabaseName"
PS C:\UsersAdministrator>Get-User
-OrganizationalUnit
Assemblers |
Enable-Mailbox
-Database "AssemblyDB"
               

After acquiring a new assembly plant in Philadelphia, you need to create mailboxes in the AssemblyDB database for all users in the Assemblers OU, which is a child of the Philadelphia OU.

This pipelined cmdlet retrieves a list of all users in the Assemblers OU and passes the resultset to the Enable-Mailbox cmdlet, which creates the mailboxes for those users.

In Figure 3-1, you can see that there are two users in the Assemblers OU in Active Directory Users and Computers. However, in Figure 3-2, there are no mailboxes present for these users.

Figure 3-3 demonstrates the cmdlet used for creating mailboxes for existing users using a Get-User cmdlet piped to an Enable-Mailbox cmdlet. Finally, in Figure 3-4, you can see that the mailboxes have been created.

Figure 3-1 Users in the Assemblers OU in Active Directory Users and Computers

Figure 3-2 No mailboxes present in the Exchange Management Console for the Assemblers OU users

Figure 3-3 Mailboxes for users in the Assemblers OU created with the Enable-Mailbox cmdlet

Figure 3-4 Mailboxes now present in the Exchange Management Console for the Assemblers OU users

You can also use pipelining to combine several actions. In that way, you can use one cmdlet to gather the mailboxes for all managers, VPs, and anyone in the Assembly department in your organization who has an Exchange mailbox and then a second cmdlet to set multiple quota values on those distinct groups of mailboxes. Performing multiple actions on Exchange objects might work like what's shown in the following table.

                  Get-User -Filter {((Title -like
                  Title1Name) -or (Title -like Title2Name)

                  -or (Department -eq DepartmentName
                  ))


                  -and (RecipientTypeDetails -eqRecipientType
                  )} | Set-Mailbox


                  -IssueWarningQuota size1

                  -ProhibitSendQuota size2


                  -ProhibitSendReceiveQuota size3


                  -UseDatabaseQuotaDefaults $boolean value

                  PS C:\Users\Administrator>Get-User

                  -Filter {((Title -like "*Manager*") -or

                  (Title -like "*VP*") -or (Department -eq

                  "Assembly")) -and (RecipientTypeDetails

                  -eq "UserMailbox")} |

                  Set-Mailbox -IssueWarningQuota

                  900MB -ProhibitSendQuota 1GB

                  -ProhibitSendReceiveQuota unlimited

                  -UseDatabaseQuotaDefaults $false

               

You have very distinct groups of users who need unique quotas applied to their mailboxes. You cannot use a quota at the database level because these users are spread across multiple databases.

All managers, VPs, and users in the Assembly department need these quotas applied to their mailboxes regardless of the server or database where their mailbox is located.

You can combine the collecting of the distinct groups of users with the application of the unique quotas on the mailboxes with a piped cmdlet, as shown.

You can pipe data between dissimilar nouns. You might find that you want to use the data from one cmdlet within another cmdlet, but the object types do not match. This can happen if one cmdlet references one noun (such as by importing information from a .csv file with an Import-CSV cmdlet, where "CSV" is the noun) and you then want to use that imported data to create a new user account as well as an Exchange mailbox, which you can do with the New-Mailbox cmdlet, where "Mailbox" is the noun. Finally, you might wish to add title and department attributes to the user account (not the mailbox), which references the "User" noun. Passing data output between dissimilar nouns might work like what's shown in the following table.

                  Import-CSV "C:\filename.csv" |

                  ForEach-Object -Begin {
                  $Pass =

                  ConvertTo-SecureString password
                  -asPlainText -force} -Process
                  {New-Mailbox -Name $_.Name
                  -UserPrincipalName
                  "$($_.UserName)@
                  DomainName"
                  -OrganizationalUnit "OUName" -Database
                  "DatabaseName" -Password $Pass
                  -ResetPasswordOnNextLogon $true |
                  Set-User
                  -Title $_.Title -Department
                  $_.Department}
                  PS C:\Users\Administrator>Import-CSV
                  "C:\FileFromHR.csv" |
                  ForEach-Object -Begin {$Pass =
                  ConvertTo-SecureString "Pa$$w0rd"
                  
                  -asPlainText -force} -Process
                  {New-Mailbox -Name $_.Name
                  -UserPrincipalName "$($_.UserName)
                  @DomainName"
                  -OrganizationalUnit "OUName" -Database
                  "DatabaseName"
                  -Password $Pass
                  -ResetPasswordOnNextLogon $true |
                  Set-User
                  -Title $_.Title -Department
                  $_.Department}
               

You need to import several users from a .csv file given to you by the HR department. The noun initially used is "CSV".

You then wish to create the user and the mailbox at the same time, but that requires setting a password for each user. You create a password and save it as a secure string, which the Active Directory will accept. You use a variable ($Pass) to store the secure string password. This involves the New-Mailbox cmdlet, which utilizes the "Mailbox" noun.

Finally, you want to add values to title and department, which are properties of the user, so you need to reference the "User" noun to do that.

You can also report errors or warnings though pipelining, which might work like what's shown in the following table.

                  $Name = "Custom Text"
                   PS C:\Users                   Administrator>
                   $Warn
                  = "This is an example
                  of a custom warning
                  that you might create that could provide
                  an onscreen warning
                  when some condition
                  exists."
                  $Name | Write-Warning
                  PS C:\Users                  Administrator>
                     $Warn |
                  Write-Warning
               

This illustrates how you could pipe a string to the Write-Warning cmdlet.

You could save the string in a variable, as shown in the first pair of cmdlets, and then pipe the string to Write-Warning, as shown in the second pair of cmdlets.

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |