Está en la página 1de 2

consultas via powershell a active directory

- PS D:\> get-aduser -Properties * -Identity claudio.aliste | fl <- veo los datos


completos de la cuenta

Consulta con filtros en campos de cuenta y exportacion a un archivo CSV


- PS D:\> get-aduser -Properties * -filter * | select
samaccountname,displayname,DistinguishedName,accountExpires,EmailAdd
ress,Enabled | Export-Csv -Delimiter ";" -path: D:test.csv

Comando en powershell SI para que se regitre servidor en Dns

$computers = "ruil","sauce"
invoke-command -computername $computers {ipconfig /registerdns}

******************************SCRIPT PARA
REGISTERDNS***************************************************

Enable-PSRemoting -Force

$domainuser = 'arauco\ladmin.caliste'
$domainpassword = 'Andr0m3da.1985' | ConvertTo-SecureString -AsPlainText -Force
$domaincredentials = New-Object System.Management.Automation.PSCredential
($domainuser, $domainpassword)

$RemoteComputers = Get-Content "D:\RemoteComputers.txt"


$ComputerStatus = "D:\Status.txt"

ForEach ($Computer in $RemoteComputers)


{
Try
{
$client = $Computer
$Client += " - OK"

Invoke-Command -ComputerName $Computer -ScriptBlock { cmd /c ipconfig


/registerdns } -credential $domaincredentials -ErrorAction Stop
Add-Content $ComputerStatus -Value $client
}
Catch
{
$client = $Computer
$Client += " - ERROR (Client not online?)"
Add-Content $ComputerStatus -Value $client
}
}

*************************************Agregar usuario a AD via


powershell*******************

New-ADUser -DisplayName "xxxxx" -Name "xxxxxxx" -UserPrincipalName "xxxxxx"


-Enabled:$true -Path "OU=Administracion,OU=Chile,DC=arauco,DC=cl" -AccountPassword
(ConvertTo-SecureString -string "P@ssw0rd2018" -AsPlainText -Force)
-ChangePasswordAtLogon:$True

******************************************* Sconfig.vbs
***********************************************************
Get-Host <- me muestra informaci�n sobre el servidor en donde estoy