Skip to content

Instantly share code, notes, and snippets.

@fluggelgleckheimlen
Created February 2, 2024 09:15
Show Gist options
  • Save fluggelgleckheimlen/56abff246a0e705fd359b230159c412d to your computer and use it in GitHub Desktop.
Save fluggelgleckheimlen/56abff246a0e705fd359b230159c412d to your computer and use it in GitHub Desktop.
Заполняет SimpleDisplayName при создании почтового ящика
<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="NewMailbox" Cmdlets="New-Mailbox">
<ApiCall Name="OnComplete">
If ($succeeded)
{
Start-Sleep -s 20
$DC = [string]($readOnlyIConfigurable.originatingserver)
$User = Get-User -Identity $provisioningHandler.UserSpecifiedParameters["Alias"]
$Alias = Get-Mailbox -Identity $user.DistinguishedName
If (($Alias.IsShared -eq $False) -and ($Alias.IsLinked -eq $False) -and ($Alias.IsResource -eq $False) -and ($Alias.IsRootPublicFolderMailbox -eq $False))
{
$SDN = "$($User.FirstName) $($User.LastName)";
$SDN = $SDN.Trim();
If ($SDN -match '[A-Z]+') {
Set-User $User -simpleDisplayName $SDN
}
}
}
</ApiCall>
</Feature>
<Feature Name="EnableMailbox" Cmdlets="Enable-Mailbox">
<ApiCall Name="OnComplete">
If ($succeeded)
{
Start-Sleep -s 20
$DC = [string]($readOnlyIConfigurable.originatingserver)
$User = Get-User -Identity $provisioningHandler.UserSpecifiedParameters["Alias"]
$Alias = Get-Mailbox -Identity $user.DistinguishedName
If (($Alias.IsShared -eq $False) -and ($Alias.IsLinked -eq $False) -and ($Alias.IsResource -eq $False) -and ($Alias.IsRootPublicFolderMailbox -eq $False))
{
$SDN = "$($User.FirstName) $($User.LastName)"
$SDN = $SDN.Trim()
If ($SDN -match '[A-Z]+') {
Set-User $User -simpleDisplayName $SDN
}
}
}
</ApiCall>
</Feature>
</Configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment