title: How to combine first name and last name in powershell?
body: <p>Hello everyone I am currently learning PowerShell, and I have script were I can create a Active Directory User, And I am trying to combine the first name and last name (firstname.lastname) and set it where it says $logonname so the user will not have to input that information. Is there some type of command used to achieve that ?</p>
  <pre><code>    import-module activedirectory
  
  #Define variable
  $OU =&quot;OU=mine,DC=mine,DC=mine&quot;
  
  
  
  $firstname = Read-Host 'Enter New Users First Name'
  
  
  $lastname = Read-Host 'Enter New Users Last Name'
  
  $logonname = Read-Host 'Enter New Users Windows Logon Name'
  
  $EmailAddress = &quot;$logonname@mine.com&quot;
  
  $Description = Read-Host 'Job Title?'
  
  $Landline = Read-Host 'Enter the Users Landline Phone (if applicable)'
  
  $Mobile = Read-Host 'Mobile Phone? (If Applicable)'
  
  $Password = Read-Host 'Please enter a secure password'
  
  
  
  
  
  New-ADUser -Name &quot;$firstname $lastname&quot; -EmailAddress $EmailAddress -DisplayName &quot;$firstname $lastname&quot; -SamAccountName $logonname -Title $Description -UserPrincipalName &quot;$logonname@mine.com&quot; -GivenName $firstname -Surname $lastname -Description $Description -OfficePhone $Landline -MobilePhone $Mobile
  
  
  
  Write-Host 'Setting Account Details...'
  
  
  
  Write-Host 'Setting Password...'
  
  Set-ADAccountPassword -Identity $logonname -NewPassword (ConvertTo-SecureString -AsPlainText &quot;$Password&quot; -Force)
  
  Set-ADUser -Identity $logonname -PasswordNeverExpires $true
  
  
  
  Write-Host 'Setting Home Directory to \\networklocation\Home'
  
  Set-ADUser -Identity $logonname -HomeDirectory \\networklocation\home -HomeDrive H
  
  
  
  Write-Host 'Enabling Account in Active Directory..
  
  **NOTE**
  
  The Account Will Take 30 Seconds To Enable, It Is Safe To Close The Script As Long as you See the &quot;DONE&quot; Prompt.'
  
  Enable-ADAccount -Identity $logonname
  
  
  
  Write-Host 'Done'
  </code></pre>