Thursday, July 23, 2009

Script to Copy the Same File to a Number of Different Computers

 

‘------------- Script Starts from here --------------------


Const ForReading = 1
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt")

Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine



strRemoteFile = "\\" & strComputer & "\C$\Scripts\Test.doc"
objFSO.CopyFile "C:\Scripts\Test.doc", strRemoteFile, OverwriteExisting
Loop
’ ---------------------Script Ends here ----------------------------------


Here, at long last, we call the CopyFile method, passing three parameters:




  • The path to the local file (C:\Scripts\Test.doc), the file we want copied.


  • The UNC path for the remote computer (stashed in the variable strRemoteFile).


  • The constant OverWriteExisting (just in case Test.doc already exists in the C:\Scripts folder).



We copy the file, then loop around and repeat the process with the next computer in the list.




Technorati Tags: ,

Tuesday, June 23, 2009

How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server

When you change the name of the computer that is running SQL Server, the new name is recognized during SQL Server startup. You do not have to run Setup again to reset the computer name. Instead, use the following steps to update system metadata that is stored in sys.servers and reported by the system function @@SERVERNAME. Update system metadata to reflect computer name changes for remote connections and applications that use @@SERVERNAME, or that query the server name from sys.servers.

The following steps cannot be used to rename an instance of SQL Server. They can be used only to rename the part of the instance name that corresponds to the computer name. For example, you can change a computer named MB1 that hosts an instance of SQL Server named Instance1 to another name, such as MB2. However, the instance part of the name, Instance1, will remain unchanged. In this example, the \\ComputerName\InstanceName would be changed from \\MB1\Instance1 to \\MB2\Instance1.

Before you begin

Before you begin the renaming process, review the following information:

  • When an instance of SQL Server is part of a SQL Server failover cluster, the computer renaming process differs from a computer that hosts a stand-alone instance.
  • SQL Server does not support renaming computers that are involved in replication, except when you use log shipping with replication. The secondary computer in log shipping can be renamed if the primary computer is permanently lost. For more information, see Replication and Log Shipping.
  • When you rename a computer that is configured to use Reporting Services, Reporting Services might not be available after the computer name change. For more information, see Renaming a Report Server Computer.
  • When you rename a computer that is configured to use database mirroring, you must turn off database mirroring before the renaming operation. Then, re-establish database mirroring with the new computer name. Metadata for database mirroring will not be updated automatically to reflect the new computer name. Use the following steps to update system metadata.
  • Users who connect to SQL Server through a Windows group that uses a hard-coded reference to the computer name might not be able to connect to SQL Server. This can occur after the rename if the Windows group specifies the old computer name. To ensure that such Windows groups have SQL Server connectivity following the renaming operation, update the Windows group to specify the new computer name.

You can connect to SQL Server by using the new computer name after you have restarted SQL Server. To ensure that @@SERVERNAME returns the updated name of the local server instance, you should manually run the following procedure that applies to your scenario. The procedure you use depends on whether you are updating a computer that hosts a default or named instance of SQL Server.

To rename a computer that hosts a stand-alone instance of SQL Server

  • For a renamed computer that hosts a default instance of SQL Server, run the following procedures:

    Copy Code

    sp_dropserver <old_name>

    GO

    sp_addserver <new_name>, local

    GO

    Restart the instance of SQL Server.

  • For a renamed computer that hosts a named instance of SQL Server, run the following procedures:

    Copy Code

    sp_dropserver <old_name\instancename>

    GO

    sp_addserver <new_name\instancename>, local

    GO

    Restart the instance of SQL Server.

After the Renaming Operation

After a computer has been renamed, any connections that used the old computer name must connect by using the new name.

To verify that the renaming operation has completed successfully

  • Select information from either @@SERVERNAME or sys.servers. The @@SERVERNAME function will return the new name, and the sys.servers table will show the new name. The following example shows the use of @@SERVERNAME.

    SELECT @@SERVERNAME AS 'Server Name'

Additional Considerations

Remote Logins - If the computer has any remote logins, running sp_dropserver might generate an error similar to the following:

Server: Msg 15190, Level 16, State 1, Procedure sp_dropserver, Line 44

There are still remote logins for the server 'SERVER1'.

To resolve the error, you must drop remote logins for this server.

To drop remote logins

  • For a default instance, run the following procedure:

    sp_dropremotelogin old_name

    GO

  • For a named instance, run the following procedure:

    sp_dropremotelogin old_name\instancename

    GO

