April 30, 2015 at 12:25 pm
Need script for below.
1)Add the user ''AD\abc' to local admin group in server.
2)Create login 'AD\abc' and Grant sysadmin access for AD\abc
Any help Please ...
April 30, 2015 at 2:31 pm
Two seconds in Google would have given you the answer.
However...
To add a user to a the local administrators group:
net localgroup Administrators AD\abc /add
To create a windows login and grant sysadmin privileges:
CREATE LOGIN [AD\abc] FROM WINDOWS;
ALTER SERVER ROLE sysadmin ADD MEMBER [AD\abc];
-- Gianluca Sartori
April 30, 2015 at 11:26 pm
thank you.
Actually i need a sql script to add the user to local admin also.
May 1, 2015 at 6:35 am
charipg (4/30/2015)
thank you.Actually i need a sql script to add the user to local admin also.
xp_cmdShell for the commandline script already provided, but i'd bet there is a 90% chance it will fail, since you have to be an administrator to add an administrator, and the Service Account running SQL probably is not a local admin(and should not be, either)
administration of users for the operating system is a function that should always be handled outside of SQL, in my opinion.
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply