halbaradkenafin
Members-
Posts
1,219 -
Joined
-
Last visited
Content Type
Forums
News
20th
EduGeek EDIT Conference
Blogs
Everything posted by halbaradkenafin
-
Same, Meteorain on Rufus was as far as I went while on an attempt to hit level 30 before leaving midgar, got to about 24 before I got bored of grinding.
-
It is pretty time consuming to get it done, especially racing against that damn black chocobo rider (Joe?) where the only way to beat him sometimes is to make him push you along and try to stop him slipping by you. The other big grind in the game is Omnislash, which a friend decided to try to get on disc 1 and succeeded in using it against Demon's Gate in the Temple of the Ancients. That was pretty awesome to see that happen.
-
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
It may not be associating the $sAMAccountname with the one that's on the domain. The method I use for these sort of things is to specify which domain to look up the $sAMAccountName by changing the two lines to something like this: $AccessRule = new-object System.Security.AccessControl.FileSystemAccessRule("domain\$sAMAccountName",$Rights,$Inherit,$Propogation,$Access) $Account = new-object system.security.principal.ntaccount("domain\$sAMAccountName") -
Are we moving away from the days where asking if you can bring a drake in comms/fleet chat would get you laughed at then kicked from the fleet?
-
Important Health Announcement for all IT Staff
halbaradkenafin replied to sonofsanta's topic in General Chat
That's what I thought, I know I'd had a special form in the past when I was a student but this is information I just got back from HR: Which is pretty easy to get an optician to sign for as I know some of the staff at the place I'm going to, just seems odd they don't have an actual procedure in place for this as I'd imagine it's something quite a few staff would need to use due to how many people work with computers for 4+ hours a day. -
Important Health Announcement for all IT Staff
halbaradkenafin replied to sonofsanta's topic in General Chat
Going in for a test myself at the weekend, I'd arranged it myself but I'm going to contact HR and see if I can get them to pay for it and glasses (last test was 10 years ago and they said I needed them for computer use then so I doubt it's changed). -
Important Health Announcement for all IT Staff
halbaradkenafin replied to sonofsanta's topic in General Chat
I've had memory problems for years (I think) but don't drink coffee, maybe I should start and see if that helps the memory problems. Then again my gf drinks a few cups a day and still have memory problems so maybe not. -
Good call on that, picked it up last night and started it earlier.
-
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
There are a few ways to handle this, the easiest way would be to have some if/elseif/else statements and create the account name within that. It would result in something like this: if ($forename.length -lt 3 -and $surname.length -lt 4) { $samaccountname = "$Leaving$Forename$Surname" } elseif ($forename.length -lt 3 ) { $samaccountname="$Leaving$Forename$($surname.substring(0,4))" } elseif ($surname.length -lt 4) { $samaccountname="$Leaving$($Forename.substring(0,3))$surname" } else { $samaccountname= "$Leaving$($forename.substring(0,3))$(surname.substring(0,4))" } -
Tempting to get speakers but 80s music doesn't bother me as I was brought up listening to pretty much everything 60s onwards. I'm also reasonably certain I'd win such a war as I know I can mute his PC with Impero and he can't unmute it without going to a different computer.
-
We tried some radio station with no adverts and very few breaks in the music (pretty much just to remind you what the radio station was) but apparently the music was too "weird" for the boss. Personally I was pretty happy with the wide range of music we got from there but he's got the speakers so he gets to choose with me having only a little bit of a say in it. I make up for it by listening to whatever has taken my fancy at the moment on the way home thanks to Google Play. Currently bouncing between Parov Stelar and Bonobo.
-
Our solution is Absolute 80s, it gets a bit repetitive over the course of a few days but there are always a few gems that appear.
-
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
Might be worth trying something a little more complex for the string concatenation: $sAMAccountName = "$Leaving$($Forename.substring(0,3))$($Surname.substring(0,4)" The way it works is that double quotation marks will take the value of a variable and put it in the string (single quotes will print whatever is between them including variable names), but if you have something like "$forename.substring" then it will read that as "PSH.substring". The solution to this is use $() and it will evaluate the code between the brackets first and then convert it to a string before adding it to the main string. That should mean that your $leaving is converted to a string and the other parts are evaluated correctly as well. -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
You'd have to test each forename to ensure it's length is greater than 2 and then do something if it's not. What you do depends on how you want to handle it. if ($Forename.length -lt 3) { #do something here to short forenames } if ($surname.length -lt 4) { #do something here to short surnames } -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
I've bolded the important part here. It basically means you've got a name which is only 1 or 2 characters long by the looks of it. -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
One solution to that is to wrap the $Leaving part of $sAMAccountName in "" and it will parse it as a string with the value of the variable. -
[Powershell] Does anyone have a script which .....
halbaradkenafin replied to halbaradkenafin's topic in Scripts
Here is a script I've recently finished updating to create user accounts, either staff or student with the only difference being the Staff member uses a title and student has intake year. It accepts input through pipeline so you can just import-csv and then pipe it to the script and have it work it's magic on each row in the csv. We use a very basic csv file as most of the values are generated automatically from that data: forename,surname,intakeyear,password,Staffmember,Title john,smith,2014,Password1 Jane,Doe,,Password1,True,Miss <# .Synopsis Script to create single users in AD and assign to correct groups .DESCRIPTION This script will create a single user account in AD, home directory and assign to the groups needed. Input can be specified using the parameters or passed through the Pipeline, such as from Import-Csv. Output will be a pretty printed statement of the new users username when calling the script on it's own or a custom object with the parameters of the newly created account when called as part of a pipeline. The pipeline can then be passed to Export-Csv for easy distribution of account information or to another command. The script will automatically generate a username using the standard format for either staff or students (depending on if -staffmember switch is supplied) and ensure the username is not already in use, if it is then it will increment it until it finds an available username. .EXAMPLE Create-SingleUser.ps1 -Forename John -Surname Smith -IntakeYear 2015 -Password Password1 This will create a new account for the user John Smith, create the home folder and assign them to the AD groups. it will then output the following to the screen: "New User created with Username: J.Smith2 and Pasword specified." .EXAMPLE Create-SingleUser.ps1 -Forename John -Surname Smith -Password Password1 -Title Mr -StaffMember This will create a new account for the staff member John Smith, create the home folder and assign to the ad groups. It will then output the following to the screen: "New User created with Username: Smith.J1 and Pasword specified." .EXAMPLE Import-Csv -Path "C:\User.csv" | Create-SingleUser.ps1 | Export-Csv -Path "C:\NewUsersDetails.csv" This will import a csv of user details and create accounts for each one, then output the new details to the specified csv file. #> [cmdletbinding()] param ( [Parameter(ValueFromPipelineByPropertyName)] [string]$Forename = $(Read-Host "Enter Forename"), [Parameter(ValueFromPipelineByPropertyName)] [string]$Surname = $(Read-Host "Enter Surname"), [Parameter(ValueFromPipelineByPropertyName)] [string]$IntakeYear, [Parameter(ValueFromPipelineByPropertyName)] [string]$Password = $(Read-Host "Enter password for new user"), [parameter(ValueFromPipelineByPropertyname)] [switch]$StaffMember, [parameter(ValueFromPipelineByPropertyName)] [string]$Title ) Process { # This will return if the queried user # does not exist within AD. Function Check-ADUser { [string]$Name = $args[0] $ADUser = Get-ADUser -Filter {SamAccountName -eq $Name} if (!$ADUser) { return 0 } } # Creates the basic details for the user depending # on if they are a member of staff or not. if ($StaffMember) { $ShortName = "$Surname.$($Forename.Substring(0,1))" $IsADUser = Check-ADUser $ShortName $Count = 1 while ($IsADUser -ne 0) { $ShortName = "$Surname.$($Forename.Substring(0,1))$Count" $IsADUser = Check-ADUser $ShortName $Count += 1 } $DisplayName = "$Title $($Forename.Substring(0,1)). $Surname" $Description = "Teacher" $HomeDirectory = "\\Fileserver\Staffwork$\$ShortName" $ProfilePath = "\\fileserver\staffprofiles$\$ShortName" $OU = "OU=Teaching Staff,OU=Users,DC=Domain,DC=local" } else { $ShortName = "$($Forename.Substring(0,1)).$Surname" $IsADUser = Check-ADUser $ShortName $Count = 1 while ($IsADUser -ne 0) { $ShortName = "$($Forename.Substring(0,1)).$Surname$Count" $IsADUser = Check-ADUser $ShortName $Count += 1 } $DisplayName = "$Forename $Surname" $Description = "Student" $HomeDirectory = "\\fileserver\studentwork$\$IntakeYear\$ShortName" $ProfilePath = "\\fileserver\studentprofiles$\$IntakeYear\$ShortName" $OU = "OU=$IntakeYear,OU=Students,OU=Users,DC=domain,DC=local" } $SecureString = ConvertTo-SecureString -String $Password -AsPlainText -Force $UserPrincipalName = "[email protected]" $email = "[email protected]" # Creates the AD Account using the details specified and then pauses to allow replication to the DC New-ADUser -Name $ShortName -Description $Description -DisplayName $DisplayName -GivenName $Forename -HomeDirectory $HomeDirectory -HomeDrive "N:" -ProfilePath $ProfilePath -SamAccountName $ShortName -Surname $Surname -UserPrincipalName $UserPrincipalName -Path $OU -AccountPassword $SecureString -EmailAddress $email -Enabled 1 -ChangePasswordAtLogon 1 Start-Sleep -s 10 # Creates home folders and main group membership if ($Staffmember) { New-Item -Path "\\fileserver\StaffWork$\" -Name $ShortName -ItemType Directory Add-NTFSAccess -Account "domain\$ShortName" -AccessRights FullControl -AccessType Allow -Path $HomeDirectory Add-ADGroupMember -Identity "All Staff" -Members $ShortName } else { New-Item -Path "\\fileserver\StudentWork$\$IntakeYear\" -Name $ShortName -ItemType Directory Add-NTFSAccess -Account "domain\$ShortName" -AccessRights FullControl -AccessType Allow -Path $HomeDirectory Add-ADGroupMember -Identity $IntakeYear -Member $ShortName } Add-ADGroupMember -Identity "Other Users Group" -Member $ShortName # Outputs created account data based on if the script was called on it's own or as part of a pipeline if ($PSCmdlet.MyInvocation.PipelineLength -gt 1) { Write-Output (New-Object -TypeName PSObject -Properties (@{"Forename"=$Forename;"Surname"=$Surname;"Username"=$ShortName;"Password"=$Password})) } else { Write-Output -InputObject "New User created with Username: $ShortName and Pasword specified." } } -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
That's quite an easy one to handle (though it will look a little convoluted at first) and depends on how your csv stores the intake year. Assuming you store it as just the two digit number then you can do this: $LeavingYear = [int]$_.Intake + 5 And then substitute $LeavingYear in your $sAMAccountName where it currently has $_.Intake. If you do 4 digit intake year in the csv then it's just a slight modification to the above code: $LeavingYear = [int]($_.Intake.substring(2)) + 5 -
Changing naming scheme for pupils...
halbaradkenafin replied to rickjames's topic in How do you do....it?
Very quick oneliner that should work (note I haven't tested this across more than one account so I'd strongly suggest leaving the -WhatIf parameter in and only take it out when your happy with that it will actually work): Get-ADUser -Filter * -Searchbase "OU=StudentParentOU,OU=user,DC=Domain,DC=Local" -properties samaccountname | Foreach-object {$YearOfLeaving = [int]($_.SamAccountName.substring($_.SamAccountName.length -2)) + 5; $NewName = ($_.SamAccountName).Substring(0,$_.SamAccountName.length -2) + $YearOfLeaving; Set-ADUser -Identity $_.SamAccountName -SamAccountName $NewName -UserPrincipalName "[email protected]" -whatif} -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
You may need to modify the lines around there that say "$Displayname" to "\$Displayname". I've found that to cause problems in the past when assigning ACEs this way. If it's still occurring then I'd add in Start-Sleep -s 10 after the New-ADUser statement to allow it time to properly update the DCs. -
You can do it through Powershell with the command: Install-WindowsFeature FS-Data-Deduplication It might error out if you don't see it in the Add Role Wizard but it's worth a try. It might also need to be run as administrator.
-
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
Does the csv contain columns called Forename, Surname etc? If it does then I'd next see what data the script is trying to work with, before the $sAMAccountName line add in Write-Host $User.Forename Write-host $User.Surname This should give you an idea of what the field actually contains. If it shows two blank lines before the error message then it means your columns aren't named the same as the script is looking for (it shouldn't be case sensitive). If it shows the correct data from your csv then I'd resorted to messing around in the command line view using various lines one at a time, probably something like: $test = Import-csv -path "D:\PS\New-ADUser.csv" Write-host $Test[0] Write-host ($test[0].forename).Substring(0,$test[0].forename.length+3) If that gives any error messages then I'd expect it to be on the last line. You'll need to add -Name to the New-ADUser command, before the -ErrorAction parameter would be best. -
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
Just replace all instances of $_ with $User (Find/Replace tool will make this easy), it should fix the code and make it more readable. -
The progression for restore materia is: Cure 1 -> Cure 2 -> Regen -> Cure 3
-
[Powershell] Creating Users from CSV - Home folder
halbaradkenafin replied to CHiLL's topic in Scripts
Just noticed the foreach loop is actually using $User instead of $_ for the variable name, that is likely causing a problem. Might also be worth wrapping the $User.Forename and $User.Surname in () brackets before the .substring section to ensure it's evaluating each part individually. You'll also have to specify the -name property for New-ADUser as it's a required parameter. I'm guessing it will be the same value as your sAMAccountname but it depends on what you'd like to use, Get-ADUser -Identity will tell you what format you currently use if you don't know which one to use.
