Crear cuentas de usuario

Vamos a ver como crear cuentas de usuario, incluyendo el buzón de correo, su directorio personal, su directorio de perfil. Necesitas 1) Exchange 2007 Management Shell Snapin; 2)Quest Active Roles management PS snapin; and, 3) xcacls.vbs en el mismo directorio que el script.  El script esta documentado en ingles, pero creo que esto no tiene que ser gran problema.

 

Write-Host "============ Create new domain user ============" -foregroundcolor Cyan
 
$username = Read-Host "Username "
## check if only letters were used
$regex = "^([a-zA-Z]+)$" ## only text, no spaces, no numbers
If ($username -notmatch $regex) {
      Write-Host "Invalid username specified. $username" -foregroundcolor Cyan
      break
}
 
## Check if there's already a user with this samAccountName
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$domainnb = "DOMAIN"
$root = $dom.GetDirectoryEntry()
 
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.Filter = "(samAccountName=$username)"
$result = $search.FindOne()
 
if ($result -ne $null) {
      $user = $result.GetDirectoryEntry()
      Write-Host "There is already a useraccount $username." -foregroundcolor Cyan
      Write-Host "User found: " $user.distinguishedName -foregroundcolor Cyan
      break
}
 
$surname = read-host "User's last name (surname) "
$regex = "^([a-zA-Z'-]+)$" ## allows characters and dashes only
If ($surname -notmatch $regex) {
      Write-Host "Invalid surname specified. $surname" -foregroundcolor Cyan
      break
}
 
$tussenvoegsel = read-host "Infix. I.e. van den "
 
$name = Read-Host "User's first name "
 
$tel = Read-Host "Extension number "
$regex = "^(7|8)\d{3}$" ## 4 digit extension numbers, starting with 7 or 8 only.
If ($tel -notmatch $regex) {
      Write-Host "Invalid extension number specified. $tel" -foregroundcolor Cyan
      break
}
 
$passwd = Read-Host "Specify user's password "
## Password must be at least 6 characters, 
## no more than 15 characters, 
## and must include at least one upper case letter, 
## one lower case letter, and one numeric digit.
$regex = "^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}$"
If ($password -notmatch $regex) {
      Write-Host "Invalid password specified. $password" -foregroundcolor Cyan
      break
}
 
$DisplayName = "$surname, $name $tussenvoegsel"
$homeroot = "\\server1\mydocuments"
$profileroot = "\\server1\profiles"
 
Write-Host "================================================" -foregroundcolor Cyan
Write-Host "Creating user $DisplayName using New-Mailbox cmdlet.." -foregroundcolor Cyan
 
New-Mailbox -Name $DisplayName.Trim() `
      -Database "EXCHSRVR\Mailbox Store\Mailbox Database" `
      -Password (convertto-securestring $passwd -asplaintext -force) `
      -UserPrincipalName $username@DOMAIN.LOCAL `
      -ActiveSyncMailboxPolicy "Default" `
      -Alias $username `
      -Confirm `
      -DisplayName ($DisplayName.Trim()) `
      -FirstName "$name $tussenvoegsel" `
      -LastName $surname `
      -OrganizationalUnit "DOMAIN.LOCAL/OU Users " `
      -ResetPasswordOnNextLogon $true `
      -SamAccountName $username
 
## Wait for DC's to pick up change
Start-Sleep -s 10
 
## Modify user properties
Get-QADUser $username | Set-QADUser -PhoneNumber $tel `
                                   -UserPassword $passwd
 
Write-Host "================================================" -foregroundcolor Cyan
 
## Create home directory with permissions
If ( !(Test-Path -Path "$homeroot\$username" -PathType Container) ) {
      ## Doesn't exist so create it.
      Write-Host "home directory doesn't exist. Creating home directory." -ForegroundColor Cyan
      
      ## Create the directory
      New-Item -path $homeroot -Name $username -ItemType Directory
      $homedir = "$homeroot\$username"
      
      ## Modify  Permissions on homedir
 
      ## Instead of using the .NET approach of setting NTFS permissions, using xcacls is quicker:
      cscript xcacls.vbs $homedir /E /G `"$nbdomain\$username`":M
      
      ## The .NET approach - remmed out
      ## To list available rights options, run: [system.enum]::getnames([System.Security.AccessControl.FileSystemRights])
      ## To list available inheritance flags, run: [system.enum]::getnames([System.Security.AccessControl.InheritanceFlags])
      ## Idem for Propagation flags.
      #$newrights = [System.Security.AccessControl.FileSystemRights]"Modify"
      #$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::"ObjectInherit"
      #$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::"InheritOnly"
      #$Typ = [System.Security.AccessControl.AccessControlType]::Allow
      #$ID = new-object System.Security.Principal.NTAccount($domainnb + "\" + $username)
      #$SecRule = new-object System.Security.AccessControl.FileSystemAccessRule($ID, $newrights, $InheritanceFlag, PropagationFlag, $Typ)
      
      #$myACL = Get-Acl -Path $homedir
      #$myACL.AddAccessRule($SecRule) 
      #Set-ACL -AclObject $myACL $homedir
}
Else {
      Write-Host "home directory already exists. Script end." -ForegroundColor Cyan
      Break
}
 
