-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-groups_v1.0.0_.py
More file actions
62 lines (50 loc) · 2.36 KB
/
create-groups_v1.0.0_.py
File metadata and controls
62 lines (50 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
########################################################################
# #
# WhiteAngel #
# #
# #
# Creado por Angel Mendez #
# 20/Junio/2019 #
# #
# Con el proposito de ahorrarme muchos clics!!! #
# All rights reserved #
# Don't copy or share this script without asking for permision #
# #
########################################################################
#Programa que crea grupos de AD
import os, subprocess, sys;
#Para limpiar la consola
def clear():
os.system("cls");
#En caso de que desee crear mas de un grupo
def repetir():
clear()
repetir = input("Desea crear otro grupo [S:n]: ")
repetir = repetir.upper()
if repetir == "S":
main()
elif repetir == "N":
sys.exit()
elif repetir == "":
main()
else:
input("Opcion invalida!!")
repetir()
def main():
clear()
print("Vamos a crear un grupo!!")
nombre = input("Ingrese el nombre del grupo: ")
scope = input("Seleccione el tipo de SCOPE [DomainLocal | *Global* | Universal]: ")
category = input("Seleccione la cetegoria del grupo[Distribution | *Security*]: ")
path = input("Ingrese la ubicacion del grupo: ")
#Crear script de PowerShell
psf = open("./crear.ps1", "w+")
psf.write("Import-Module ActiveDirectory; New-ADGroup -name %s -GroupScope %s -DisplayName %s -GroupCategory %s -path \"%s\"; Pause;"
%(nombre, scope or "Global", nombre, category or "Security", path + ",dc=itla,dc=local" )) #Puedes cambiar ",dc=itla,dc=local" por ",dc={NombreDelDominio}, dc={TopLevelDomainDelDominio}"
psf.close()
#Ejecutar Script de PowerShell
ejecutar = subprocess.Popen(["powershell.exe", "./crear.ps1"])
ejecutar.communicate()
repetir()
#Inicio del programa
main()