PowerShell
De Ardemans Wiki
Revisión a fecha de 06:53 26 jul 2012; Pmblanco (Discusión | contribuciones)
Contenido
Editores para trabajar más fácil
Ejemplos de ayuda en powershell
Buscando en el directorio activo
$myad= [ADSI]"LDAP://dc=prisacom,dc=int" $search = new-object DirectoryServices.DirectorySearcher($myad) $search.filter = "(samaccountname=pmblanco)" $search.findall()
Creando un contacto en el Directorio Activo
$destOU = [ADSI]"LDAP://ou=meristation,ou=Lista de contactos,ou=Listas PRISACOM,dc=prisacom,dc=int" $contacto = $destOU.create("Contact","cn=contacto de prueba") $contacto.Put("Description","Descripcion del contacto") $Contacto.Put("Displayname","Nombre a mostrar") $Contacto.Put("Mail","mail@contacto.com") $Contacto.Put("company","Prisa Digital") $Contacto.Put("department","Meristation") $Contacto.setInfo()
Recorrer un fichero y usar sus elementos
listacontactos = type c:\ps\Meristation\contactos_nuevos.txt foreach ($contacto in $listacontactos) { echo $contacto }
Convertir un dato ObjectSID de AD a hexadecimal
# Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx param ( [string]$SidString ) # Create SID .NET object using SID string provided $sid = New-Object system.Security.Principal.SecurityIdentifier "S-1-5-21-1645522239-1004336348-1801674531-512" # Create a byte array of the proper length $sidBytes = New-Object byte[] $sid.BinaryLength #Convert to bytes $sid.GetBinaryForm( $sidBytes, 0 ) # Iterate through bytes, converting each to the hexidecimal equivalent $hexArr = $sidBytes | ForEach-Object { $_.ToString("X2") } # Join the hex array into a single string for output $hexArr -join ''