Wednesday, December 28, 2011

How to logoff remote desktop sessions via command line tools?


Query the Remote Server for Current Terminal Sessions

To query and list the sessions on the remote session, you could use QUser.exe or QWinsta

1. QUser

QUser command comes with all the latest Windows clients and servers. This will list the sessions of the remote server (or local machine).
NOTE: if you are using Windows XP, you need to add this location into your System path: C:WindowsSystem32DLLCache. To do this, in command prompt, type the following.
SET PATH = %PATH%;C:WindowsSystem32DLLCache;
QUser help shows,
C:Anand>QUser /?
Display information about users logged on to the system.

QUERY USER [username | sessionname | sessionid] [/SERVER:servername]
  username            Identifies the username.
  sessionname         Identifies the session named sessionname.
  sessionid           Identifies the session with ID sessionid.
  /SERVER:servername  The server to be queried (default is current).


E.g.,

C:>quser /server:MyCitrixSVR
USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
johndoe               ica-tcp#966        10  Active          7  7/31/2008 3:04 PM
averagejoe            ica-tcp#969         1  Active          9  7/31/2008 3:30 PM
familyman             ica-tcp#984         5  Active       1:06  7/31/2008 4:33 PM
normaldude            ica-tcp#987         2  Active          4  7/31/2008 6:20 PM
 

2. QWinsta

QWinsta is little different and better. It has more features and options. It comes with all flavors of Windows.  QWinsta command line help displays as,
C:>qwinsta /?
Display information about Terminal Sessions.

QUERY SESSION [sessionname | username | sessionid]
              [/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER]

  sessionname         Identifies the session named sessionname.
  username            Identifies the session with user username.
  sessionid           Identifies the session with ID sessionid.
  /SERVER:servername  The server to be queried (default is current).
  /MODE               Display current line settings.
  /FLOW               Display current flow control settings.
  /CONNECT            Display current connect settings.
  /COUNTER            Display current Terminal Services counters information.


E.g.,
C:>qwinsta /server:citrixserver
SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
                                             0  Disc    rdpwd
ica-tcp                                 65536  Listen  wdica
rdp-tcp                                 65537  Listen  rdpwd
console                                    16  Conn    wdcon
ica-tcp#966       johndoe                  10  Active  wdica
ica-tcp#969       apple                     1  Active  wdica
ica-tcp#984       averagejoe                5  Active  wdica
ica-tcp#987       familyman                 2  Active  wdica
ica-tcp#989       whoisme                   3  Active  wdica

You are welcome to try the other options QWinsta provides.

Logoff the Remote Sessions

To Log off the terminal session of the remote server, you can use any one of two command line tools. One of LOGOFF and another one is RWINSTA. Before you log off the remote session, you should know the "Session ID" which you get it from "QUSER" OR "QWINSTA" commands as above stated.

1. Logoff

Logoff command kicks off (logging off) the specified remote session. Log off help shows,
C:>logoff /?
Terminates a session.

LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]
  sessionname         The name of the session.
  sessionid           The ID of the session.
  /SERVER:servername  Specifies the Terminal server containing the user
                      session to log off (default is current).
  /V                  Displays information about the actions performed.


E.g.,
C:>logoff /server:infra-apps 1 /v
Logging off session ID 1

2. RWinsta

RWinsta has same parameters and does same thing as log off command. It simply means Reset WINdows STAtion. The help goes as,

C:>RWinsta /?
Reset the session subsytem hardware and software to known initial values.

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]
  sessionname         Identifies the session with name sessionname.
  sessionid           Identifies the session with ID sessionid.
  /SERVER:servername  The server containing the session (default is current).
  /V                  Display additional information.

E.g.,

C:>RWinsta /Server:MyWinServer 1
Note: RWinsta command does not return anything.
Happy Re-setting the remote sessions (Hey, stop cursing your co-workers who didn’t log off their sessions).
Keywords: Reset remote session, Remote Desktop Session

Tuesday, December 27, 2011

Microsoft Word: “This modification is not allowed because the selection is locked.”


