Buenos días, siguiendo con la serie de post sobre PowerShell y tras ver como inicializar servidores y como conectar a controladores de dominio, vamos a seguir viendo diferentes tareas que podemos hacer una vez conectados a nuestro controlador.
Recordar que en la lista teníamos las siguientes funcionalidades:
- Listado de usuarios.
- Creación de usuarios.
- Creación de usuarios con csv.
- Listado de grupos.
- Creación de grupos.
- Agregar usuarios a grupos.
De las cuales hoy vamos a ver como realizar las dos primeras, así que vamos a ello.
La primera es el listado de usuarios completo del dominio, numerado y por orden alfabético:
#Listado de usuarios
Write-Host ‘ LISTADO DE USUARIOS’ -ForegroundColor «Yellow»
#Metemos todos los usuarios del dominio en $array, pero de todos los campos que contiene el usuario en mi caso solo me interesa el samaccountname, podéis variar el campo que deseáis extraer o simplemente estraer todo y darle el formato que queráis a la salida.
$array=(Get-ADUser -filter *).samaccountname
#Creo la variable $i que sera la encargada de ir numerando los usuarios.
$i=0
#Ordenamos los usuarios alfabéticamente.
$array= $array | sort
#Generamos una lista extrayendo los usuarios, numerándolos mediante la variable $i e incrementando esta en +1 tras la extracción de cada usuario.
foreach ($elemento in $array){
echo $i’-‘$elemento
$i++
}
Ahora mismo a lo mejor no tiene mucho sentido listar todos los usuarios de un dominio pero veremos mas adelante como usaremos dicha lista cuando tengamos que asignar usuarios a grupos.
El siguiente paso es como crear usuarios, para ello:
#Creacion de usuarios
Write-Host ‘ CREACION DE USUARIO’ -ForegroundColor «Yellow»
#Definimos una serie de variables con los campos que vamos a rellenar del usuario, algunos como el nombre y apellidos los introduciremos, mientas otros los generaremos con los campos ya introducidos. Ciertas variables como $domain no están siendo definidas, ya que las definimos cuando hicimos la conexión al controlador de dominio que vimos en el post anterior. No obstante si solo deseáis usar esta parte del script, solo tenéis que añadir dicha variable o cambiar el valor por vuestro dominio y dejarlo fijo.
$GivenName=Read-Host ‘Introduzca el Nombre propio del usuario’
$SurName=Read-Host ‘Introduzca el Apellidos del usuario’
$Name=$GivenName+’ ‘+$SurName
$User=Read-Host ‘Introduzca el nombre de Usuario para el dominio’
$Upn=$User+’@’+$domain
$Department=Read-Host ‘Introduzca el departamento’
$Email=$User+’@’+$domain
$Pass=Read-Host ‘Introduzca la contraseña temporal para la cuenta’
$enc_password = (ConvertTo-SecureString $Pass -AsPlainText -Force)
#Creamos el usuario haciendo uso de las variables definidas. El campo -path deberéis rellenarlo según la ubicación de vuestro Active Directory en la que queréis que se creen los usuarios.
New-ADUser -Name $Name -GivenName $GivenName -Surname $SurName -SamAccountName $User -UserPrincipalName $Upn -Enable $true -Description $Department -EmailAddress $Email -AccountPassword $enc_password -path «OU=ScriptUsers,DC=sergio,DC=cloud»
Con este tenemos ya un poquito mas del script completo a la vista, cuando tengamos todas las funcionalidades veremos como integrarlas en un solo script.
Espero os sea de ayuda la información como siempre y no olvidéis comentar, dar el pertinente me gusta y enlazar el post en vuestras redes sociales, podéis hacerlo un poquito mas abajo ;).
Nos vemos pronto.
[…] que tenemos en nuestro Active Directory, el script es básicamente el mismo que vimos para el listado de usuarios, únicamente modificamos el objeto que deseamos extraer de un usuario a un […]
free local dates
free dating
tinder app , what is tinder
tinder login
viagra au canada tesco online viagra – pay for shipping only free viagra
ed clinic
generic cialis 20 mg online purchasing cialis in the usa how to get cialis prescription
prednisone 10mg for sale cheap prednisone prednisone 10 mg online
best drugs for ed pet antibiotics without vet prescription muse ed drug
50 mg prednisone tablet generic prednisone online order prednisone 10mg
cialis australia online stores cialis usa generic cialis fast delivery
prednisone 5mg daily buy prednisone prednisone 5 mg tablet without a prescription
cialis superactive cialis usa online cialis low price
buy propecia cheap propecia prescription online cheap propecia
anti fungal pills without prescription ed meds online without prescription or membership prescription meds without the prescriptions
the canadian drugstore canadian medications best online canadian pharmacy
mens erection pills new treatments for ed mens ed pills
buy prescription drugs online legally meds online without doctor prescription the canadian drugstore
buy propecia no prescription propecia generic finasteride propecia no prescription
finasteride without prescription propecia for sale how do i get propecia
reputable online pharmacies in india india pharmacies online india pharmacies shipping to usa
stromectol for sale stromectol for sale stromectol pills for humans
india pharmacy mail order india pharmacies online india pharmacies shipping to usa
cialis pharmacy where to buy liquid cialis lowest price tadalafil
clomid tablets for sale clomid for sale canada clomid tablets
buy tadalafil online tadalafil without a doctor’s prescription generic tadalafil 20mg india
tadalafil best price 20 mg cialis pharmacy cialis pills
stromectol for humans for sale stromectol tablets for humans stromectol tablets for humans
stromectol 12 mg tablets stromectol for sale stromectol for sale
stromectol tablets for humans stromectol tablets for humans stromectol tablets for humans
buy viagra online canada viagra cost of viagra
viagra amazon viagra coupon over the counter viagra
cialis buy on line generic version of cialis why buy cialis. com
cialis generic timeline generic tadalafil 20mg india buy cialis without
cialis viagra cocktail tadalafil 20mg best price cialis sample pack
viagra cialis trail pack buy cialis in cro cialis delivery held at customs
gnereic cialis generic version of cialis cheap cialis super active
cialis 5mg no prescription generic tadalafil 20mg india cialis overnight deleivery
super cialis professional best price for daily cialis
ivermectin 6 mg tablets stromectol cvs
https://stromectolgf.com/# how much does ivermectin cost
ivermectin human stromectol 3mg cost
pet meds without vet prescription best canadian online pharmacy
ed meds online without prescription or membership buy prescription drugs without doctor
https://drwithoutdoctorprescription.com/# prescription drugs online without doctor
non prescription ed pills sildenafil without a doctor’s prescription
how to get prescription drugs without doctor canadian drugs online
https://drwithoutdoctorprescription.site/ best non prescription ed pills
viagra without a doctor prescription 100mg viagra
cost of viagra viagra pills
viagra shop over the counter viagra
viagra without a doctor prescription usa price of viagra
over the counter viagra viagra shop
100mg viagra buy viagra online canada
п»їviagra pills sildenafil 20 mg
can you buy clomid over the counter us clomid over the counter australia
https://prednisoneforsale.store/# prednisone otc uk
clomid 100mg for sale clomid 50 mg buy uk
prednisone 3 tablets daily prednisone 5084
buy lasix online furosemide 40 mg
https://buynolvadex.store/# nolvadex gynecomastia
https://buylasix.icu/# furosemide 100mg
generic lipitor online lipitor 80 mg daily
https://buylasix.icu/# lasix 100mg
where can i get metformin without prescription online no prescription metformin
https://buytadalafil.men/# canadian pharmacy generic tadalafil
lasix tablet lasix tablet
nolvadex for pct does tamoxifen cause menopause
canadian medications canadian drug
https://erectionpills.best/# best ed pills at gnc
https://erectionpills.best/# new treatments for ed
https://cipro.best/# cipro ciprofloxacin
ciprofloxacin 500 mg tablet price ciprofloxacin generic
neurontin price neurontin 600mg
neurontin gel neurontin 600
https://erectionpills.best/# cheap erectile dysfunction pills online
https://erectionpills.best/# top ed pills
buy prescription drugs without doctor canadian pharmacy online
https://erectionpills.best/# ed medications list
best ed pill non prescription erection pills
generic gabapentin neurontin medicine
https://cipro.best/# buy generic ciprofloxacin
https://cipro.best/# cipro
gnc ed pills medication for ed dysfunction
clomid 200 mg daily clomid for sale
erection pills best male enhancement pills
https://stromectol.life/# ivermectin cream cost
https://drugsonline.store/# prescription drugs online without doctor
buy clomid cheap clomid
https://clomidonline.icu/# clomid
https://doxycyclineonline.store/# doxycycline without prescription
gnc ed pills drugs for ed
ivermectin 5 buy stromectol uk
ed clinic impotence pills
https://clomidonline.icu/# clomid
best ed pills mens ed pills
https://stromectol.life/# stromectol where to buy
https://doxycyclineonline.store/# doxycycline for sale
who makes ivermectin stromectol 12 mg tablets
https://stromectoltrust.com/# order stromectol over the counter
https://stromectoltrust.com/# stromectol 12 mg tablets
stromectol order stromectol over the counter
https://stromectoltrust.com/# stromectol for humans for sale
stromectol 12 mg tablets stromectol for humans for sale
drug prices cheap erectile dysfunction pill
https://pharmacyizi.com/# best ed treatment pills
https://pharmacyizi.com/# ed medications
buy prescription drugs best medicine for ed
https://pharmacyizi.com/# medicine for erectile
https://pharmacyizi.com/# online drug store
online medications ed online pharmacy
best medicine for ed real cialis without a doctor’s prescription
https://pharmacyizi.com/# ed trial pack
https://pharmacyizi.com/# mens ed
medications online best erection pills
best treatment for ed dysfunction erectile
https://pharmacyizi.com/# ed medications online
https://pharmacyizi.com/# medicine for erectile
https://pharmacyizi.com/# drugs prices
male ed pills causes of ed
https://erectionpills.shop/# ed treatment pills
Provera Lopressor
https://canadiandrugs.best/# best non prescription ed pills
https://erectionpills.shop/# ed pills that work
online pharmacy delivery usa pharmacy online uae
https://onlinepharmacy.men/# pharmacy coupons
https://allpharm.store/# viagra from canada
Biaxin drugs for sale
cat antibiotics without pet prescription ed meds online without doctor prescription
https://canadiandrugs.best/# buy prescription drugs from canada cheap
https://allpharm.store/# Effexor
medication for ed dysfunction cheap erectile dysfunction pill
ed drugs best ed pills online
https://erectionpills.shop/# ed medications online
https://erectionpills.shop/# non prescription erection pills
best ed drugs ed pills otc
canadian online drugs prescription drugs online without
https://onlinepharmacy.men/# indian trail pharmacy
buy cheap prescription drugs online buy prescription drugs from canada cheap
http://stromectolbestprice.com/# worming rabbits with ivermectin
ivermectin for canaries how long does it take ivermectin to kill scabies
http://stromectolbestprice.com/# ivermectin 4
ivermectin for coronavirus is noromectin the same as ivermectin
how long does it take ivermectin to kill scabies ivermectin 1
http://stromectolbestprice.com/# ivermectin tractor supply
https://drugsbestprice.com/# drugs and medications
erectile dysfunction treatment ed pills otc
https://drugsbestprice.com/# ed cures
https://drugsbestprice.com/# new treatments for ed
canadian pharmacy ed prescription drugs
https://medrxfast.com/# how to get prescription drugs without doctor
discount prescription drugs ed meds online without doctor prescription
buy prescription drugs from india canadian pharmacy
https://medrxfast.com/# buy prescription drugs from canada cheap
https://medrxfast.com/# buy prescription drugs
pain medications without a prescription canadian pharmacy online
https://medrxfast.com/# non prescription erection pills
https://medrxfast.com/# ed meds online without doctor prescription
ed meds online canada pain meds online without doctor prescription
https://medrxfast.com/# prescription drugs online without doctor
https://medrxfast.com/# online canadian drugstore
anti fungal pills without prescription how to get prescription drugs without doctor
https://medrxfast.com/# canadian drugstore online
https://medrxfast.com/# mexican pharmacy without prescription
canadian online pharmacy prescription drugs canada buy online
https://medrxfast.com/# п»їed drugs online from canada
https://medrxfast.com/# best ed pills non prescription
canadian online pharmacy dog antibiotics without vet prescription
https://medrxfast.com/# buy cheap prescription drugs online
buy prescription drugs from canada pain meds without written prescription
https://medrxfast.com/# buy prescription drugs online
https://medrxfast.com/# meds online without doctor prescription
https://wellbutrin.best/# wellbutrin 30 mg
valtrex uk over the counter how much is valtrex
https://diflucan.life/# diflucan 150 mg caps
https://valtrex.icu/# cheap generic valtrex without prescription
diflucan buy nz diflucan 150 mg