Script to grant dial-in access in Active Directory

I have found that is not a trivial task to change the dial-in permission in an Active Directory user or computer because you must update the userParameters attribute at the same time that the msNPAllowDialin.

In the KB252398, Microsoft says to download the Active Directory Service Interface, so you can register adsras.dll, and use the ADSI interface it provides, but the download is no longer available.

I have managed to create a script to allow dial-in: first, I have allowed manually a user to dial-in, and then I pick those permissions and apply them to the rest.

[Read More]

Eliminar buzones de usuarios deshabilitados en Exchange 2010

Aquí os pongo un script que borra los buzones de Exchange de los usuarios deshabilitados en AD. Comprueba que sean del tipo UserMailbox, porque hay buzones como los RoomMailbox cuyo usuario está deshabilitado, cuidado con esto.

Es necesario tener instalado los comandos powershell para Active Directory de Quest.

# Script que deshabilita los buzones de todos los usuarios de AD deshabilitados

Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue | Out-Null
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue | Out-Null

$DisabledMailboxes = New-Object -TypeName Microsoft.Exchange.Data.Directory.Management.Mailbox
$DisabledMailboxes = $null
Get-QADUser -Disabled -SizeLimit 0 | foreach-object {
   $ID = $_.samaccountname
   $mbx = Get-Mailbox -Identity $ID -RecipientTypeDetails UserMailbox  -ErrorAction SilentlyContinue
   If ($mbx) {
      Write-Host "Añado a la lista: " $mbx.Name
      $DisabledMailboxes += $mbx
   }
}
If ($DisabledMailboxes) {
   $DisabledMailboxes | foreach-object {
      Write-Host "Deshabilito el buzón: " $_.Name
      $_ | Disable-Mailbox -Confirm:$false
   }
}
Get-MailboxDatabase | Clean-MailboxDatabase