If you’re getting a message at the bottom of Word 2007, Word 2010, or other products in the Office suite whenever you try to change the document saying “This modifications is not allowed because the selection is locked.”, this article should answer your question ‘why’ and tell you how to make your document editable again.
wordmodification
There are four possible causes to this problem:
  1. The document is marked as final.
  2. The document is protected.
  3. You are using a trial of Office 2007.
  4. Office 2007 has not yet been activated.

Document is Marked as Final

You will also be unable to paste into the document. If you hover over the Paste button under the Home tab, you’ll get this error message: “This command is currently disabled. This command is not available because the document is marked as final.”
wordmodification1_2
The rest of that error message also points us in the right direction.
Click on the Office button (the circle with the office logo on it in the top-left corner) and go down to the Prepare sub-menu. In this sub-menu, you’ll see an icon next to ‘Mark as Final’ highlighted in orange. This means that it is enabled and the document is “finalized.” It won’t allow any changes to the document. It would be best practice to mark your document as final before you send it off to others for professional evaluation. This also makes the red (spelling) and green (grammar) squiggles under words go away as well as any marked changes throughout the document.
wordmodification2
Besides the ‘Mark as Final’ icon being highlighted in the Prepare sub-menu you will also notice a small version of the same icon at the bottom of Word 2007 in the status bar.
wordmodification2_2
In order to make changes, the document just needs to be “un-finalized.” Go back to the Office button -> Prepare menu and click “Mark as Final” to toggle it off. After that, the icon will now appear unhighlighted and the icon will be gone from the status bar.
wordmodification3

Document is Protected

If you are still not able to edit the document, it may be protected. Switch to the Review tab and then hit the Protect Document button to bring up a small menu.
wordmodification4
From that menu, choose Restrict Formatting and Editing.
wordmodification5
Next to the document, a little window should pop up. If at the bottom, you have a Stop Protection button, click that. If you don’t see that button but instead see a ‘Start protection‘ button, you can close this little window. This setting is not the one locking your document. You may have to enter a password in order to modify the document. You’ll need to know the password in order to stop this protection.
wordmodification6

Your trial of Office 2007 has expired.

If you’re using Office 2007 that came with your computer, likely it was only a trial and has expired. Try opening your document in the free Open Office or purchase a full version of Microsoft Office 2007. “If you have the Office Home and Student 2007 Trial preloaded on your computer, you can purchase the disc version and use the product-key to unlock and activate the preloaded trial.”

Tuesday, December 13, 2011

Installing the File Server Resource Manager Tools in Windows Server 2008

The File Server Resource Manager (FSRM) can be installed separately or it can be installed during the installation of the File Services role. If FSRM needs to be installed on a system that is not a file server or just installed separately, follow the below steps:

1. Log on to the Windows Server 2008 system with an account with administrator privileges.

2. Click on Start > All Programs > Administrative Tools > Server Manager.

3. Click on the Features > Tree pane and Add Features > tasks pane.

4. The Add Features Wizard opens. On the Select Feature page, click the plus symbol next to Remote Server Administration Tools.

5. Click the Role Administration Tools > File Services tools > File Server Resource Manager Tools > Next 

6. On the Confirm Installation Selections page,  click Install to continue.

7. On the Installation Results page, review the result summary, and click Close to complete the installation.

On a system with the FSRM tools installed but not the File Server and File Server Resource Manager roles, FSRM will only be available from the Administrative Tools menu to manage remote servers. On systems with the File Server and File Server Resource Manager roles installed, FSRM will be available in the Server Manager console in the File Services group under Roles.

NOTE: If the File Services role is installed but the File Server Resource Manager Tool cannot connect to the system, chances are that during the File Services role installation, File Server Resource Manager was not selected. To add this functionality, the File Service Resource Manager service will need to be added using the Add Role Services from the tasks pane in the Server Manager Role node.

Monday, December 12, 2011

How to Use Jetpack.exe to Compact a WINS or DHCP Database

Microsoft Windows NT Server includes a utility, Jetpack.exe, that can be used to compact a Windows Internet Name Service (WINS) or Dynamic Host Configuration Protocol (DHCP) database. Microsoft recommends that you compact the WINS database whenever it approaches 30 MB.

