Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #tworzenie grup
- $arr = @('GG - Sales','GG - Finance','GG - Informatics') | ForEach-Object {New-ADGroup -Name $_ -GroupCategory Security -GroupScope Global -Path "OU=Groups,OU=Bydgoszcz,DC=atos,DC=net"}
- #import #pułapka na nieuważnych
- $users = Import-Csv .\userzy.csv –Delimiter “;”
- foreach($user in $users){
- $pass = ConvertTo-SecureString $user.Haslo -AsPlainText -force
- New-ADUser -Name $user.id -SamAccountname $user.ID `
- -Country $user.country `
- -Office $user.office `
- -EmailAddress $user.mail `
- -GivenName $_user.imie `
- -Surname $user.nazwisko `
- -Department $user.department `
- -DisplayName $user.displayname `
- -AccountPassword $pass `
- -Path "OU=Users,OU=Bydgoszcz,DC=atos,DC=net"`
- -Enabled $true
- #przydzielanie do grupy na bazie wartości pola Department
- if(($user.Department -eq 'Informatics') -or ($user.Department -eq 'IT')) {Add-ADGroupMember -Identity 'GG - Informatics' -Members $user.ID} `
- if($user.Department -eq 'Sales') {Add-ADGroupMember -Identity 'GG - Sales' -Members $user.ID} `
- if($user.Department -eq 'Finance') {Add-ADGroupMember -Identity 'GG - Finance' -Members $user.ID}
- Write-Host "Creating user: $($user.id)"
- }
- <#
- 1. Stworz 3 grupy w AD:
- GG - Sales
- GG - Finance
- GG - Informatics
- 2. Uzyj zalaczonego pliku CSV aby stworzyc uzytkowników. W trakcie tworzenia uzytkownika pole "Department" powinno byc sprawdzane i na jego podstawie uzytkownik bedzie dodawany do odpowiedniej grupy stworzonej w poprzednim kroku.
- Uzytkownicy z Sales dodawani do: "GG - Sales"
- Uzytkownicy z Finance dodawani do: "GG - Finance"
- Uzytkownicy z Informatics dodawani do: "GG - Informatics"
- UWAGI: Nie wolno modyfikowac pliku CSV.
- 3. Jak podlinkowac GPO do nowego OU "kopiujac" linki GPO z istniejacego OU.
- https://blogs.msdn.microsoft.com/canberrapfe/2012/11/15/where-are-site-linked-group-policy-objects-stored-and-why-should-you-care/
- #>
- ---------------------------------------------------------------------------
- #Get-ADObject -Identity "OU=OUzGPO,OU=Bydgoszcz,DC=atos,DC=net" -Properties gPlink#
- #zad 3#
- $src ="OU=OUzGPO,OU=Bydgoszcz,DC=atos,DC=net"
- $dest="OU=NoweOU,OU=Bydgoszcz,DC=atos,DC=net"
- $linked = (Get-GPInheritance -Target $src).gpolinks
- foreach ($link in $linked)
- {
- $guid = $link.GPOId
- $order = $link.Order
- $enabled = $link.Enabled
- if ($enabled)
- {
- $enabled = "Yes"
- }
- else
- {
- $enabled = "No"
- }
- New-GPLink -Guid $guid -Target $dest -LinkEnabled $enabled
- Set-GPLink -Guid $guid -Target $dest -Order $order
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement