mycloudcake.com Rotating Header Image

MS SQL single user tempdb recovery

Start MS SQL in minimal configuration mode
sqlserver.exe -f
Version: ms sql 2000 sp4

If cluster instance remember to connect to

USE master
go
ALTER DATABASE tempdb MODIFY file (name = tempdev, filename = 'G:\SQLData\TempDB\tempdb.mdf')
ALTER DATABASE tempdb MODIFY file (name = TEMPDEV2, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb2.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev3, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb3.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev4, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb4.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev5, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb5.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev6, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb6.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev7, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb7.ndf')
ALTER DATABASE tempdb MODIFY file (name = tempdev8, filename = 'G:\SQLData\TempDB_RAMDISK\tempdb8.ndf')
go
 
ALTER DATABASE tempdb MODIFY file (name = templog, filename = 'G:\SQLData\TempDB_RAMDISK\templog.ldf')
go
 
SELECT * FROM master..sysaltfiles
go
 
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb2.ndf' WHERE name = 'tempdev2'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb3.ndf' WHERE name = 'tempdev3'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb4.ndf' WHERE name = 'tempdev4'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb5.ndf' WHERE name = 'tempdev5'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb6.ndf' WHERE name = 'tempdev6'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb7.ndf' WHERE name = 'tempdev7'
UPDATE master..sysaltfiles SET filename = 'G:\SQLData\TempDB_RAMDISK\tempdb8.ndf' WHERE name = 'tempdev8'
 
go

Schedule windows hosts to shutdown or reboot automatically

Its sometimes necessary to reboot (or shutdown) windows machines due to patch installations, driver upgrades, etc. With Unix/Linux machines reboots/shutdowns can be scheduled via cron jobs. Most of the time for production machines we would like this to occur out of business hours with no user intervention for such a trivial task. Windows server comes with no built-in command to schedule a reboot (or shutdowns).

Sysinternals has a great little tool call PsShutdown, it is a command line utility. PsShutdown requires no manual installation of client software, simply run it from the command line and away it goes.

You can download PsShutdown from sysinternals web site.

How to schedule Windows machines to reboot/shutdown

Download the psshutdown util and put in a folder some place ie. C:\admtools. Next open a windows command prompt and use the windows ‘at’ command to schedule a reboot
This command will reboot the system at 2am:

c:> at 2:00am c:\admtools\psshutdown.exe -r -f -c -t 10

If you want to shutdown the system at 2am:

c:> at 2:00am c:\admtools\psshutdown.exe -s -f -c -t 10

Where,

  • -s: Shutdown windows server
  • -r: Reboot windows server
  • -f: Forces all running application to exit
  • -c: Allow the shutdown to by cancel by user
  • -t: Specifies the countdown in seconds until the shutdown

For more information run the “psshutdown /?” for all possible command line switches

Installing Windows Powershell and VI toolkit

The VI Toolkit (for Windows) provides a powerful yet simple command line interface for task based management of the VMware Infrastructure platform. Windows Administrators can easily manage and deploy the VMware Infrastructure with a familiar, simple to use command line interface.

Step 1. The VI toolkit requires Microsoft powershell to run, if you dont have Microsoft Powershell installed, you can get it from the Mircosoft website throught this link

Step 2. Download the latest VI toolkit from the VMware webssite through this link

System Requirements for Windows Powershell

  • Requires .NET Framework Version 2.0

Install or update VMware tools without immediate reboot

I recently came across a requirement to install an updated version of VMware Tools without rebooting the guest OS. It became apparent very quickly that passing arguments to the MSI installer was the way forwarded. But how to do this automatically for a large number of guests was unclear.

I did some searching on the VMware community’s Site and came across this nifty little VI toolkit (powershell) script.

If you don’t have The VI toolkit installed you can see my blog posting here on how to install it.

So here is the script and you can download it here..

Remember to set $updlist to your cluster name. If your not using a cluster and just ESX hosts you could use ‘get-vmhost -name ESXHOSTNAME’ instead of get-cluster.

$cluster = 'SETCLUSTERNAME'
$insParm = '/s /v"/qn /norestart"'
$updList = get-cluster -name $cluster | get-vm | where-object {$_.powerstate -eq "PoweredON"} | foreach-object { get-view $_.ID } | where { $_.guest.toolsstatus -match "toolsOld" }
 
foreach ($uVM in $updList)
 
{
$uVM.name
$uVM.UpgradeTools_Task($insParm)
#Wait 30 seconds before starting another update task
Start-sleep -s 30
}

Once the tools have been installed to the guests the guests need to be rebooted in order for the updated drivers to take effect.