The correct syntax for Jetpack.exe is:
JETPACK.EXE

Example commands to compact the WINS database:
CD %SYSTEMROOT%\SYSTEM32\WINS
NET STOP WINS
JETPACK WINS.MDB TMP.MDB
NET START WINS

Example commands to compact the DHCP database:
CD %SYSTEMROOT%\SYSTEM32\DHCP
NET STOP DHCPSERVER
JETPACK DHCP.MDB TMP.MDB
NET START DHCPSERVER

In the examples above, Tmp.mdb is a temporary database that is used by Jetpack.exe. Wins.mdb is the WINS database. Dhcp.mdb is the DHCP database.

Jetpack.exe compacts the WINS or DHCP database by doing the following:
  1. Copies database information to a temporary database file called Tmp.mdb.
  2. Deletes the original database file, Wins.mdb or Dhcp.mdb.
  3. Renames the temporary database files to the original filename.


NOTE: During the compact process, Jetpack.exe creates a temporary file with the name that is specified by the temp database name parameter. The temporary file is removed when the compact process is complete. Make sure you do not have a file already existing in WINS or DHCP folder with the same name as the one specified in the temp database name parameter.

Tuesday, December 6, 2011

Configuring a Server Core installation: Command line

Server Core installation does not include the Windows user interface so you need to install by using command line interface.



Administrative credentials

If you are going to join a server running a Server Core installation to an existing Windows domain, you need a user name and password for an account that has the administrative credentials to join a computer to the domain.

Known issues for configuring a Server Core installation

  • If you close all command prompts, you will have no way to manage the Server Core installation. To recover, you can press CTRL+ALT+DELETE, click Start Task Manager, click File, click Run, and type cmd.exe. Alternatively, you can log off and log back on again.
  • Because there is no Web browser, you cannot activate a Server Core installation or access the Internet through a firewall that requires users to log on.

Steps for configuring a Server Core installation

The following procedures explain how to configure a computer running a Server Core installation. You’ll need to:
  • Set the administrative password.
  • Set a static IP address.

noteNote: A DHCP address is provided by default. You should perform this procedure only if you need to set a static IP address.

  • Join a domain.
  • Activate the server and entering a product key, if required.
  • Configure the firewall.
  • Configure several aspects with one tool (Windows Server 2008 R2 only).
To set the administrative password in Windows Server 2008
  1. When your computer starts for the first time after the installation completes, press CTRL+ALT+DELETE. Type Administrator for the user name and leave the password blank.
  2. The system will inform you that the password has expired and will prompt you to enter a new password.
  3. Type an appropriate password.
To set the administrative password in Windows Server 2008 R2
  1. When your computer starts for the first time after the installation completes, the system will inform you that the user’s password must be changed before logging on for the first time. Click OK.
  2. The system will prompt you to enter a password.
  3. Type an appropriate password.
To set a static IP address
  1. At a command prompt, type the following:
    netsh interface ipv4 show interfaces
  2. Make a note of the number shown in the Idx column of the output for your network adapter. If your computer has more than one network adapter, make a note of the number corresponding to the network adapter for which you wish to set a static IP address.
  3. At the command prompt, type:
    netsh interface ipv4 set address name="" source=static address= mask= gateway=
    Where:
    ID is the number from step 2 above.
    StaticIP is the static IP address that you are setting.
    SubnetMask is the subnet mask for the IP address.
    DefaultGateway is the default gateway.
  4. At the command prompt, type:
    netsh interface ipv4 add dnsserver name=">" address=index=1
    Where:
    ID is the number from step 2 above.
    DNSIP is the IP address of your DNS server.
  5. Repeat step 4 for each DNS server that you want to set, incrementing the index= number each time.
noteNote:
If you set the static IP address on the wrong network adapter, you can change back to using the DHCP address
supplied by using the following command:

netsh interface ipv4 set address name="" source=dhcp
where ID is the number of the network adapter from Step 2.


