Link to home
Start Free TrialLog in
Avatar of RobertSamples
RobertSamplesFlag for Afghanistan

asked on

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"
Avatar of becraig
becraig
Flag of United States of America image

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"
Avatar of RobertSamples

ASKER

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.
do you think it's freaking out on the '-' in "ACME - text" ?
ASKER CERTIFIED SOLUTION
Avatar of becraig
becraig
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
well something is all jacked up with the space between the arguments.

ISE showed me where the problem is, thanks
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.