Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9063973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:07:55+00:00 2026-06-16T16:07:55+00:00

have a great 2013. I am getting my hands wet on my first PS

  • 0

have a great 2013. I am getting my hands wet on my first PS Script and I am stuck on a very common error, the “Unexpected Token” error. I’ve searched the internet, but could not find an answer, so please help me out.

    If ($_.Voorvoegsel.Trim() -ieq "") {
        $dn = $_.Voornaam.Trim() + " " 
        $dn += $_.Achternaam.Trim()
        $email = $_.Voornaam.substring(0,1).ToLower() + "."
        $email+= $_.Achternaam.Trim().ToLower() + "@test.nl
    } Else {
        $dn = $_.Voornaam.Trim() + " "
        $dn += $_.Voorvoegsel.Trim() + " "
        $dn += $_.Achternaam.Trim() 
        $email = $_.Voornaam.substring(0,1).ToLower() + "."
        $email += $_.Voorvoegsel.Replace(" ","").ToLower()
        $email += $_.Achternaam.Trim().ToLower() + "@test.nl
    }

The strange thing is that it errors on the $_.Voorvoegsel variable in the else statement:

Unexpected token '
            $dn += $_.Voorvoegsel.Trim()
            $dn += ' in expression or statement.
At C:\Users\Public\Documents\PSImportTest.ps1:42 char:12
+             $dn = $_ <<<< .Voornaam.Trim() + " "
    + CategoryInfo          : ParserError: (
            $dn += $_....m()
            $dn += :String) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

Anyone out there who sees what my blind spot is here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:07:57+00:00Added an answer on June 16, 2026 at 4:07 pm

    It may be that you are missing an end quote on line 5:

    $email += $_.Acternaam.Trim().ToLower() + "@test.nl"
    

    It looks like you also may be missing one on line 12. Powershell may think the rest of the code, until the next quote character, is part of your string literal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a great question for you. I searched all the Google and MSDN
First of all I am an autodidact so I don't have great know how
I have a great idea about cheating on exams. My school uses very old
I have this great script that uses jQuery to display a small portion of
I have a great problem for parse a very difficult json string. For Eg
I have a great problem about the rotation in three.js I want to rotate
I have a great app for capturing shoutcast streams :-) . So far, it
I have a great concern in deploying the TinyMCE editor on a website. Looking
Scenario: We have a great deal of server environmental information (names, IPs, roles, firewall
I used to have a great Firefox add-on for this and I can't remember

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.