update,
This commit is contained in:
127
_resources/it114105/itp4509/Assignment/CheckInf.psm1
Normal file
127
_resources/it114105/itp4509/Assignment/CheckInf.psm1
Normal file
@@ -0,0 +1,127 @@
|
||||
function Check-EmailAddressFormat([String]$email){
|
||||
|
||||
$check = $true
|
||||
Try{
|
||||
New-Object System.Net.Mail.MailAddress($email)
|
||||
}Catch{
|
||||
$check = $false
|
||||
}
|
||||
|
||||
Write-Output $check
|
||||
|
||||
}
|
||||
|
||||
function Check-PasswordLength([String]$pwd){
|
||||
|
||||
$check = $pwd -match ".{8,}"
|
||||
Write-Output $check
|
||||
|
||||
}
|
||||
|
||||
function Check-PasswordContainDigit([String]$pwd){
|
||||
|
||||
$check = $pwd -match "\d"
|
||||
Write-Output $check
|
||||
|
||||
}
|
||||
|
||||
function Check-PasswordContainSymbol([String]$pwd){
|
||||
|
||||
$check = $pwd -match "[~!@#$=%><^?+&,/\[\]*()_}{-]"
|
||||
Write-Output $check
|
||||
|
||||
}
|
||||
|
||||
function Check-PhoneNumberFormat([String]$phone){
|
||||
|
||||
$check = $phone -match "^\d{8}$"
|
||||
Write-Output $check
|
||||
|
||||
}
|
||||
|
||||
function Check-ADOrgranizationlUnit(){
|
||||
$ouWorstation = "OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
$ouTrainees = "OU=Trainees, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
$ouTrainers = "OU=Trainers, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
if(Get-ADOrganizationalUnit -Filter "distinguishedName -eq '$ouWorstation'"){
|
||||
Write-Host "$ouWorstation already exists."
|
||||
}else{
|
||||
New-ADOrganizationalUnit -Name "Workstation" -Path 'DC=OnlineB10, DC=hk'
|
||||
}
|
||||
|
||||
if(Get-ADOrganizationalUnit -Filter "distinguishedName -eq '$ouTrainees'"){
|
||||
Write-Host "$ouTrainees already exists."
|
||||
}else{
|
||||
New-ADOrganizationalUnit -Name 'Trainees' -Path 'OU=Workstation, DC=OnlineB10, DC=hk'
|
||||
}
|
||||
|
||||
if(Get-ADOrganizationalUnit -Filter "distinguishedName -eq '$ouTrainers'"){
|
||||
Write-Host "$ouTrainers already exists."
|
||||
}else{
|
||||
New-ADOrganizationalUnit -Name 'Trainers' -Path 'OU=Workstation, DC=OnlineB10, DC=hk'
|
||||
}
|
||||
}
|
||||
|
||||
function Check-ADGroup(){
|
||||
|
||||
try{
|
||||
$adGroupOnlineTrainer = Get-ADGroup -Identity 'OnlineTrainer'
|
||||
Write-Host $adGroupOnlineTrainer + 'is already exists'
|
||||
}catch{
|
||||
New-ADGroup -Name "OnlineTrainer" -SamAccountName "OnlineTrainer" -GroupCategory Security -GroupScope Global -DisplayName "OnlineTrainer" -Path "CN=Users,DC=OnlineB10,DC=hk" -Description "OnlineTrainer"
|
||||
}
|
||||
try{
|
||||
$adGroupTrainees = Get-ADGroup -Identity 'Trainees'
|
||||
Write-Host $adGroupTrainees + 'is already exists'
|
||||
}catch{
|
||||
New-ADGroup -Name "Trainees" -SamAccountName "Trainees" -GroupCategory Security -GroupScope Global -DisplayName "Trainees" -Path "CN=Users,DC=OnlineB10,DC=hk" -Description "Trainees"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function Check-TraineeInformation([Object]$trainee){
|
||||
|
||||
$valid = 1
|
||||
|
||||
if(!(Check-PhoneNumberFormat $trainee.Telephone)){
|
||||
"Trainee " + $trainee.FullName + " (" + $trainee.LoginId + ") inputted error phone number(" + $trainee.Telephone + ")" >> .\InvalidPhone.txt
|
||||
$valid = 0
|
||||
}
|
||||
|
||||
if(!(Check-EmailAddressFormat $trainee.Email)){
|
||||
"Trainee " + $trainee.FullName + " (" + $trainee.LoginId + ") inputted error email address(" + $trainee.Email + ")" >> .\InvalidEmail.txt
|
||||
$valid = 0
|
||||
}
|
||||
|
||||
if(!(Check-PasswordLength $trainee.Password)){
|
||||
"Trainee " + $trainee.FullName + " (" + $trainee.LoginId + ") inputted password is not meet the password length requirement" >> .\InvalidPassword.txt
|
||||
$valid = 0
|
||||
|
||||
}
|
||||
if(!(Check-PasswordContainDigit $trainee.Password)){
|
||||
"Trainee " + $trainee.FullName + " (" + $trainee.LoginId + ") inputted password is not contains a digit" >> .\InvalidPassword.txt
|
||||
$valid = 0
|
||||
}
|
||||
|
||||
if(!(Check-PasswordContainSymbol $trainee.Password)){
|
||||
"Trainee " + $trainee.FullName + " (" + $trainee.LoginId + ") inputted password is not contains a special symbol" >> .\InvalidPassword.txt
|
||||
$valid = 0
|
||||
|
||||
}
|
||||
|
||||
Write-Output $valid
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Export-ModuleMember -Function Check-EmailAddressFormat
|
||||
Export-ModuleMember -Function Check-PasswordLength
|
||||
Export-ModuleMember -Function Check-PasswordContainDigit
|
||||
Export-ModuleMember -Function Check-PasswordContainSymbol
|
||||
Export-ModuleMember -Function Check-PhoneNumberFormat
|
||||
Export-ModuleMember -Function Check-TraineeInformation
|
||||
Export-ModuleMember -Function Check-ADOrgranizationlUnit
|
||||
Export-ModuleMember -Function Check-ADGroup
|
23
_resources/it114105/itp4509/Assignment/Computer.psm1
Normal file
23
_resources/it114105/itp4509/Assignment/Computer.psm1
Normal file
@@ -0,0 +1,23 @@
|
||||
Import-Module '.\CheckInf.psm1'
|
||||
|
||||
function New-TraineesComputer($lab, $computer) {
|
||||
Check-ADOrgranizationlUnit
|
||||
Check-ADGroup
|
||||
for($i = 1; $i -le $computer; $i++){
|
||||
$name = "Lab" + $lab + "-S"+ $i.ToString("00")
|
||||
New-ADComputer -Name $name -SAMAccountName $name -PATH "OU=Trainees, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function New-TrainersComputer($lab, $computer){
|
||||
Check-ADOrgranizationlUnit
|
||||
Check-ADGroup
|
||||
for($i = 1; $i -le $computer; $i++){
|
||||
$name = "Lab" + $lab + "-T"+ $i.ToString("00")
|
||||
New-ADComputer -Name $name -SAMAccountName $name -PATH "OU=Trainers, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
|
||||
}
|
||||
|
||||
}
|
31
_resources/it114105/itp4509/Assignment/Intake20.csv
Normal file
31
_resources/it114105/itp4509/Assignment/Intake20.csv
Normal file
@@ -0,0 +1,31 @@
|
||||
LoginID,FullName,LastName,FirstName,Password,Email,Telephone
|
||||
T20200001,Pan Wong,Wong,Pan,dHt5U?VG,panwong@gmail.com,26090005
|
||||
T20200002,Henry Poon,Poon,Henry,-6QrV}NF,henry.poon123@haley.org,27662071
|
||||
T20200003,Kimmy Chin,Chin,Kimmy,%CKE98dT,kimmy2352@muller.com,25222980
|
||||
T20200004,Connie Lau,Lau,Connie,8!NsW7j$,lau.34351@ortiz.com,26379139
|
||||
T20200005,Peter Chou,Chou,Peter,hJ4nK_Hk,peterylchou@hotmail.com,28381205
|
||||
T20200006,Sunny Tseng,Tseng,Sunny,-zujNp2!,sunny70@ratke.com,26996000
|
||||
T20200007,Donald Lam,Lam,Donald,3^{M-Ht,donald.lam@@koss.com,24089533
|
||||
T20200008,Charles Lam,Lam,Charles,%6gW^K&9,clam234y@swift.com,24098988
|
||||
T20200009,Sam Lam,Lam,Sam,RfxYry=4,samsam34@aufderhar.info,(852)30775513
|
||||
T20200010,Tiffany Wong,Wong,Tiffany,qMpA>w5/,t2wong@yahoo.com,27248602
|
||||
T20200011,Bony Lam,Lam,Bony,%js[?3Yb$,bony4lam@feil.com,652319701
|
||||
T20200012,Larry Wan,Wan,Larry,g[Gj>W5D,larry324w@boyer.com.net,23040150
|
||||
T20200013,Crystal Lam,Lam,Crystal,UV48qRw$,crystal34@hotmail.com,85227124888
|
||||
T20200014,Honey Chiu,Chiu,Honey,-*N[4c>U,honey343c@gerhold.com,23400676
|
||||
T20200015,Nancy Hui,Hui,Nancy,J26mZ5a4,nancyhui234@cruickshank.com,28800722
|
||||
T20200016,Aron Lam,Lam,Aron,XRb)(K8>,aron4lam@gmail.com,+(852)61311840
|
||||
T20200017,Mary Yeung,Yeung,Mary,td_e4ELG,mary22@lowe.com,29541117
|
||||
T20200018,Peter Tseng,Tseng,Peter,>3V*&ydg,peter_tseng@kiehn.info,23078360
|
||||
T20200019,Danny Wong,Wong,Danny,VY7Z]ysq,danny.towne@hotmail.com,31523762
|
||||
T20200020,Eddie Lam,Lam,Eddie,BRsc-E!64,eddiea@yahoo.com,27404797
|
||||
T20200021,Freddy Chan,Chan,Freddy,%S5Hg_8E,freddy.breanna@monahan.com,27713667
|
||||
T20200022,Grace Lam,Lam,Grace,(sF5/rT>,grace82@beatty.org,85224991923
|
||||
T20200023,Gary Cheung,Cheung,Gary,=V{ZjU^3,gary.eliane@hoppe.com,23925071
|
||||
T20200024,Hilton Lam,Lam,Hilton,!e=A2cY,gerhilton34@shields.com,23699770
|
||||
T20200025,Iris Lam,Lam,Iris,Z*8+XmdD,yost@iris@yahoo.com,6810099
|
||||
T20200026,Joanne Yeung,Yeung,Joanne,P^hZJHqC7,joannemurray@hotmail.com,23684687
|
||||
T20200027,Robert Lau,Lau,Robert,Ceadv2(L,robert_lau_234@rau.com,+8593669988
|
||||
T20200028,Parker Chui,Chui,Parker,hZW?92Fz,parker72@yahoo.com,23181349
|
||||
T20200029,Tracy Chan,Chan,Tracy,2V[tB+b^,tracy.kirlin@gmail.com,24602234
|
||||
T20200030,ChiuChiu Tai,Tai,ChiuChiu,U9Ev5+2[,chiuchiu234@gmail.com,22363222
|
|
22
_resources/it114105/itp4509/Assignment/README.md.original
Normal file
22
_resources/it114105/itp4509/Assignment/README.md.original
Normal file
@@ -0,0 +1,22 @@
|
||||
# ITP4509-Assignemnt
|
||||
Operating Systems Programming & Administration
|
||||
|
||||
- [x] setup a Domain Controlled computer system,
|
||||
- [x] managing AD Users and Group permission
|
||||
- [x] Domain Policy configuration,
|
||||
- [x] registry configuration,
|
||||
- [x] regular expressions,
|
||||
- [x] automate the administrative tasks using PowerShell scripts.
|
||||
|
||||
| | Domain controller WinServer 2012R2| Trainee Computers | Trainer Computers |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| *Domain* | Onlineαββ.hk*| Onlineαββ.hk* | Onlineαββ.hk* |
|
||||
| *Computer Name* | OnlineDC | Lab1-s01...Lab1-s15 and Lab2-s01...Lab2-s15 | Lab1-t01 and Lab2-t02 |
|
||||
| *IP Address* | 192.168.20.1 | 192.168.20.11 to 192.168.20.40 | 192.168.20.6 and 192.168.20.7 |
|
||||
| *Subnet Mask* | 255.255.255.0 | 255.255.255.0 | 255.255.255.0|
|
||||
| *Default Gateway* | 192.168.20.254 | 192.168.20.254 | 192.168.20.254|
|
||||
| *Preferred DNS* | 192.168.20.1 | 192.168.20.1 | 192.168.20.1 |
|
||||
|
||||
*In the domain name “Onlineαββ.hk”, αββ represents your group and
|
||||
sequence inside the group. E.g. If you are the fourth student in group Z,
|
||||
you should set the domain name to “OnlineZ04.hk”.
|
@@ -0,0 +1,6 @@
|
||||
Import-Module '.\Computer.psm1'
|
||||
|
||||
New-TraineesComputer 1 15
|
||||
New-TraineesComputer 2 15
|
||||
New-TrainersComputer 1 1
|
||||
New-TrainersComputer 2 1
|
@@ -0,0 +1,19 @@
|
||||
$folderPath = "C:\Profiles"
|
||||
New-Item $folderPath -ItemType Directory
|
||||
|
||||
$acl = Get-Acl $folderPath
|
||||
$acl.SetAccessRuleProtection($True, $False)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.SetAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER", "FullControl","ContainerInherit,ObjectInherit","InheritOnly", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Trainees", "ReadAndExecute", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("OnlineTrainer", "ReadAndExecute", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
|
||||
Set-Acl $folderPath -AclObject $acl
|
||||
|
||||
New-SmbShare -Name "Profiles$" -Path $folderPath -FullAccess "Everyone"
|
@@ -0,0 +1,4 @@
|
||||
Import-Module '.\User.psm1'
|
||||
|
||||
$trainees = Get-TraineeList '.\Intake20.csv'
|
||||
New-Trainees $trainees
|
@@ -0,0 +1,4 @@
|
||||
Import-Module '.\User.psm1'
|
||||
|
||||
$trainers = Get-TrainerList '.\Trainers.txt'
|
||||
New-Trainers $trainers
|
@@ -0,0 +1,11 @@
|
||||
Import-Module '.\User.psm1'
|
||||
|
||||
$trainees = Get-TraineeList '.\Intake20.csv'
|
||||
foreach($trainee in $trainees){
|
||||
Set-UserHomeFolder $trainee.LoginID
|
||||
}
|
||||
|
||||
$trainers = Get-TrainerList '.\Trainers.txt'
|
||||
foreach($trainer in $trainers){
|
||||
Set-UserHomeFolder $trainer.LoginID
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
#Create Home Folder Directory
|
||||
$folderPath = "C:\personal"
|
||||
New-Item $folderPath -ItemType Directory
|
||||
|
||||
$acl = Get-Acl $folderPath
|
||||
$acl.SetAccessRuleProtection($True, $False)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.SetAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators", "FullControl", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Trainees", "ReadData", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("OnlineTrainer", "ReadData", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
|
||||
Set-Acl $folderPath -AclObject $acl
|
||||
|
||||
New-SmbShare -Name "Personal" -Path $folderPath -FullAccess "Authenticated Users"
|
||||
|
||||
#Create New Quota Template
|
||||
|
||||
$action = New-FsrmAction Event -EventType Information -Body "The user [File Owner] is about to reach the end of his available storage."
|
||||
$Threshold = New-FsrmQuotaThreshold -Percentage 75 -Action $action
|
||||
New-FsrmQuotaTemplate -Name "HomeFolder_Quota" -Size 8GB -Threshold $Threshold
|
@@ -0,0 +1,19 @@
|
||||
$folderPath = "C:\DropAndPick"
|
||||
New-Item $folderPath -ItemType Directory
|
||||
|
||||
$acl = Get-Acl $folderPath
|
||||
$acl.SetAccessRuleProtection($True, $False)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.SetAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators", "FullControl", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER", "FullControl","ContainerInherit,ObjectInherit","InheritOnly", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Trainees", "ReadData", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("OnlineTrainer", "ReadData", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
|
||||
Set-Acl $folderPath -AclObject $acl
|
||||
|
||||
New-SmbShare -Name "DropAndPick" -Path $folderPath -FullAccess "Authenticated Users"
|
@@ -0,0 +1,6 @@
|
||||
Import-Module '.\User.psm1'
|
||||
|
||||
$trainers = Get-TrainerList '.\Trainers.txt'
|
||||
foreach($trainer in $trainers){
|
||||
Set-TrainerAdditionalFolder $trainer.LoginID
|
||||
}
|
9
_resources/it114105/itp4509/Assignment/Trainers.txt
Normal file
9
_resources/it114105/itp4509/Assignment/Trainers.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
Trainer information:
|
||||
*** Confidential ***
|
||||
|
||||
Login ID,First Name,Last Name,HKID,Telephone
|
||||
slyeung,Sing Lam,Yeung,K914545(3),23842118
|
||||
scchan,Siu Chuen,Chan,C342343(7),26903153
|
||||
hycheung10,Hok Yau,Cheung,B323416(4),24246484
|
||||
lamtt,Tsz Tseng,Lam,A354574(6),23294512
|
||||
kamdw,Dai Wok,Kam,G355374(4),23852345
|
143
_resources/it114105/itp4509/Assignment/User.psm1
Normal file
143
_resources/it114105/itp4509/Assignment/User.psm1
Normal file
@@ -0,0 +1,143 @@
|
||||
Import-Module '.\CheckInf.psm1'
|
||||
|
||||
function New-Trainees([Object] $trainees){
|
||||
|
||||
"Create New Trainee on " + (Get-Date) > .\InvalidPassword.txt
|
||||
"Create New Trainee on " + (Get-Date) > .\InvalidPhone.txt
|
||||
"Create New Trainee on " + (Get-Date) > .\InvalidEmail.txt
|
||||
Check-ADOrgranizationlUnit
|
||||
Check-ADGroup
|
||||
foreach($trainee in $trainees){
|
||||
|
||||
$enable = Check-TraineeInformation $trainee
|
||||
|
||||
New-ADUser -Name $trainee.LoginID -GivenName $trainee.FirstName -Surname $trainee.LastName -EmailAddress $trainee.Email -OfficePhone $trainee.Telephone -AccountPassword (ConvertTo-SecureString ($trainee.Password) -AsPlainText -Force) -Enabled $enable -Description "Traniee" -ProfilePath "\\OnlineDC\Profiles$\%username%" -Path "OU=Trainees, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
Add-ADGroupMember -Identity "Trainees" -Members $trainee.LoginID
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function New-Trainers([Object] $trainers){
|
||||
|
||||
Check-ADOrgranizationlUnit
|
||||
Check-ADGroup
|
||||
foreach($trainer in $trainers){
|
||||
#Get default Password
|
||||
$defaultPwd = Get-TrainerDefaultPassword $trainer.LastName $trainer.HKID
|
||||
|
||||
#New Trainer User
|
||||
New-ADUser -Name $trainer.LoginID -GivenName $trainer.FirstName -Surname $trainer.LastName -OfficePhone $trainer.Telephone -AccountPassword (ConvertTo-SecureString ($defaultPwd) -AsPlainText -Force) -Enabled $True -Description "Tranier" -ProfilePath "\\OnlineDC\Profiles$\%username%" -Path "OU=Trainers, OU=Workstation, DC=OnlineB10, DC=hk"
|
||||
|
||||
#Add User to Group
|
||||
Add-ADGroupMember -Identity "OnlineTrainer" -Members $trainer.LoginID
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Get-TrainerDefaultPassword([String]$trainerLastName, [String]$trainHKID){
|
||||
|
||||
$pwd = $trainerLastName.ToLower() + "$" + $trainHKID.Substring(0, $trainHKID.Length-3)
|
||||
|
||||
Write-Output $pwd
|
||||
|
||||
}
|
||||
|
||||
function Get-TrainerList([String] $path) {
|
||||
#Get Data via Txt file
|
||||
$data = Get-Content $path
|
||||
$dictory = @()
|
||||
$trainers = @()
|
||||
for($i = 0; $i -lt $data.Length; $i++){
|
||||
$rowData = $data[$i].Split(",")
|
||||
if(!($rowData.Length -eq 1)){
|
||||
# Add the first row to dictory array
|
||||
if($dictory.Length -eq 0){
|
||||
$rowData = $rowData.Replace(' ','')
|
||||
foreach($dict in $rowData){
|
||||
$dictory += $dict
|
||||
}
|
||||
|
||||
}else{
|
||||
# Add data assoicate the dictory
|
||||
if($dictory.Length -eq $rowData.Length){
|
||||
$trainer = $null
|
||||
for($count = 0; $count -lt $dictory.Length; $count++){
|
||||
$trainer += @{$dictory[$count] = $rowData[$count]}
|
||||
}
|
||||
|
||||
$trainers += $trainer
|
||||
|
||||
}else{
|
||||
Write-Host "Data Row " + ($i + 1) + "Error"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Write-Output $trainers
|
||||
|
||||
}
|
||||
|
||||
function Get-TraineeList([String] $path){
|
||||
|
||||
$trainees = Import-Csv -Path $path
|
||||
|
||||
Write-Output $trainees
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Set-UserHomeFolder([String]$username){
|
||||
|
||||
Set-ADUser $username -HomeDirectory "\\OnlineDC\personal\$username" -HomeDrive "F:"
|
||||
|
||||
#Create User Home Folder
|
||||
$folderPath = "C:\personal\$($username)"
|
||||
New-Item $folderPath -ItemType Directory
|
||||
|
||||
#Set Permission
|
||||
$acl = Get-Acl $folderPath
|
||||
$acl.SetAccessRuleProtection($True, $False)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.SetAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators", "FullControl", "ContainerInherit, ObjectInherit","InheritOnly", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule($username, "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
|
||||
Set-Acl $folderPath -AclObject $acl
|
||||
New-FSRMQuota -Path $folderPath -Size 8GB -Template "HomeFolder_Quota"
|
||||
}
|
||||
|
||||
function Set-TrainerAdditionalFolder([String] $username){
|
||||
|
||||
$folderPath = "C:\DropAndPick\$username"
|
||||
New-Item $folderPath -ItemType Directory
|
||||
|
||||
$acl = Get-Acl $folderPath
|
||||
$acl.SetAccessRuleProtection($True, $False)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.SetAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators", "FullControl", "None", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule($username, "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("Trainees", "ListDirectory, CreateDirectories, CreateFiles", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
$ace = New-Object System.Security.AccessControl.FileSystemAccessRule("OnlineTrainer", "ListDirectory, CreateDirectories, CreateFiles", "ContainerInherit, ObjectInherit", "None", "Allow" )
|
||||
$acl.AddAccessRule($ace)
|
||||
|
||||
Set-Acl $folderPath -AclObject $acl
|
||||
|
||||
New-FSRMQuota -Path $folderPath -Size 40GB
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user