Friday, August 27, 2010

Configure TCP/IP from the Command Prompt

In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe.

Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script in a text file for archival purposes or to help you configure other servers.

Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003.

You can use the Netsh.exe tool to perform the following tasks:

  • Configure interfaces
  • Configure routing protocols
  • Configure filters
  • Configure routes
  • Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service
  • Display the configuration of a currently running router on any computer
  • Use the scripting feature to run a collection of commands in batch mode against a specified router.

What can we do with Netsh.exe?

With Netsh.exe you can easily view your TCP/IP settings. Type the following command in a Command Prompt window (CMD.EXE):

netsh interface ip show config

With Netsh.exe, you can easily configure your computer's IP address and other TCP/IP related settings. For example:

The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

(The above line is one long line, copy paste it as one line)

Netsh.exe can be also useful in certain scenarios such as when you have a portable computer that needs to be relocated between 2 or more office locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration.

First, connect your portable computer to location #1, and then manually configure the required settings (such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses).

Now, you need to export your current IP settings to a text file. Use the following command:

netsh -c interface dump > c:'location1.txt

When you reach location #2, do the same thing, only keep the new settings to a different file:

netsh -c interface dump > c:'location2.txt

You can go on with any other location you may need, but we'll keep it simple and only use 2 examples.

Now, whenever you need to quickly import your IP settings and change them between location #1 and location #2, just enter the following command in a Command Prompt window (CMD.EXE):

netsh -f c:'location1.txt

or

netsh -f c:'location2.txt

and so on.

You can also use the global EXEC switch instead of -F:

netsh exec c:'location2.txt

Netsh.exe can also be used to configure your NIC to automatically obtain an IP address from a DHCP server:

netsh interface ip set address "Local Area Connection" dhcp

Would you like to configure DNS and WINS addresses from the Command Prompt? You can. See this example for DNS:

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

and this one for WINS:

netsh interface ip set wins "Local Area Connection" static 192.168.0.200

Or, if you want, you can configure your NIC to dynamically obtain it's DNS settings:

netsh interface ip set dns "Local Area Connection" dhcp

BTW, if you want to set a primary and secondary DNS address, add index=1 and index=2 respectively to the lines of Netsh command.

As you now see, Netsh.exe has many features you might find useful, and that goes beyond saying even without looking into the other valuable options that exist in the command.

Friday, July 23, 2010

Troubleshoot Group Policy from the Command Line with GPRESULT

When you are trying to determine why policy is not being applied as expected, one of first things you should do is examine the Resultant Set of Policy (RSoP) for the user and computer experiencing problems with policy settings. Using the Gpresult command-line utility, you can view RSoP.

Gpresult provides details on the following:

* Special settings applied for folder redirection, software installation, disk quota, IPSec, and scripts
* The last time Group Policy was applied
* The domain controller from which policy was applied and the security group memberships for the computer and user
* The complete list of GPOs that were applied as well as the complete list of GPOs that were not applied because of filters

Gpresult has the following basic syntax:
gpresult /s ComputerName /user Domain\UserName

Here, ComputerName is the name of the computer that you want to log policy results for and Domain\UserName indicates the user that you want to log policy results for. For example, to view the RSoP for CorpPC85 and the user Tedg in the Cpandl domain, you would type the following command:
gpresult /s corppc85 /user cpandl\tedg

You can view more detailed output by using one of the two verbose options. The /v parameter turns on verbose output and results are displayed only for policy settings in effect. The /z parameter turns on verbose output with settings for policy settings in effect and all other GPOs that have the policy set. Because Gpresult output can be fairly long, you should create an HTML report using the /h parameter or an XML report using the /x parameter. Here are a couple examples using these parameters:
gpresult /s corppc85 /user cpandl\tedg /h gpreport.html
gpresult /s corppc85 /user cpandl\tedg /x gpreport.xml

Friday, June 4, 2010

Using Remote Desktop via your Browser

In Windows Vista:

Attached Image


This is really simple and easy. Works with Windows Server 2003 and XP:

Using “Add or Remove Programs”, select “Add/Remove Components” and in “Application Server” select “Details”. You will find another list and in “Internet Information Services” select “Details” again and check “Remote Desktop Web Connection”.


Attached Image

When the installation starts you’ll be prompted to insert the Windows Server 2003 CD. After the installation is complete you are ready to use your Remote Desktop Connection in the default direction established in IIS: http://localhost/tsweb/

Attached Image

As a best practice, is always recommended that you set your permissions in IIS to not allow anonymous authentication, any other will be fine; and use HTTPS for the communication.

Attached ImageI

How To Change SID On Windows 7 And Windows Server 2008 R2 Using Sysprep

Sysprep on Windows Server 2008 R2 Datacenter edition, but same steps apply for Windows7 also.

First, click to Start->Run, type sysprep and press OK.

Posted Image

This will open sysprep folder which is located in c:\Windows\System32. Open sysprep application.

Posted Image

This will open System Preparation Tool 3.14 window. As a System Cleanup Action select Enter System Out-of-Box Experience (OOBE). Important: select Generalize if you want to change SID, it�s not selected by default. As Shutdown Options select Reboot.

Posted Image

It will take some time for sysprep to finish, so grab a cup of coffee and wait.

Posted Image

After rebooting you�ll have to enter some data, for example, Country or region, Time and currency and Keyboard input.

Posted Image

Also, you�ll have to accept EULA. And that�s it. After booting, in Server Manager you�ll see that everything is changed, if you had some settings set now they�re changed.

Posted Image

Now you can again use PsGetSid to check that your OS has new SID.

Thursday, June 3, 2010

Start System Restore from a command prompt in Vista

You can start System Restore from a command prompt window if you can't start your computer in any mode other than safe mode with command prompt.

1. Start your computer in safe mode with command prompt. For more information, see Start your computer in safe mode.

2. At the command prompt, type rstrui.exe, and then press ENTER. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

Note

If you use System Restore when the computer is in safe mode, you can't undo the restore operation. However, you can run System Restore again and choose a different restore point if one exists.

How to start System Restore by using the Command prompt

To start System Restore using the Command prompt, follow these steps:
  1. Restart your computer, and then press and hold F8 during the initial startup to start your computer in safe mode with a Command prompt.
  2. Use the arrow keys to select the Safe mode with a Command prompt option.
  3. If you are prompted to select an operating system, use the arrow keys to select the appropriate operating system for your computer, and then press ENTER.
  4. Log on as an administrator or with an account that has administrator credentials.
  5. At the command prompt, type %systemroot%\system32\restore\rstrui.exe, and then press ENTER.
  6. Follow the instructions that appear on the screen to restore your computer to a functional state.

Wednesday, April 21, 2010