Update User Attributes with Set-Aduser powershell script

i get the following error when trying to update user attributes with a power shell script.



i have the following single line in a .ps1 file on the c:

Set-ADUser testuser -Description "Test Company Name - Staff" -Office "Test Office" -Title "Test User" -Department "Test Dept" -Company "Testing Company Name" -StreetAddress "12345 Test St" -City "Testville" -State "TX" -PostalCode "12345" -OfficePhone "111-222-3333"


c:\test\user_update.ps1

From a elivated PS console i type the following command

c:\test\user_update.ps1

i get the following error.


The string starting:
At C:\_admin\users_update\users_test.ps1:1 char:254
+ Set-ADUser testuser -Description "Test Company - Staff" -Office "Test Office" -Title "Test User" -Department "Test De
pt" -Company "Testing Company" -StreetAddress "12345 Test St" -City "Testing" -State "TX" -PostalCode "12345" -OfficePh
one "111-222-3333 <<<< "
is missing the terminator: ".
At C:\_admin\users_update\users_test.ps1:2 char:1
+  <<<<
    + CategoryInfo          : ParserError: (
:String) [], ParseException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Set-ADUser testuser -Description "Test Company Name - Staff" -Office "Test Office" -Title "Test User" -Department "Test Dept" -Company "Testing Company Name" -StreetAddress "12345 Test St" -City "Testville" -State "TX" -PostalCode "12345" -OfficePhone "111-222-3333"
RobertSamplesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

becraigCommented:
Set-ADUser testuser -Description "Test Company Name - Staff" -Office "Test Office" -Title "Test User" -Department "Test Dept" -Company "Testing Company Name" -StreetAddress "12345 Test St" -City "Testville" -State "TX" -PostalCode "12345" -OfficePhone "111-222-3333"

Can you explain this entry:
-Description "Test Company Name - Staff"

Should it be:
-Description "Test Company" -Name "Staff"
0
RobertSamplesAuthor Commented:
no that is correct as is.

it would normally read

ACME Company - Front Office
ACME Company - Back Office

it's an employee classification we use, i generalized everything.

personally i can't find the error.

i'm trying to update 155 employees and have them one after another in the .PS1 file.
0
RobertSamplesAuthor Commented:
do you think it's freaking out on the '-' in "ACME - text" ?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

becraigCommented:
Can you post more of the script

The error is pointing to +  <<<<

However I do not see a plus sign in the line you are referencing, it seems clearly a  " is missing somewhere.

Try loading in ISE or something else and validating your script.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobertSamplesAuthor Commented:
here is the script, i had to rename it to add .txt to the end to allow it upload.

it's a single line.
users-update.ps1.txt
0
becraigCommented:
Ok this works perfectly for me:


Set-ADUser testuser -Description "Test Company Staff" -Office "Test Office" -Title "Test User" -Department "Test Dept" -Company "Testing Company" -StreetAddress "12345 Test St" -City "Testing" -State "TX" -PostalCode "12345" -OfficePhone "(123) 2223333"



I do not get any errors running this command.
0
RobertSamplesAuthor Commented:
well something is all jacked up with the space between the arguments.

ISE showed me where the problem is, thanks
0
becraigCommented:
Great that looking at it in ISE got it sorted for you, it is always a good idea to write in an environment to validate your scripts.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.