To join a domain
  1. At a command prompt, type:
    netdom join > /domain: /userd: /passwordd:*
    Where:
    ComputerName is the name of the server that is running the Server Core installation.
    DomainName is the name of the domain to join.
    UserName is a domain user account with permission to join the domain.
  2. When prompted to enter the password, type the password for the domain user account specified by UserName.
  3. If you need to add a domain user account to the local Administrators group, type the following command:
    net localgroup administrators /add \
  4. Restart the computer. You can do this by typing the following at a command prompt:
    shutdown /r /t 0
To rename the server
  1. Determine the current name of the server with the hostname or ipconfig command.
  2. At a command prompt, type:
    netdom renamecomputer  /NewName:
  3. Restart the computer.
To activate the server
  • For Windows Server 2008 R2, enter a product key by typing the following at a command prompt:
    slmgr.vbs –ipk
    Then, for both Windows Server 2008 R2 and Windows Server 2008, activate the server by typing the following at a command prompt:
    slmgr.vbs -ato
If activation is successful, no message will return in the command prompt.

noteNote:



You can also activate by phone, using a Key Management Service (KMS) server, or remotely by typing the following command at a command prompt of a computer that is running Windows Vista or Windows Server 2008:
cscript windows\system32\slmgr.vbs  :-ato

To configure the firewall
  • Use the netsh advfirewall command. For example, to enable remote management from any MMC snap-in, type the following:
    netsh advfirewall firewall set rule group="Remote Administration" new enable=yes
noteNote:
You can also use the Windows Firewall snap-in from a computer running Windows Vista or Windows Server 2008
to remotely manage the firewall on a server running a Server Core installation. To do this, you must first enable
remote management of the firewall by running the following command on the computer running a Server Core
installation:

netsh advfirewall set currentprofile settings remotemanagement enable

How to set Static/DHCP IP Address from command line

In Windows Server 2008 Core installation, the only way to setup IP Address eithe Static or DHCP is from the command line. The following procedure helps setting the IP Address from the command Line using “netsh”. This procedure works in Windows Server 2008 (No core installation as well), Windows Server 2003, Windows XP, Windows Vista.
To setup Static IP Address:
From the command prompt:
1. Type 
C:\Users\Administrator> netsh interface ipv4 show interfaces
Idx  Met   MTU   State        Name
—  —  —–  ———–  ——————-
  1   50 4294967295  connected    Loopback Pseudo-Interface 1
 10   20   1500  connected    Local Area Connection
This should show the Network Connections. We are looking for the name here. On mine, I have one LAN interface and is named as “Local Area Connection”
2. To set a static IP Address type the following command
C:\Users\Administrator>netsh interface ipv4 set address name=”Local Area Connect
ion” source=static address=192.168.0.5 mask=255.255.255.0 gateway=192.168.0.1
The syntax is
netsh interface ipv4 set address name=”” source=static address= mask= gateway=
Where:
ID is the name of the LAN Connection
StaticIP is the static IP address that you are setting
SubnetMask is the subnet mask for the IP address
DefaultGateway is the default gateway
3. Now set the DNS Servers one at a time with the followind command. For each DNS server, increase the index number.
C:\Users\Administrator>netsh interface ipv4 add dnsserver name=”Local Area Conne
ction” address=192.168.0.1 index=1
C:\Users\Administrator>netsh interface ipv4 add dnsserver name=”Local Area Conne
ction” address=192.168.0.10 index=2
The syntax is
netsh interface ipv4 add dnsserver name=”” address=index=1
Where:
ID is the name of the Network Connection
DNSIP is the IP address of your DNS server
This should do. To confirm, do an “ipconfig”
Ethernet adapter Local Area Connection:
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Broadcom 440x 10/100 Integrated Controller
   Physical Address. . . . . . . . . : 00-1D-09-D4-2C-8F
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.0.5(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1
   DNS Servers . . . . . . . . . . . : 192.168.0.1
                                       192.168.0.10
                                       127.0.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled
Set IP through DHCP Server
To set the DHCP Server, from the command line
C:\Users\Administrator> netsh interface ipv4 set address name=”Local Area Connection” source=dhcp
Syntax is
netsh interface ipv4 set address name=”ID” source=dhcp
where ID is the name of the Network Connection