Linked Server Configurations - Linked server configurations will be affected by the computer renaming operation. Use sp_addlinkedserver or sp_setnetname to update computer name references. For more information, see the sp_addlinkedserver (Transact-SQL) or sp_setnetname (Transact-SQL) SQL Server Books Online topic on MSDN.

Client Alias Names - Client aliases that use named pipes will be affected by the computer renaming operation. For example, if an alias "PROD_SRVR" was created to point to SRVR1 and uses the named pipes protocol, the pipe name will look like \\SRVR1\pipe\sql\query. After the computer is renamed, the path of the named pipe will no longer be valid and. For more information about named pipes, see the Creating a Valid Connection String Using Named Pipes SQL Server Books Online topic on MSDN.

Renaming a Report Server Computer

Renaming a computer causes a corresponding name change for the Web server and SQL Server instance (if it is on the same computer). In some cases, SQL Server Reporting Services may not be accessible after a computer name change. Use the steps provided in this topic to reconfigure a report server after a computer name change.

Renaming a SQL Server Database Engine

If you rename the SQL Server Database Engine instance that runs the report server database, do the following:

  1. Start the Reporting Services Configuration tool and connect to the report server that uses the report server database on the renamed server.
  2. Open the Database Setup page.
  3. In Server Name, type or select the SQL Server name, and then click Connect.
  4. Click Apply.

If the report server is using a local Database Engine instance, you can use (local) or (local)\instancename to specify the server. If you use (local) to refer to the server, you can rename the server and the connections will continue to work. If you are using a remote server, or if Reporting Services is configured using the server name, you must update the database connection information whenever the server name is changed.

Renaming a Report Server Computer

If you rename a computer that runs a report server, do the following:

  1. Open RSReportServer.config in a text editor and modify the UrlRoot setting to reflect the new server name. The UrlRoot setting is used by delivery extensions to compose the URL used to access items stored on the report server. Changing the report server URL address requires that you update the UrlRoot setting so that subscriptions continue to deliver reports as expected.
  2. In the same file, if it is set, modify the ReportServerUrl setting to reflect the new server name. Note that this setting is not used in every installation. If it is empty, do nothing.

Wednesday, June 17, 2009

WINDIRSTAT: Visualize Drive Usage

Features

WinDirStat reads the whole directory tree once and then presents it in three useful views:

  • The directory list, which resembles the tree view of the Windows Explorer but is sorted by file/subtree size,
  • The treemap, which shows the whole contents of the directory tree straight away,
  • The extension list, which serves as a legend and shows statistics about the file types.
  • Coupling. Select an item in the directory list: The treemap highlights it; and vice versa.
  • Zooming.
  • Built-in cleanup actions including Open, Show Properties, Delete.
  • User-defined cleanups (command line based).
  • Works with network drives and UNC paths.
  • 'Create disk usage report' option.

Main Window

Click here to visit WINDIRSTAT home page.

Download

Technorati Tags: ,

Thursday, May 28, 2009

Hyper-V Deployment Guide

You can download detailed Hyper-V Deployment guide from the below mentioned link.

Download Hyper-V Deployment  Guide

Script to List the VMs in a Hyper-V Host

This script will collect the list and status of the VMs hosted in a  hyper-V host.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
Set vmcollection = objWMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem",,48)
Wscript.Echo VbCrLF
Wscript.Echo "Name Description State "
Wscript.Echo "--------------------------------------- ---------------------------------- -------------"

For Each vm in vmcollection
VMStateCode = vm.EnabledState
Select Case VMStateCode
Case 2 VMState = "Running"
Case 3 VMState = "PowerOff"
Case 4 VMState = "ShuttingDown"
Case 10 VMState = "Reset"
Case 32768 VMState = "Paused"
Case 32770 VMState = "Starting"
Case 32771 VMState = "SnapshotInProgress"
Case 32772 VMState = "Migrating"
Case 32773 VMState = "Saving"
Case 32774 VMState = "Stopping"
Case 32776 VMState = "Pausing"
Case 32777 VMState = "Resuming"
Case 32769 VMState = "Saved"
Case Else VMState = "Unclassified (so far)"
End Select

Wscript.Echo vm.ElementName & Space(40 - Len(vm.ElementName)) & _
vm.Description & Space(35 - Len(vm.Description)) & _
VMState & " (" &VMStateCode & ")"
Next


Technorati Tags: ,,