Professional Documents
Culture Documents
DESCRIPTION
# This script adds a constraint with the given properties to the provided
organizations.
#
# .PARAMETER ConstraintName
# The name of the constraint to be added
#
# .PARAMETER ConstraintReason
# The reason for the constraint.
#
# .PARAMETER ConstraintExpirationDate
# The date the constraint will expire. Please use DateTime.MinValue to indicate
a constraint which will never expire automatically.
#
# .PARAMETER OrgList
# An array of organizations to which the specified constraint will be added.
# Any organization identity parameters which can be used to look up the
organization using Get-Organization will work.
#
# .EXAMPLE
# Set-OrganizationConstraint.ps1 -ConstraintName "MigConstraint" -
ConstraintReason "Example" -ConstraintExpirationDate $(get-date) -OrgList
@("testtenant1.com", "testtenant2.com")
# This will add constraints with the name "MigConstraint", reason "Example" and
expiration date of the current time to testtenant1.com and testtenant2.com
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
RISK
# OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $ConstraintName,
[Parameter(Mandatory=$true)]
[string] $ConstraintReason,
[Parameter(Mandatory=$true)]
[DateTime] $ConstraintExpirationDate,
[Parameter(Mandatory=$true)]
$OrgList
)
$constraint = new-object
Microsoft.Exchange.Data.Directory.SystemConfiguration.UpgradeConstraint($Constraint
Name,$ConstraintReason,$ConstraintExpirationDate);
foreach ($org in $OrgList)
{
write-host "Adding constraint $ConstraintName to $org";
$orgInfo = get-organization $org;
$orgConstraints = $orgInfo.UpgradeConstraints;