Aperture Script Memos
From Datateknik
(Difference between revisions)
(Created page with "<h2>Creating users with CSV file on Windows Server 2019 AD</h2> *Create the CSV file with ";" as delimiter *Create an OU container in your Active Directory server and record t...") |
|||
Line 8: | Line 8: | ||
New-ADUser `<br> | New-ADUser `<br> | ||
-Name $($_.FirstName + " " + $_.Lastname) `<br> | -Name $($_.FirstName + " " + $_.Lastname) `<br> | ||
− | -GivenName $_.FirstName<br> | + | -GivenName $_.FirstName `<br> |
− | -SurName $_.LastName<br> | + | -SurName $_.LastName `<br> |
-DisplayName $($_.FirstName + " " + $_.Lastname) `<br> | -DisplayName $($_.FirstName + " " + $_.Lastname) `<br> | ||
− | | + | -SamAccountName $($_.FirstName.Substring(0,3).ToLower() + $_$.LastName.Substring(0,3).ToLower()) `<br> |
+ | -UserPrincipalName $($_.FirstName.ToLower() + "." + $_.LastName.ToLower() + "@example.com") `<br> | ||
+ | -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force)`<br> | ||
+ | -Path "OU=ExampleUsers,DC=example,DC=com" `<br> | ||
+ | -Enabled $True `<br> | ||
+ | } | ||
+ | </code></blockquote> | ||
+ | <h2>Blocking open resolver and enabeling WSUS Service on Windows Server 2019 AD</h2> | ||
+ | *Disable recursive queries | ||
+ | *Use the following script | ||
+ | <blockquote><code>hello. | ||
+ | Hello again. | ||
</code></blockquote> | </code></blockquote> |
Revision as of 14:07, 16 October 2020
Creating users with CSV file on Windows Server 2019 AD
- Create the CSV file with ";" as delimiter
- Create an OU container in your Active Directory server and record the location
- Create a PowerShell script in the same location as the CSV file is located
- Use the following script
# Import Active Directory module and import CSV File to list
Import-Module Active Directory
$import_users = Import-Csv -Path .\Users.csv -Header "FirstName","LastName","Password" -Delimiter ";"
# Start a loop and send each line of the CSV file to create a user
$import_users | ForEach-Object{
New-ADUser `
-Name $($_.FirstName + " " + $_.Lastname) `
-GivenName $_.FirstName `
-SurName $_.LastName `
-DisplayName $($_.FirstName + " " + $_.Lastname) `
-SamAccountName $($_.FirstName.Substring(0,3).ToLower() + $_$.LastName.Substring(0,3).ToLower()) `
-UserPrincipalName $($_.FirstName.ToLower() + "." + $_.LastName.ToLower() + "@example.com") `
-AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force)`
-Path "OU=ExampleUsers,DC=example,DC=com" `
-Enabled $True `
}
Blocking open resolver and enabeling WSUS Service on Windows Server 2019 AD
- Disable recursive queries
- Use the following script
hello.
Hello again.