Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A script to ensure 100% accuracy and speed up the NS process, as well as enabling anyone to carry out the basic setup process
- #----------
- #Import the AD cmdlt
- Import-Module ActiveDirectory
- #----------
- #Define the New user and the permissions similar user as varibles via user imput
- $NewUser = Read-Host -Prompt 'Enter the New users firstname.lastname'
- $OldUser = Read-Host -Prompt 'Enter the permissions similar users firstname.lastname'
- #----------
- #Prompt to set the users password as a secure string (e.g **********)
- $newPassword = (Read-Host -Prompt "Provide New Password" -AsSecureString); Set-ADAccountPassword -Identity $NewUser -NewPassword $newPassword -Reset
- #----------
- #Creates a selection list with 6 options. Selection by typing a number and pressing enter
- [int]$xMenuChoiceA = 0
- while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 6 ){
- Write-host "1. UK"
- Write-host "2. International office"
- Write-host "3. Finance team"
- Write-host "4. Culture team"
- Write-host "5. IT Team"
- Write-host "6. Bored member"
- Write-host "7. Cancel"
- #----------
- #When an option is selected, what happens
- [Int]$xMenuChoiceA = read-host "Please enter an option 1 to 6..." }
- Switch( $xMenuChoiceA ){
- 1{Set-ADUser $NewUser –scriptPath “Windows7_LOGIN_SCRIPT.bat”}
- 2{Set-ADUser $NewUser –scriptPath “Windows7_LOGIN_SCRIPT_INT.bat”}
- 3{Set-ADUser $NewUser –scriptPath “Windows7_FINANCE_LOGIN_SCRIPT.bat”}
- 4{Set-ADUser $NewUser –scriptPath "Windows7_PEOPLE_LOGIN_SCRIPT”}
- 5{Set-ADUser $NewUser –scriptPath "Windows7_ITBC_LOGIN_SCRIPT.bat”}
- 6{Set-ADUser $NewUser –scriptPath "Windows7_Director_LOGIN_SCRIPT.bat”}
- 7{Write-host "No logon script set!"}
- }
- #----------
- #Sets the home drive to "P" and specifies the path. Also enables the account
- Set-ADUser $NewUser -HomeDrive "P:" -HomeDirectory "\\lime\private$\$Newuser" -Enabled $true
- #----------
- #Sets the "memberof" permissions for $NewUser to be the same as $Olduser and shows the output (-passthru)
- Get-ADUser $OldUser -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members $NewUser -PassThru
- #----------
- #Prompts the user to press enter to finish the script run
- Read-Host -Prompt "Press Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement