Generating new user name

Hey All,
I have created a runbook to create new user, our company uses last name and first initial for user name, how can I get that generated in a runbook, I tried random text generator but it didn't work. any ideas please

Hi, best should be to use PowerShell for that, here is a sample Script.
Depends on how you want to create the Username, but should help
<#
.SYNOPSIS
This is a Powershell script to clean up the Sid-History of Users in a specified Organization Unit.
.DESCRIPTION
Parameters:
-Verbose
> Set Verbose to $true for Testing mode
> Set Verbose to $false for Productive mode
> Default Value: $true
-DistinguishedNameOU
> Set DistinguishedNameOU to define the scope
> Default Value: "DC=voestalpine,DC=root,DC=local"
-RecreateDatabaseEntries
> Set RecreateDatabaseEntries to $true for Database Rebuild (necessary after Domain Migration), Duration: approx. 1 Week
By setting RecreateDatabaseEntries to $true all other Parameters will be ignored.
> Set RecreateDatabaseEntries to $false; using existing DatabaseValues
> Default Value: $false
-UserReportLoggingPath
> Set UserReportLoggingPath to change Logging Path for User-Report
> Default Value: "C:\Temp\"
-FullLoggingPath
> Set FullLoggingPath to change Logging Path for User-Report
> Default Value: "C:\Temp\"
.EXAMPLE
Clean SID-History of Users and Groups in OU "OU=Stahl,DC=voestalpine,DC=root,DC=local"
./AD_SID_CleanUP_SCRIPT_V0.2.ps1 -DistinguishedNameOU "OU=Stahl,DC=voestalpine,DC=root,DC=local" -Verbose:$true
Rebuild Database Entries
./AD_SID_CleanUP_SCRIPT_V0.2.ps1 -RecreateDatabaseEntries:$true
#>
##################Section: Parameters###################
#Parameters for Script-Mode:
param(
#[Parameter(Mandatory=$True)]
[string]$OU,
#[Parameter(Mandatory=$True)]
[string]$GivenName="MiChàel",
#[Parameter(Mandatory=$True)]
[string]$LastName="SeiDl",
#[Parameter(Mandatory=$True)]
[ValidateSet("A", "B")]
[string]$Mode,
#[Parameter(Mandatory=$True)]
[string]$Domain="ad.base-it.at",
#[Parameter(Mandatory=$True)]
[string]$FullLoggingPath = "C:\Users\Michael\SkyDrive\3-Work\3 - TECH\Scripts\PowerShell\ActiveDirectory\GetUsername ",
#[Parameter(Mandatory=$True)]
[ValidateSet("Yes", "No")]
[string]$Cleaning = "Yes"
$FullLoggingFileName = "FullLog"+"_"+$GivenName+"_"+$lastname+".txt"
#Settings Mode A
$A_CharLastName=3
$A_CharGivenName=2
$B_CharLastName=3
$B_CharGivenName=2
##################Section: Functions####################
# Function Get-MyModule:
# Function Get-MyModule imports the given $name Module or PSSnapin.
# Return Values:
# $true => success
# $false => error
Function Get-MyModule ($name)
if(-not(Get-Module -name $name))
if(Get-Module -ListAvailable | Where-Object { $_.name -eq $name })
Import-Module -Name $name
return $true
else {
if(-not(Get-PSSnapin | where { $_.Name -eq $name })){
if(Get-PSSnapin -Registered | Where-Object { $_.name -eq $name })
Add-PSSnapin $name
return $true
else{
return $false
else { return $true }
else { return $true }
# Function Write-LogAppendLine ($Text, $Public):
# Function Write-LogAppendLine adds the formated Text to the Log-File ("<current Date> - $F_Text - $F_Value")
# No return Value
function Write-LogAppendLine ($Text, $Public) {
if (!(Test-Path -Path $FullLoggingPath)) {
New-Item -Path $FullLoggingPath -ItemType Directory
if (!(Test-Path -Path $FullLoggingPath\$FullLoggingFileName)) {
New-Item -Path $FullLoggingPath\$FullLoggingFileName -ItemType File
$Datum=Get-Date -format dd.MM.yyyy-HH:mm:ss
$Log="$Datum - $Text"
add-Content -Path $FullLoggingPath\$FullLoggingFileName -Value $Log
if ($Public -eq "Yes") {
Write-Host $Text
if ($Text -match "Error") {
Write-Host "Script stoped"
#exit
# Function Clean-Akzent ($Name):
# Function Clean-Akzent cleans all Names from Akzent
# No return Value
function Clean-Akzent ($Name) {
Try
$Value=$Name.replace('à','a').replace('á','a').replace('é','e').replace('è','e').replace('ó','o').replace('ò','o').replace('ú','u').replace('ù','u').replace('í','i').replace('ì','i')
Write-LogAppendLine "Info: Name cleaned from Akzent => $Value." "Yes"
return $Value
Catch
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-LogAppendLine "Error: Failed on cleaning Akzent." "Yes"
Write-LogAppendLine "Error: Failed Item => $FailedItem" "No"
Write-LogAppendLine "Error: ErrorMessage => $ErrorMessage" "No"
return $false
# Function Clean-Size ($Name):
# Function Clean-Size uppers the first Character and lowers all others
# No return Value
function Clean-Size ($Name) {
Try
$NameArray=$Name.Split(' ')
$givenName=$null
$CountNameArray=1
foreach ($Entry in $NameArray) {
if ($CountNameArray -gt 1) {
$Value+=" "
$Value+=$Entry.Substring(0,1).ToUpper()+$Entry.Substring(1).ToLower()
$CountNameArray++
Write-LogAppendLine "Info: Name cleaned uppere and lower => $Value." "Yes"
return $Value
Catch
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-LogAppendLine "Error: Failed on cleaning Akzent." "Yes"
Write-LogAppendLine "Error: Failed Item => $FailedItem" "No"
Write-LogAppendLine "Error: ErrorMessage => $ErrorMessage" "No"
return $false
# Function Get-Username_A ($LastName, $GivenName):
# Function Get-Username_A
# No return Value
function Get-Username_A ($LastName, $GivenName) {
Try
If ($LastName.length -gt $A_CharLastName) {
$A_LastName = $LastName.ToLower().Substring(0,$A_CharLastName)
else
$A_LastName = $LastName.ToLower()}
If ($GivenName.length -gt $A_CharFirstName) {
$A_GivenName = $GivenName.ToLower().Substring(0,$A_CharGivenName)
else
$A_GivenName = $GivenName.ToLower()
$UsernameOrig="$A_LastName$A_GivenName"
$Username=$UsernameOrig
$Nummer=1
$UserExist=0
while ($UserExist -lt 1) {
if (!(get-aduser -filter {SamAccountName -eq $Username})) {
$UserExist=1
$Value=$Username
Else
$Username=$UsernameOrig+$Nummer
$Nummer++
Write-LogAppendLine "Info: Got a Username => $Value." "Yes"
return $Value
Catch
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-LogAppendLine "Error: Failed on cleaning Akzent." "Yes"
Write-LogAppendLine "Error: Failed Item => $FailedItem" "No"
Write-LogAppendLine "Error: ErrorMessage => $ErrorMessage" "No"
return $false
# Function Get-Username_B ($LastName, $GivenName):
# Function Get-Username_B
# No return Value
function Get_Username_B ($LastName, $GivenName) {
Try
$GivenNameOrig=$GivenName
If ($LastName.length -gt $B_CharLastName) {
$LastName = $LastName.ToLower().Substring(0,$B_CharLastName)
else
$LasTName = $LastName.ToLower()
If ($GivenName.length -gt $B_CharGivenName) {
$GivenName = $GivenName.ToLower().Substring(0,$B_CharGivenName)
else
$GivenName = $GivenName.ToLower()
$UserName="$LastName$GivenName"
$Nummer=1
$UserExist=0
$Length=$givenNameOrig.Length
$Position = 3
$TwoFirstName=$GivenNameOrig.Substring(0,2)
while ($UserExist -lt 1) {
if (!(get-aduser -filter {SamAccountName -eq $Username})) {
$UserExist=1
Else
$UserExist=0
if ($Position -lt $Length) {
$Buchstabe=$givenNameOrig.Substring($Position,1)
$UserName=$LastName+$TwoFirstName+$Buchstabe
$Position++
elseif ($Position -eq $Length) {
$UserName="$LastName$FirstName"
$UserName=$Username.subString(0,$B_CharLastName+$B_CharGivenName)
$UserName=$username+$Nummer
$Nummer++
return $Username.tolower()
Write-LogAppendLine "Info: Got a Username => $Value." "Yes"
#return $Value
Catch
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-LogAppendLine "Error: Failed on cleaning Akzent." "Yes"
Write-LogAppendLine "Error: Failed Item => $FailedItem" "No"
Write-LogAppendLine "Error: ErrorMessage => $ErrorMessage" "No"
return $false
##################Section: Module-Imports/Add-Snappins###############
$CheckModuleImportAD = get-mymodule -name "ActiveDirectory"
if($CheckModuleImportAD){ Write-LogAppendLine "Info: ActiveDirectory-Modul successfully imported." }else{ Write-LogAppendLine "Error: ActiveDirectory-Modul not avaiable." }
##################Section: Magic##################
#Cleaning
if ($Cleaning -eq "yes") {
$GivenName=Clean-Akzent $GivenName
$GivenName=Clean-Size $GivenName
$LastName=Clean-Akzent $LastName
$LastName=Clean-Size $LastName
#Set DisplayName
$Displayname=$LastName+", "+$GivenName
Write-LogAppendLine "Info: Displayname defined => $Displayname." "Yes"
Get-Username_A $LastName $GivenName
Get_Username_B $LastName $GivenName
Seidl Michael | http://www.techguy.at |
twitter.com/techguyat | facebook.com/techguyat

Similar Messages

  • HT3231 I ended up having to create a new user name because the migration assistant wouldn't let me put the data back onto my original user name.  I now have to log into the new user name to see all my data, apps, photographs etc. What went wrong?

    I have a Mac that was part of the recall involved with the faulty Seagate hard drives.  The folks at the Apple Store near me changed the hard drive early December, 2012. I had my data, etc. all backed up on a portable hard drive.  When the Mac was returned with the new hard drive, I used the Migration Assistant to bring everything back over. Trouble was, it wouldn't let me bring it over to my original user name.  I was forced to create a new user name that became the place where everything was restored.  I can't see any data on my old user name, just the basics.  Everything is on the new user name but I wish I didn't have it (just want everything back the way it was originally).  Any suggestions?

    Probably the cleanest thing to do is to erase and freshly install the operating system on the new drive. Then, on the first boot up, don't create a new user, instead select the option in Setup Assistant to immediately bring things over from your backup, which you must connect via USB or firewire. Setup Assistant will then recretae your old user to look just like it used to.
    Before doing this, make sure you realize you will lose everything on the new drive by erasing it, and make sure your backup is still viable.

  • Hey,i forgot my login password,so i changed the password by using terminal command(reset password).now i have new user name with new password,but i can't find  my data which i have saved on mac.please help me out in this matter.

    hey,i forgot my login password,so i changed the password by using terminal command(reset password).now i have new user name with new password,
    but i can't find  my data which i have saved on mac.the storage is showing data used and free space on the disk
    please help me out in this matter.

    How did you change your user name?
    resetpassword wouldn't have done it. If you managed to create a new user, then your data is still in the old account.

  • TS1702 When I try to update an App I am getting my old email address (which no longer works) and when I put in its password it says password or username is wrong. but it does not give me an option to put in my new user name. How can I correct this.

    When I try to update an App I am getting my old email address (which no longer works) and when I put in its password it says password or username is wrong. but it does not give me an option to put in my new user name. How can I correct this.

    What you are getting is the AppleID (AppleID can be an email adress) used at the time of the purchase of this app.  It is an identifiant allowing Apple to link your purchase to your account.
    If you want to manage associated email, you can go at https://appleid.apple.com but the AppleID could never be modified.  
    I do not know if in your case, it is just that you no longer use your old email address or that you actually a 2 AppleID.  In any case, you will have to remember the password related to the account used for your purchase.  If you don't, just use the link above to try to retreive your password.

  • Documents that are park in FBV0 do not update with the new user name when

    Hi,
         I need to find out why documents that are park in FBV0 do not update with the new user name when any changes are made.  Also when we park using MIR7 and make changes to the documents at a later time the document updates with the new users name.
    Requesting you to please suggest what could be the reason.
    Earliest reply will be highly appreciated,
    With regards,
    Rj

    Hi,
        I have checked this in system. I posted one Parked invoice using T.code FV60 and there i appeared my name because i created. But after some time one of my collegue changed the reference and text field with his login i.d. But still in the invoice it is showing as my name whereas if we go to the environmnet, there in the changes we can see what are the changes done and it is appearing my collegues user i.d. But in the main invoice it is still appearing my name.
    Regards,
    Rj.

  • Apple ID is disabled , I got a new user name  still

    MY Apple ID was disabled
    i got a new user name and password
    still disabled

    Go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'iTunes', then 'iTunes Store'.
    A new page will open.
    Choose 'Purchases, Billing & Redemption', then 'Apple ID account billing'.
    Fill out the 'Please tell us more about the issue' box.
    Click the blue 'Continue' button.
    Choose your country.
    Select the contact option that suits your needs best.

  • A new user name showed up on my computer after a windows 8 update.

    A new user name showed up on my computer after a windows 8 update. A name I do not know or recognize. After the update,  the screen showed 2 users, myself and the name "John". it wasn't there yesterday, & I am the only user. I also bought the laptop new so it can't be a previous user. Can anyone tell me how to remove "John" from my computer. I am going to do a system restore & see if that works. In the meantime, if anyone has ever had this happen, what did you do?
    Spoiler (Highlight to read)
    This question was solved.
    View Solution.

    Hello Patthemech1. To remove this account, I would like you to reference this link on how to remove user accounts on Windows 8. Let me know if this assists you. I'm only here to help!
    http://answers.microsoft.com/en-us/windows/forum/windows_8-security/how-do-i-delete-user-accounts-on...
    Mario
    I worked on behalf of HP.

  • I have an old user name tht is no longer accessible. I access fierfox through a new user name. I have copied the profile from the old user name. Can I have 2 profiles from which to choose when using firefox in the under the new username?

    I have a user name on my computer that was tied in with the domain name of the server at my workplace. I would access Firefox under this user name. I have now changed jobs, and for good and obvious reasons can no longer utilize my previous company associated username.
    I have set up a new username on the same computer. When I access Firefox, all of my old bookmarks are gone, because Firefox does not recognize me under the new username as the same person. In the meantime, I have established new bookmarks under the new username.
    I have copied my profile from Firefox under my old username. Can I have two profiles under my new username and pick which one I want to use at that time when accessing Firefox?
    I am running Windows 7 Professional, with 4 gig ram, Intel i3 CPU, 2.13 GHz, 64 bit operating system, Firefox 7.0.1
    Thank you

    You can not merge accounts.
    Apps are tied to the Apple ID used to download them, you can not transfer them.

  • How to force Skype to fetch new user name after re...

    In Skype, there is an option to change the default user name to something meaningful to you. For example echo123 may be renamed from "Echo / Sound Test Service" to "Microphone check". But what if you want to get the old name back? Or what if the contact renamed his public name? How to fetch the new contact name?
    Solved!
    Go to Solution.

    xeos wrote:
    In Skype, there is an option to change the default user name to something meaningful to you. For example echo123 may be renamed from "Echo / Sound Test Service" to "Microphone check". But what if you want to get the old name back? Or what if the contact renamed his public name? How to fetch the new contact name?
    right click then select rename.  erase the old name then leave it blank.  a new window will appear.  delete the name again and leave it blank.  After you click ok, the display name of that contact should revert to the original one.
    IF YOU FOUND OUR POST USEFUL THEN PLEASE GIVE "KUDOS". IF IT HELPED TO FIX YOUR ISSUE PLEASE MARK IT AS A "SOLUTION" TO HELP OTHERS. THANKS!
    ALTERNATIVE SKYPE DOWNLOAD LINKS | HOW TO RECORD SKYPE VIDEO CALLS | HOW TO HANDLE SUSPICIOS CALLS AND MESSAGES

  • HT1311 New user name

    I have changed my user name to a new, but everytime I go to the store to update any of the apps, itunes will ask for my old user name (that is no longer working) and will not accept my password. Please help!

    Are you adding the same username that is listed? If so try a different name. Before I would do that though I would backup the data that is in Palm Desktop. To back up the data click on contacts or address book if you have that, then go to file and export. Save in a location you would remember, then be sure you pick all in the bottom. Create the file name and click save. Do the same for calendar or datebook. Memos, and To do's

  • New user name palm centro

    I have a new to me used Palm Centro that has the previous owners user name in it.  How do I change it to mine user name so that I can sync it to my desktop?  Thanks!!

    You will have to erase the device via a Hard Reset.
    Power the phone off, and remove the battery.  Now hold the power button pressed and reinstall the battery.
    Keep holding the button until you see the "Palm Powered" screen.  Release the button.
    At the "Erase all data, Y/N?" press the up direction to complete the task.  The phone will reinstall all the stock apps and have no HotSync account.
    Perform a HotSync and choose "Existing account" when asked by Palm Desktop.  Choose your original account name.
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • New user name and password

    I want to get the new skype, but want to change my user name and password. How do I get it and change my info?

    If you mean create a new iTunes account then you can do so directly on the iPad via Settings > Store - if an account is currently logged in then tap on it and log out of it (any apps and/or other content that your mother downloaded from her account will remain tied to her account).
    If you don't want to give credit card details when creating an account then follow the instructions on this page : Create an iTunes Store, App Store, or iBooks Store account without a credit card or other payment method

  • How to erase all from a TX and use a new user name?

    I just got a used TX. It has all of the old info on it and of course the user name. I want to install my medical software etc and get rid of everything on the TX. I changed my user name on the desktop Palm software but it keeps reloading the information that was on the TX back to the TX when I do a hard reset and it keeps using the user name of the person I purchased the TX from. I want to wipe everything and start over. I am even having a hard time getting everything off of my Mac. 
    Any ideas? Thank you. John  
    Post relates to: Palm TX
    This question was solved.
    View Solution.

    Hello and welcome to the Palm forums.
    Here are the instructions you need for performing a hard reset on your palm, which will wipe off all the information.
    A hard reset is performed by holding down the power button while sticking something thin (your stylus, paper clip) into the back reset hole of your device. Keep your hand on the power button while you release the paper clip from the reset hole. The screen will now say "Palm Powered." Take your hand off the power button. You will now see a screen in 5 languages prompting you to erase all data from the palm. The screen will say "erase all data? Yes - up, no - down" and you need to click on the up arrow (silver button on the 5 way navigator on the bottom of the palm). This will erase all the info from your device.
    Post relates to: None

  • Generate new user in Oracle BPEL Worklist

    Hello,
    how can I put on in the Oracle BPEL Worklist a new user? I have already read the tutorials in addition. Or if one can work only with the preset users like jstein and jcooper.
    Thank
    Greeting Cathleen

    add a new user in jazn-data.xml (..\integration\orabpel\system\appserver/j2ee/home/config) in your enviroment (if you use developer install) - or if you use OID there .. add additional properties and relations in user-properties.xml (..\integration\orabpel\system\services\config)
    hth clemens

  • Will Setup Assistant allow me to choose a new user name or must I keep the user name on the source computer?

    The source computer is an early 2008 Macbook Pro running Mavericks. The new computer (it's in transit) is a 15" Macbook Pro w/ Retina Display, also running Mavericks. I want to copy all files, settings, apps etc from the old computer but I do not want the same computer name or the same user account name (short name) on the new computer. Can Setup assistant do this?

Maybe you are looking for

  • G5 with samsung 52" tv  Mode not supported

    Does anyone know how I can make my Powermac G5(single 1.8 ATI Radeon 9800pro) work with my Samsung 52 inch TV at HD resolution I am attempting to convert my old Powermac G5 into a media computer. At some point I may want to add a blu-ray drive. When

  • RichDialog doesn't close with exception handling in DialogListener

    I have a RichPopup with a child that is a RichDialog. The popup is called using a command button with a showPopupBehavior child. I have a DialogListener on the RichDialog that calls a web service method through a proxy. I added a try/catch block arou

  • Problem while creating text search index

    Hi, When I am tring to create a text search index I am getting the following: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine ORA-20000: Oracle Text error: DRG-10700: preference does not exist: GLOBAL_LEXER ORA-06512: at "CTXSYS

  • Airport base station agent is always running

    airport base station agent is always running on my computer and i dont know why. i dont even use a wireless connection. im not in a network. my mac connects to the internet directly through a modem. how can i shut it down.

  • Abap web dynpro proxy error

    hi all... i m getting error while testing my abap application.. can anyone pls suggest me, where should i set the proxy settings for that? error is like this: Proxy Encountered Error Host Address Not Found: The proxy could not find an IP address for