Jump to content

CrazyMatt

Member
  • Posts

    12
  • Joined

  • Last visited

Reputation Activity

  1. Like
    CrazyMatt got a reaction from paps511 in Simple move and click script   
    If you want to do just a teensy bit of programming, you can use AutoIt.
    #include <AutoItConstants.au3> Local $running = true Do MouseClick($MOUSE_CLICK_LEFT, 25, 25) Sleep(3000) MouseClick($MOUSE_CLICK_LEFT, 50, 50) Sleep(1000) Until $running = false  
  2. Agree
    CrazyMatt got a reaction from NinjaJc01 in What is the Easiest Language   
    I'm gonna say VB.NET. It's all about preference, though.
  3. Like
    CrazyMatt reacted to Kryis in The under 100 line challenge!   
    Hey,
     
    Powershell script i quickly wrote for a client school. Their SMS system does not create students automatically and they use Google directory sync and google password sync to sync users into google apps.
     
    The script can be improved greatly and will be when I can be bothered / have time.
     
    The script will import an CSV with all the student information, First name, last name, email address and password etc, the default user scripts are currently hard coded in the script. script base config can be changed with a config csv that lists the domain name, creation OU and a few other details.
     
    The script does the following
     
     Imports all details required for user creation creates all users from csv into the OU listed in the config csv creates the user a home drive for folder redirection gives the user modify rights on said folder syncs google directory sync(runs as another user due to how we have their site setup), waits for sync to complete resets user password to what it was in the csv to force google password sync to sync script outputs to a log file for basic debugging renames the user import csv to the date and moves it into a old folder  

    # SCHOOL NAME Student Usercreator. # Rhys Jeffery # New Era IT # 24/05/2016 Import-Module ActiveDirectory # Importing Users fro Template CSV in CSV-Import. $ul = import-csv ".\CSV-Import\User Template.csv" $ulp = ".\CSV-Import" # Importing Configuration Data from Configuration. $config = import-csv ".\Configuration\config.csv" # Setting Default Config $path = $config.path $homedir = $config.hd $domain = $config.domain # Add all default groups for all users being created $groups = @(“Students") # Imports each user, and users pulled informaton to create AD objects, assign groups and create home drive. ForEach($User in $ul) {     $s = $user.Username     $f = $user.FirstName     $l = $user.LastName     $fn = $f + " " + $l     $dn = $user.DN     $e = $user.Email     $p = $user.Password     $hd = Join-Path $homedir -childpath $s     $upn = $user.Email     $date = Get-Date     $dt = "User Created @ $date By Usercreator"     $check = Get-ADUser -Filter {sAMAccountName -eq $s}     If ($check -eq $Null) {         write-output $s "AD Account Created @ " $date  | out-file .\log.txt -Append         New-ADUser `         -Name $s `         -GivenName $f `         -Surname $l `         -SamAccountName $s `         -DisplayName $fn `         -EmailAddress $e `         -Path $path `         -Description $dt `         -PasswordNeverExpires $true `         -CannotChangePassword $true `         -ChangePasswordAtLogon $false `         -UserPrincipalName $upn `         -AccountPassword (ConvertTo-SecureString –AsPlaintext $p -Force) `         -Enable $true         ForEach($Group in $Groups){Add-ADGroupMember -Identity $Group -Members $s}         }     Else {}     if(!(Test-Path -Path $hd )){         write-output $s "Home Drive Created @ " $date  | out-file .\log.txt -Append         New-Item -ItemType directory -Path $hd         write-output $s "Home Drive Permissions Set @ "$date  | out-file .\log.txt -Append         $acl = Get-Acl $hd         $permission = "$domain\$s","Modify","ContainerInherit, ObjectInherit", "None","Allow"         $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission         $acl.SetAccessRule($accessRule)         $acl | Set-Acl $hd         }     } write-output $s  "Google Apps Sync Started @ " $date  | out-file .\log.txt -Append $arg = "C:\Program Files\Google Apps Directory Sync\Xml\GADSXML.xml" $params = @("-a -c `"$arg`"") $credential = New-Object System.Management.Automation.PsCredential("Domain\account", (ConvertTo-SecureString "PasswordHere" -AsPlainText -Force)) Start-Process -Credential $credential -Filepath "C:\Program Files\Google Apps Directory Sync\Sync-cmd.exe" -ArgumentList $params -NoNewWindow -Wait Wait-Process Sync-cmd write-output $s "Google Apps Sync Completed @ " $Date  | out-file .\log.txt -Append ForEach($User in $ul){ $s = $user.Username $p = $user.Password $check = Get-ADUser -Filter {sAMAccountName -eq $s}     If ($check -ne $Null) {         Set-ADAccountPassword -identity $s -reset -newPassword (ConvertTo-SecureString –AsPlaintext $p -Force)         write-output $s "Password Reset @ " $Date  | out-file .\log.txt -Append     } } move-item "$ulp\User Template.csv" ("$ulp\old\{0:ddMMyyyy}.log" -f (get-date))
×