Use the SHADOW command to monitor another terminal services user session

This is a simple but useful command to allow you to shadow another terminal services user when working in a remote desktop environment, this often works when the “remote control” option in Task Manager or Terminal Services Manager fails to connect to the session.

To determine the session ID of the user you wish to shadow you can either check using the task manager “users” tab (see below), paying attention to the “Session” column value:

Shadow Command - Check Users with Task Manager

Shadow Command - Check Users with Task Manager

Alternatively use the query user command at the command prompt to output the session list:

USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
>Jason                rdp-tcp#0           2  Active          .  9/11/2011 11:17 AM
 Bob                  rdp-tcp#4           1  Active          .  9/11/2011 4:03 PM
 John                 rdp-tcp#6           3  Active         11  9/11/2011 8:44 AM

Once you are armed with the “session” name/ID you can connect to the user using the Shadow command:
For example to connect to the top session above I would use “shadow rdp-tcp#0” in the command line.

When finished Press CTRL+* to end the remotely controlled session (use the asterisk [*] from the numeric keypad only).

Jason Vigus

Determine Sharepoint version using SQL query on the Sharepoint config database

We recently had a client who lost their Sharepoint application (web front-end) server, fortunately their Sharepoint databases were located on a different SQL server (which was being backed up). So we started to rebuild the Sharepoint application server & proceeded to restore the content (websites).

When we ran through the Sharepoint configuration wizard which connects the application server to the Sharepoint config database it failed at step 2 with the following error:
“failed to connect to the configuration database an exception of type system.security.securityexception was thrown.
Additional exception information: access denied”

This seemed strange since we were definitely using the correct Sharepoint database user, to be sure we verified the permissions were correct in SQL. It turned out the problem is caused by the Sharepoint config database version running a slightly different version to the application server (they need to be exactly the same).

How did we determine the Sharepoint version of the configuation database then?

Simple…..

The first way is to open a web browser and got to the site settings page (Site Actions > Site Settings > Modify All Settings).

The second method is to run a query against the databases.  Open SQL Server Management Studio, Connect to the server, new query, run the following:

SELECT [VersionId]
      ,[Version]
      ,[Id]
      ,[UserName]
      ,[TimeStamp]
      ,[FinalizeTimeStamp]
      ,[Mode]
      ,[ModeStack]
      ,[Updates]
      ,[Notes]
  FROM [SharePoint_Config].[dbo].[Versions] 
  WHERE VersionId = ‘00000000-0000-0000-0000-000000000000’ 
  ORDER BY Id DESC

 This returns:

VersionId Version Id UserName Updates
00000000-0000-0000-0000-000000000000 12.0.0.6219 4 MOSS\user 3
00000000-0000-0000-0000-000000000000 12.0.0.4518 1 MOSS\user 2

The top row is the latest version, if you have changed the database name from “SharePoint_Config” be sure to update the query to reflect the correct name. Check out this site to see what version you are running.

Once we determined the correct version we created the slipstreamed Sharepoint installation required, re-ran setup and bang everything worked correctly!

Jason Vigus

Recover a deleted Sharepoint site collection from SQL backup (2007/2010)

Lets assume you have NOT been doing Sharepoint site collection backups but you do have SQL database backups. Either the Sharepoint front end web server has died and you have reinstalled a new copy of Sharepoint without your sites loaded:

1. Create a new SQL database & restore your backup into it.
2. At the command prompt use stsadm.exe to add the content database to your new site:
stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver
3. Perform an IISRESET
4. Your all done, load the url and bath in your awesomeness!

Jason Vigus

Command Line Restore SQL Databases With Multiple Data Files Using Tivoli TDP for SQL

Tivoli TDP for SQL is a great backup tool that allows you to take live SQL database backups directly to your backup system, negating the need to perform SQL data dumps to disk first.

TDP SQL Client GUI restores:
The backup side works very well, however restoring SQL databases that use multiple data files is not quite as straight forward as you might imagine as there is a bug in the GUI (client version 5.5.5) where it only support/recognises 2 data files.For basic SQL databases this is fine as its the data & log file (mdf & ldf files), its also not a problem if you are using multiple data files & want to restore over the top of an existing database.

