bsharath
asked on
Script to update users with the company name in ADS.
Hi,
I have a file which has these details.
Username:Company name
I need a script which can find this user and update these details in the ADS user properties >Organization > Company.
Is there a script which can do this.
Need results file to generate with succuess and failure.
REgards
Sharath
I have a file which has these details.
Username:Company name
I need a script which can find this user and update these details in the ADS user properties >Organization > Company.
Is there a script which can do this.
Need results file to generate with succuess and failure.
REgards
Sharath
ASKER
Shouldd i user the NT login name or full name.Will it update the exact user?
Can i have a failure report also.If the user not found?
I have 2 more similar questions already posted.Can you help me in those.
Can i have a failure report also.If the user not found?
I have 2 more similar questions already posted.Can you help me in those.
Yes it will write an error inside C:\UCReport.txt (if any)
Change following inside the script:
From:
dsquery user -name "%%u*" | DSMod user -company "%%v" >>C:\UCReport.txt
To:
dsquery user -upn "%%u*" | DSMod user -company "%%v" >>C:\UCReport.txt
Change following inside the script:
From:
dsquery user -name "%%u*" | DSMod user -company "%%v" >>C:\UCReport.txt
To:
dsquery user -upn "%%u*" | DSMod user -company "%%v" >>C:\UCReport.txt
ASKER
I get this.
Changing Company Name of: sharathr to "india"
dsmod failed:`Target object for this command' is missing.
type dsmod /? for help.Changing Company Name of: Sharath reddy to " India"
dsmod failed:`Target object for this command' is missing.
type dsmod /? for help.Press any key to continue . . .
Changing Company Name of: sharathr to "india"
dsmod failed:`Target object for this command' is missing.
type dsmod /? for help.Changing Company Name of: Sharath reddy to " India"
dsmod failed:`Target object for this command' is missing.
type dsmod /? for help.Press any key to continue . . .
Are you aware that you can select Multiple Accounts in 2003, right click on Properties and then just type the company name in and ir gets entered into all accounts ?
Can you please post what result do you get after applying following commands
Click Start - Run -> Cmd.exe
DSQuery user -upn sharathr*
And
DSQuery user -samid sharathr*
Click Start - Run -> Cmd.exe
DSQuery user -upn sharathr*
And
DSQuery user -samid sharathr*
ASKER
KCTS
You are correct but i need to change 4 types of company names specific to users.
Say some users are contract so need to mention there company name in the box.Thats why i need a script which can update the company name based on the list.
You are correct but i need to change 4 types of company names specific to users.
Say some users are contract so need to mention there company name in the box.Thats why i need a script which can update the company name based on the list.
ASKER
I get this
C:\>DSQuery user -upn sharathr*
Nothing
C:\>DSQuery user -samid sharathr*
"CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=Deve
lopment,DC=Group,DC=co,DC= uk"
C:\>DSQuery user -upn sharathr*
Nothing
C:\>DSQuery user -samid sharathr*
"CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
lopment,DC=Group,DC=co,DC=
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:: * This script require "UserCompany.txt" file on C: drive root from where it will pick user names (CN).
:: * UserCompany.txt file should be in following format
:: <UserName>:<Description>
:: Like:
:: Farhan Kazi:IBM Pakistan
:: Khurram:IBM Oman
:: * Successful run will generate "UCReport.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .bat extension.
:: *** SCRIPT START ***
@Echo Off
SETLOCAL
IF NOT EXIST C:\UserCompany.txt Goto ShowErr
FOR %%R IN (C:\UserCompany.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\UCReport.txt DEL /F /Q C:\UCReport.txt
FOR /F "delims=: tokens=1-2" %%u IN (C:\UserCompany.txt) Do (
Echo Changing Company Name of: %%u to "%%v"
Echo Changing Company Name of: %%u to "%%v" >>C:\UCReport.txt
dsquery user -name "%%u*" | DSMod user -company "%%v" >>C:\UCReport.txt
)
Goto EndScript
:ShowErr
Echo "UserCompany.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***