Wednesday, January 15, 2014

useful Command for windows server

net user /domain

The above command will return with all the user details such as group names , password expiry date etc.


Use the following command to add domain user to a local group such as ora_dba

Run command prompt  as administrator


net localgroup \ /add

Eg
net localgroup ora_dba GEO\ashish /add



Follwing are the commands to give the details of currently logged in user in a windows machine
whoami

whoami /groups

whoami /priv

whoami /all




To find all the users logged in a windows server

Go to Task Manager, Users


To find the system information including domain name , memory , number of processors etc.

Use the command
systeminfo


Displaying the value of a variable in windows
echo %PATH%

Just typing set will display all variables along with values
set

If you want to display all the variables with the string mq, Use

set|findstr mq
Or
set|findstr -i mq
-i will ignore case for the string mq


Run the below command to run a exe  as a particular user which is different from the current user logged in. 
runas /user:USER-NAME "C:\full\path\of\Program.exe"
Then , Enter the password.


Compare two files in windows
Use the command fc
Example
C:\Users\Admin\Desktop\Firewall Rules>fc "Firewall & F5 change request for
Test Environment - Copy.xlsx" "Firewall & F5 change request for Test Environment
.xlsx"
Comparing files Firewall & F5 change request for Test Environment - Copy.xlsx an
d FIREWALL & F5 CHANGE REQUEST FOR TEST ENVIRONMENT.XLSX
FC: no differences encountered


One of the great ways to execute UNIX commands on windows OS.

Install cygwin and then execute regular UNIX commands. This is very helpful for a UNIX guy who is working on a windows system. He does not have to learn windows powershell , dos commands to do a particular job like searching for a file with a particular string , listing directories by their size , finding file with huge size etc. It becomes a powerful tool . Much powerful than a windows search.