## Create Profile directory with permissions
If ( !(Test-Path -Path "$profileroot\$username" -PathType Container) ) {
      ## Doesn't exist so create it.
      Write-Host "profile directory doesn't exist. Creating profile directory." -ForegroundColor Cyan
      
      ## Create the directory
      New-Item -path $profileroot -Name $username -ItemType Directory
      $profiledir = "$profileroot\$username"
 
      ## Modify Permissions on profile dir
 
      ## Instead of using the .NET approach of setting NTFS permissions, using cacls is quicker:
      cscript xcacls.vbs $profiledir /E /G `"$nbdomain\$username`":M
      
      ## The .NET approach - remmed out
      ## To list available rights options, run: [system.enum]::getnames([System.Security.AccessControl.FileSystemRights])
      ## To list available inheritance flags, run: [system.enum]::getnames([System.Security.AccessControl.InheritanceFlags])
      ## Idem for Propagation flags.
      #$newrights = [System.Security.AccessControl.FileSystemRights]"Modify"
      #$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::"None"
      #$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::"None"
      #$Typ = [System.Security.AccessControl.AccessControlType]::Allow
      #$ID = new-object System.Security.Principal.NTAccount($domainnb + "\" + $username)
      #$SecRule = new-object System.Security.AccessControl.FileSystemAccessRule($ID, $newrights, $InheritanceFlag, PropagationFlag, $Typ)
      #$myACL = Get-Acl -Path $profiledir
      #$myACL.AddAccessRule($SecRule) 
      #Set-ACL -AclObject $myACL $profiledir
}
Else {
      Write-Host "profile directory already exists. Script end." -ForegroundColor Cyan
      Break
}
 
## Modify user properties
Get-QADUser $username | Set-QADUser -ObjectAttributes @{homeDrive='H:';homeDirectory=$homedir;profilePath=$profiledir}
 
## User created. Listing properties
$info = Get-QADUser $username -IncludeAllProperties | fl DN,Name,DisplayName,userPrincipalName, `
      samAccountName,givenName,sn,homeDrive,homeDirectory, `
      ProfilePath,telephoneNumber,email
 
Write-Host "User created with the following properties: " -ForegroundColor Cyan
$info
 
Write-Host "================= Script End =================" -foregroundcolor Cyan

Una visión rápida de Service Manager 2010

Aquí os dejo los link de una serie de videos bastante ilustrativos sobre Service Manager y sus capacidades, espero que los disfrutéis tanto como yo.

System Center Service Manager 2010: Self Service Portal Feature:

BBT2+

Introducción a System Center Service Manager 2010

Clare Henry, Director, Technical Product Marketing, nos hace una breve introducción a Service Manager 2010. Es una pena que esta gente no sepa hablar otra cosa que no sea inglés, pero bueno que se la va a hacer. Podéis descargarlo desde aquí

BBT2+

Que no, que el PC no va a morir … que ya esta muerto

En esta época tan crítica, Facebook la caga con la seguridad otra vez más, seguimos con los suicidios en la fábrica de los “aparatitos de Apple”, la bolsa cae (una vez más como no), BP manchando las costas de USA, el pinball que vuelve a resucitar (¿Cuantas veces a muerto ya?) y Zapatero sin dimitir, vemos que nuestro amigo Steve Ballmer confirma lo que ya se venía oliendo desde hace tiempo, “el PC no está muerto, es que solamente va a evolucionar (¿Cómo Windows?)”.

Elije tu veneno Steve Ballmer se rieSteve Jobs señala

Claro, Claro, eso decía mi padre de su viejo seiscientos “ …nene el coche no está muerto, es que va a evolucionar”. El PC tiene los días contados si de verdad queremos “subirnos a la nube”, la gracia de que nuestra información este en la nube, nada tiene que ver con el pago p or uso o con el ahorro de costes (aunque no deberemos descartarlo), sino más bien con la disponibilidad de la información y la seguridad de la misma sin que esto suponga un gasto extra a las compañías. Pues bien, si queremos de verdad usar el “Cloud” tendremos que confiar u desarrollar dispositivos mas móviles, más ligeros, con más autonomía y más versátiles a la hora de poder conectarse cuando y donde se necesite a nuestra información.

Por esto mismo, podemos afirmar que el PC no está muerto, el concepto es y seguirá siendo genial, los que están muertos son los clonadores de la idea, que siguen desarrollando PC demasiado pesados, con poca batería y poco versátiles para tener que llevarlos de un sitio a otro. En esto, sí que ha dado en el clavo nuestro Steven Jobs, el iPad es ese cacharro que está a medias entre un teléfono móvil con acceso a datos y un netbook, pero solventando los problemas de conectividad y duración de la batería que tienen sus antecesores. Y esto, que no nos engañemos señores, el “iPad no es perfecto”, pero de momento es lo más cerca que la tecnología ha estado de la perfección en los últimos años.

Ballmer ! aúpa machote ¡¡¡ que se te muere el Windows …..

BBT2+