Lets say you want to do a test restore of that really important customer database to a new DB though, in the GUI you can restore into a new name & relocate the files to a new folder….but if you use multiple data files, the GUI only attempts to relocate the first two datafiles, the rest it attempts to restore in the original (source database) folder location – which will fail as its already in use.

TDP SQL Command Line restores:
The solution is to do a command line restore, which is actually quiet straightforward once you’ve done it before. Here is an example:

tdpsqlc restore LiveDB1 full /into=TestDB1 /REL=LiveDB1_datafile /TO=D:\Test_restore\LiveDB1_datafile.mdf /REL=LiveDB1_datafile1 /TO=D:\Test_restore\LiveDB1_datafile1.ndf /REL=LiveDB1_datafile2 /TO=D:\Test_restore\LiveDB1_datafile2.ndf /REL=LiveDB1_logfile /TO=D:\Test_restore\LiveDB1_logfile.ldf

While it looks like there are line returns in the version above to make it more readable this should be entered as a single line in the TDP Command Prompt window when you run it.

Essentially the command restores the last full backup of DB “LiveDB1” to a new database named “TestDB1” & relocates each data/log file to a new directory “D:\Test_restore\” using the /REL & /TO switches. When using the /REL= switch this needs to use the Logical Name found on the “Files” section of the database properties. That switch is followed by the /TO= switch detailing the physical location & filename you are restoring it too. This should be different from the original DB being restored from. For the database LiveDB1 the logicalnames & physical files used are:
LiveDB1_datafile LiveDB1_datafile.mdf
LiveDB1_datafile1 LiveDB1_datafile1.ndf
LiveDB1_datafile2 LiveDB1_datafile2.ndf
LiveDB1_logfile LiveDB1_logfile.ldf

Jason Vigus

Search or List Installed MS Updates/Hotfixes KB Via Command Prompt

A quick and easy way to list the installed Updates / Hotfixes via the command line:
wmic qfe get hotfixid

To output the list of installed Hotfixes to a file try:
wmic qfe get hotfixid > c:\installed-hotfixes.txt

If you want to quickly check to see if a specific Hotfix is installed try this:
wmic qfe get hotfixid |find “968930”

This tool is available in Windows 2000, Windows XP, Windows Vista, Windows 7 & Windows Server 2003/2008.

Jason Vigus

Embed a YouTube video in WordPress posts

When I tried to embed a video on another blog post the other day I did a quick “Google” to see what was involved in the process, to my surprise, rather pleasantly I discovered all you need to do is put the URL of the video you wish to embed straight into the post editor.

For example, I would use the following code to embed the video (no quotes):

“http://www.youtube.com/watch?v=5FFRoYhTJQQ”

And this would be the result:

http://www.youtube.com/watch?v=5FFRoYhTJQQ

Jason Vigus

Mac OSX Screenshots – Keyboard Shortcuts

Here they are, plain & simple!

  • Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop
  • Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop
  • Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop
  • Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard
  • Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard
  • Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard
Jason Vigus

How to install VMWare VSphere client 4.0 & 4.1 on the same computer

I frequently need to manage VMWare servers running either VSphere 4.0 or 4.1, if you are also in this position you will know that when you connect to a v4.1 server using the v4.0 client, it will prompt you to download & install the upgraded version (this is also the case when connecting to a v4.0 server with the v4.1 client) – you will also know that proceeding to do so removes & replaces the version you had installed. Someone I know came up with a simple solution which allows you to run both versions of the client on one computer:

1. Install VSphere Client V4.0 on you computer.

2. Rename the folder “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client” to “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client – V4.0 \”

3. Install VSphere Client V4.1 on your computer, this gets installed to “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client”.

4. Create shortcuts to the relevant version of VSphere Client Launcher in your start menu to the following files:

  •  VSphere Client v4.0: “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client – V4.0\Launcher\VpxClient.exe”
  • VSphere Client v4.1: “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe”

5. Enjoy a simpler VSphere Client experience!

 

Jason Vigus

Apple OSX: How to clear your DNS cache with flushdns via command line

Apple flushdns tool

Apple flushdns tool

DNS requests are usually cached, this is great as it speeds up the lookups on your machine. Occasionally you might want to clear out the cache though, using terminal its very easy to do.

MAC OSX 10.4 And Below:
lookupd -flushcache

MAC OSX 10.5 And Above:
dscacheutil -flushcache 

Tip: To launch terminal click on spotlight & type terminal.

Jason Vigus