RobertSamples
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\use rs_test.ps 1: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\use rs_test.ps 1:2 char:1
+ <<<<
+ CategoryInfo : ParserError: (
:String) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfS tring
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 "
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\use
+ 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\use
+ <<<<
+ CategoryInfo : ParserError: (
:String) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfS
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
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.
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.
ASKER
do you think it's freaking out on the '-' in "ACME - text" ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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.
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.
ASKER
well something is all jacked up with the space between the arguments.
ISE showed me where the problem is, thanks
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.
Can you explain this entry:
-Description "Test Company Name - Staff"
Should it be:
-Description "Test Company" -Name "Staff"