Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Forewarned, I use Quest's snappin for this.
- Standard Variables:
- * FirstName
- * LastName
- * SamAccountName
- * Department
- * Title
- * Company
- * Description
- * PhoneNumber
- * ipPhone
- * CopyUser (If you need to copy a user)
- * ParentContainer (General location of where they'll land when created, plus the $Department. You'll see in a minute.)
- * Office
- * LogonScript
- Custom Variables:
- * To = HelpDesk
- * From = HelpDesk
- * SMTP = <Your SMTP server>
- * NewUser="Employee Name"
- * StartDate="The start date is MM/DD/YYYY"
- * SoftwareDeploy1 (You would make this either 0 or 1 and depending on the number, have an IF statement that would do something...or not.)
- * SoftwareDeploy2 (You would make this either 0 or 1 and depending on the number, have an IF statement that would do something...or not.)
- * SoftwareDeploy3 (You would make this either 0 or 1 and depending on the number, have an IF statement that would do something...or not.)
- * HardwareDeploy1 (An example would be $iPhone=1. All of these deploys would generate emails, so this is purely an email that is generated.)
- * HardwareDeploy2 (All of these deploys would generate emails, so this is purely an email that is generated.)
- * HardwareDeploy3 (All of these deploys would generate emails, so this is purely an email that is generated.)
- New-QADUser -FirstName $Firstname -LastName $Lastname -Department $Department -Title $Title -Company $Company -MobilePhone $MobileNumber -Office $Office -PhoneNumber $PhoneNumber -Description $Description -LogonScript $LogonScript -ParentContainer ("$ParentContainer" + "$Department") -Name "$Firstname $Lastname" -SamAccountName $SamAccountName -UserPrincipalName $SamAccountName@DOMAIN -DisplayName "$Firstname $Lastname"
- Set-QADUser $SamAccountName -ObjectAttributes @{ipPhone=$ipPhone}
- $UserLoad = Get-QADUser $SamAccountName
- Set-QADUser "$SamAccountName" -UserPassword "DEFAULTPASSWORD"
- Enable-QADUser "$SamAccountName"
- $Var1 = Get-QADUser $COPYUSER | Select -ExpandProperty MemberOf
- foreach
- ($strVar1 in $Var1)
- {Get-QADUser $SamAccountName | Add-QADGroupMember $strVar1}
- Get-QADUser "$SamAccountName" | Add-QADGroupMember Group1
- Get-QADUser "$SamAccountName" | Add-QADGroupMember Group2
- Get-QADUser "$SamAccountName" | Add-QADGroupMember Group3
- Get-QADUser "$SamAccountName" | Add-QADGroupMember Group4
- # Create the "personal" share
- $Homepath = ("\\DOMAIN\dfs$\Users\" + "$SamAccountName")
- New-Item -ItemType Directory -Path $Homepath
- $UserLoad.Name
- $acl_var = Get-Acl $Homepath
- $acl_var.SetAccessRuleProtection($True, $False)
- $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
- $acl_var.RemoveAccessRuleAll($rule)
- $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($UserLoad,"Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
- $acl_var.AddAccessRule($rule)
- $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("DOMAIN\Domain Admins","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
- $acl_var.AddAccessRule($rule)
- Set-Acl $Homepath $acl_var
- Here is an example of an email that is generated if iPhone=1. You would do this for all other variables, if wanted.:
- #iPhone Information - Start
- if ($iPhone -eq "1")
- {
- $Subject = "New User: $NewUser - iPhone - $StartDate"
- $CC = "Level 2 <[email protected]>"
- Send-MailMessage -to $To -cc $CC -from $From -subject $Subject -body " " -smtpServer $SMTP
- }
- else
- {}
- #iPhone Information - End
Advertisement
Add Comment
Please, Sign In to add comment