command line

Remove Admin Rights Scripts

4

We have been tightening up security at our place recently which has prompted me to do a couple of simple scripts to find out who has local admin rights and another one to take them away. I again have used a couple of tools to get the job done one is isadmin.exe by Bill Stewart which just checks that locally logged on users group access to see if they are members of the administrators group. The other is blat which is a utility for sending smtp emails by command line. I then pipe the output to a text file and get the contents emailed to me and then just use filters to filter the email into either a box for admin users or a box for non admin users.

That script is:

:script for discovering admin privledges

If exist c:\%nwusername%.txt (exit) else goto :check

:check

echo off

(drive letter):\admin\isadmin.exe > c:\%nwusername%.txt

{drive letter):\BLAT\BLAT C:\%nwusername%.txt -TO (emailadress.co.uk) -SERVER (email server) -F (emailaddress.co.uk)

The bits in () you will obviously need to personalise for your environment.

Once that has reported the results to me any users who have admin permissions then also get added to a script that removes them from the Administrators Group. Again its faily simplistic:

If exist c:\delusr.txt(exit) else goto :script for removing admin Privledges

:Script for removing admin Privledges

echo off

net localgroup administrators %username% /delete > c:\delusr.txt

echo %username% has been deleted from %nwusername% admin account >> c:\delusr.txt

(drive letter):\BLAT\BLAT C:\delusr.TXT -TO (emailaddress.co.uk) -SERVER (email server) -F (emailaddress.co.uk)

So hopefully that will complete the removal or admin rights, I shall wait a week or two then change the text file the first script looks for so that it runs again and hopefully will get no reports of people still with admin rights.

Now of course admin rights are generally given to users because of funky old applications that cant handle tightened permissions so I expect that may be a bit of running around trying to find ways of fixing broken apps.

One thing I must say again is how brilliant notepad++ is for creating and editing any kind of script file. If you need to write scripts I would recommend at least trying it out.

Lots of effort and new toys

0

Hi all,

Well I've spent a good two or three hours fiddling with ds commands last night and its all starting to sink in. I've been looking at the commands on and off for a couple of weeks and last night I felt I'd made real progress with learning them.

With the way I've designed my AD structure with user nested in departmental OU's in an OU called scrivnet users, this added an additional layer of complexity to my ds commands which I feel has really helped me out.

I've added about 10 users using the dsadd command typing it out from scratch each time so I can memorise how to format it and also look what it does to the object so I can change the next user to include other fields.

I think I shall write another brief tutorial on the commands once I'm quite happy with using them.

On another note last week I picked up a new car an 04 vectra. Its pretty much the same as my old mondeo just with a different badge on the front but it will do me nicely until I'm earning a bit more as I really want a passat eventually.

Sent from my BlackBerry® wireless device

Shutdown revisited

1


After a brief write up the other day I thought I would expand abit on the shutdown command and what i’ve been using it for.

The shutdown command allows you to “imaginativly” shutdown the computer from a Dos command. Common switches include -s for shutdown -r for reboot -f to force it to shutdown incase you have a stubborn app still loaded, and -t xx for time in seconds until shutdown. Also you can specific a -m COMPUTERNAME to specify a remote computer you want this to run on.

So a few examples of the command would start out and simply

SHUTDOWN -S

This would start a countdown of 30 seconds (whilst displaying a warning message) and would start the shutdown proceedure imediatly after the time has elapsed.

SHUTDOWN -S -T 10

This would do the same as above but start the timer at 10 seconds

SHUTDOWN -R -M \\HOMEPC

This would make the remote computer HOMEPC restart after the 30 second countdown.

IMPORTANT: at any point in the countdown you can type SHUTDOWN -A to abort the shutdown.

So I’ve used it at work this week as part of a scheduled task for a users pc. I was running a few diags on the machine and also doing a defrag, as I didnt want to sit there and watch it I started the scheduled task wizard and pointed it to the shutdown file located in %winddir%\system32 and then added the switches to it. Then it was just a case of following the wizard to get the machine to power itself off a 9pm. User didnt say anything the next morning so i assume it all went according to plan.

Go to Top