Diferencia entre revisiones de «PowerShell»
De Ardemans Wiki
(→Docus sobre powershell) |
|||
Línea 1: | Línea 1: | ||
− | == | + | == Ejecución remota en PowerShell == |
[http://technet.microsoft.com/en-us/magazine/ff700227.aspx Habilitar PowerShell remoto] | [http://technet.microsoft.com/en-us/magazine/ff700227.aspx Habilitar PowerShell remoto] | ||
+ | |||
+ | <pre> | ||
+ | invoke-command -computername svcensync1 -scriptblock {Add-PSSnapin Coexistence-Configuration;Start-OnlineCoexistenceSync} | ||
+ | </pre> | ||
== Ejemplos de ayuda en powershell == | == Ejemplos de ayuda en powershell == |
Última revisión de 05:46 7 sep 2012
Contenido
Ejecución remota en PowerShell
invoke-command -computername svcensync1 -scriptblock {Add-PSSnapin Coexistence-Configuration;Start-OnlineCoexistenceSync}
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 ''