Category Archives: Windows OS

Powershell Script to get the Operating System Infomrmation

You can use the Win32_OperatingSystem class to get the Operating system info.

$hostname = "Enter Computer Name"
Get-WmiObject -class win32_operatingsystem -computer $hostname | select-object *

PS

Advertisements

Create a 32-bit DSN on 64-bit machine for SQL Server

Problem
During the install of an application on a 64-bit Windows machine, the application was unable to list the ODBC System DSN because it had been setup as a 64-bit DSN and the application needed a 32-bit system DSN for connectivity to SQL Server. In this tip, we cover how to create a 32-bit DSN on 64-bit machine.

Solution
http://www.mssqltips.com/sqlservertip/2498/create-a-32bit-dsn-on-64bit-machine-for-sql-server/

The Basics of Hyper-Threading: What is it?

The Basics of Hyper-Threading: What is it?

Modern processors can only handle one instruction from one program at any given point in time. Each instruction that is sent to the processor is called a thread. What I mean is that even though it looks like you’re multitasking with your computer (running more then one program at a time) you’re really not.

The CPU will divide it’s time and power evenly between all the programs by switching back and forth. This little charade of switching back and forth tricks the end user (you and me) and gives us the sense of multitasking.

Dual CPU based systems can work on two independent threads of information from the software but each processor is still limited at working on one thread at any given moment though. The software must be able to dish out two separate pieces of information like Win2000 or Adobe Photoshop for a dual processor system to be really used, by the way.

So what’s new with the Pentium4 3.06GHz processor?

The Pentium 4 3.06 GHz processor is the first Intel desktop processor in history that can process two independent threads at the same time. With a SMT (Simultaneous Multi-Thread) enabled OS like Win2000/XP, Linux, etc. the operation system will identify the P4 3.06 GHz CPU as two logical processors that share the single physical CPU’s resources. A physical processor can be thought of as the chip itself, whereas a logical processor is what the computer sees – with Hyper-Threading enabled the computer can have one physical processor installed in the motherboard, but the computer will see two logical processors, and treat the system as if there were actually two processors.

Even when we put a regular processor under 100% load, we’re never fully utilizing 100% of the execution units. With a HyperThreading enabled processor those spare execution units can used towards computing other things now.

In the last HyperThreading enabled processor, both threads are simultaneously being computed, and the CPU’s efficiency has increased from around 50% to over 90%!

The last example is of dual HyperThreading enabled processors which can work on four independent threads at the same time. Again CPU efficiency is around 90% (and in this case there would be four logical processors, and two physical processors).

While this all sounds very good in the above example, it’s also about the most ideal situation ever – so let’s get back to the real world.

If you were to run two pieces of software that are completely different, and use different execution units, your system performance should get a noticeable boost however!

The operating system will also play a key role in how well HyperThreading works. The OS assigns operations to the independent logical processors, and so if it’s determined that one of the logical CPU’s is to remain idle, the OS will issue a HALT command to the free logical processor thus devoting all of the other system resources to the working logical processor.

As you can see, HyperThreading has the potential to significantly boost system performance under certain circumstances. From Xeon/HyperThreading test results over at Anandtech you get a feel that HyperThreading Technology is still in it’s infancy in terms of real added value across the board. As it stands now, the performance that HT brings to the table is still very application specific. Some programs will notice a performance boost, and in some cases, other programs will see a performance hit with HT enabled.

As more and more software is written specifically for HyperThreading, the performance differences will grow larger. It didn’t take long for software developers to adopt SSE2, hopefully they’ll jump on the HyperThreading bandwagon quickly and the consumer will see the benefit of this this ingenuous technology quickly

XP_cmdshell extended stored procedure (Execute Winows commands)

xp_cmdshell

Executes a given command string or batch file as an operating-system command shell and returns any output as rows of text.

Permission/Rights: Only SysAdmin fixed role can execute it.

Syntax

xp_cmdshell {command_string} [, no_output]

Arguments

command_string

Is the command string to execute at the operating-system command shell or from DOS prompt. command_string is varchar(255) or nvarchar(4000), with no default.

command_string cannot contain more than one set of double quotation marks.

A single pair of quotation marks is necessary if any spaces are present in the file paths or program names referenced by command_string.

If you have trouble with embedded spaces, consider using FAT 8.3 file names as a workaround.

no_output

Is an optional parameter executing the given command_string, and does not return any output to the client.

Examples
xp_cmdshell 'dir *.jpg'

Executing this xp_cmdshell statement returns the following result set:

xp_cmdshell 'dir *.exe', NO_OUTPUT

Here is the result:

The command(s) completed successfully.

<!–[if gte vml 1]&gt; &lt;![endif]–><!–[if !vml]–><!–[endif]–>

Examples
Copy File
EXEC xp_cmdshell 'copy c:\sqldumps\jshah143.bak \\server2\backups\jshah143.bak',  NO_OUTPUT
 
Use return status

In this example, the xp_cmdshell extended stored procedure also suggests return status. The return code value is stored in the variable @result.

DECLARE @result int
EXEC @result = xp_cmdshell 'dir *.exe'
IF (@result = 0)
   PRINT 'Success'
ELSE
   PRINT 'Failure'

 

Pass the parameter to batch file

DECLARE @sourcepath VARCHAR(100)
DECLARE @destinationpath VARCHAR(1000)
SET @sourcepath = ' c:\sqldumps\jshah143.bak '
SET @destinationpath = '\\server2\backups\jshah143.bak'
 
SET @CMDSQL = 'c:copyfile.bat' + @sourcepath + @destinationpath
EXEC master..XP_CMDShell @CMDSQL

DOS Commands for DBA

As SQL Server DBA, there are many activities which needs the knowledge of DOS Commands. Please find the below useful DOS Commands.

ANSI.SYS – Defines functions that change display graphics, control cursor movement, and reassign keys.
APPEND – Causes MS-DOS to look in other directories when editing a file or running a command.
ARP – Displays, adds, and removes arp information from network devices.
ASSIGN – Assign a drive letter to an alternate letter.
ASSOC – View the file associations.
AT – Schedule a time to execute commands or programs.
ATMADM – Lists connections and addresses seen by Windows ATM call manager.
ATTRIB – Display and change file attributes.
BATCH – Recovery console command that executes a series of commands in a file.
BOOTCFG – Recovery console command that allows a user to view, modify, and rebuild the boot.ini
BREAK – Enable / disable CTRL + C feature.
CACLS – View and modify file ACL’s.
CALL – Calls a batch file from another batch file.
CD – Changes directories.
CHCP – Supplement the International keyboard and character set information.
CHDIR – Changes directories.
CHKDSK – Check the hard disk drive running FAT for errors.
CHKNTFS – Check the hard disk drive running NTFS for errors.
CHOICE – Specify a listing of multiple options within a batch file.
CLS – Clears the screen.
CMD – Opens the command interpreter.
COLOR – Easily change the foreground and background color of the MS-DOS window.
COMMAND – Opens the command interpreter.
COMP – Compares files.
COMPACT – Compresses and uncompress files.
CONTROL – Open control panel icons from the MS-DOS prompt.
CONVERT – Convert FAT to NTFS.
COPY – Copy one or more files to an alternate location.
CTTY – Change the computers input/output devices.
DATE – View or change the systems date.
DEBUG – Debug utility to create assembly programs to modify hardware settings.
DEFRAG – Re-arrange the hard disk drive to help with loading programs.
DEL – Deletes one or more files.
DELETE – Recovery console command that deletes a file.
DELTREE – Deletes one or more files and/or directories.
DIR – List the contents of one or more directory.
DISABLE – Recovery console command that disables Windows system services or drivers.
DISKCOMP – Compare a disk with another disk.
DISKCOPY – Copy the contents of one disk and place them on another disk.
DOSKEY – Command to view and execute commands that have been run in the past.
DOSSHELL – A GUI to help with early MS-DOS users.
DRIVPARM – Enables overwrite of original device drivers.
ECHO – Displays messages and enables and disables echo.
EDIT – View and edit files.
EDLIN – View and edit files.
EMM386 – Load extended Memory Manager.
ENABLE – Recovery console command to enable a disable service or driver.
ENDLOCAL – Stops the localization of the environment changes enabled by the setlocal command.
ERASE – Erase files from computer.
EXIT – Exit from the command interpreter.
EXPAND – Expand a Microsoft Windows file back to it’s original format.
EXTRACT – Extract files from the Microsoft Windows cabinets.
FASTHELP – Displays a listing of MS-DOS commands and information about them.
FC – Compare files.
FDISK – Utility used to create partitions on the hard disk drive.
FIND – Search for text within a file.
FINDSTR – Searches for a string of text within a file.
FIXBOOT – Writes a new boot sector.
FIXMBR – Writes a new boot record to a disk drive.
FORMAT – Command to erase and prepare a disk drive.
FTP – Command to connect and operate on a FTP server.
FTYPE – Displays or modifies file types used in file extension associations.
GOTO – Moves a batch file to a specific label or location.
GRAFTABL – Show extended characters in graphics mode.
HELP – Display a listing of commands and brief explanation.
IF – Allows for batch files to perform conditional processing.
IFSHLP.SYS – 32-bit file manager.
IPCONFIG – Network command to view network adapter settings and assigned values.
KEYB – Change layout of keyboard.
LABEL – Change the label of a disk drive.
LH – Load a device driver in to high memory.
LISTSVC – Recovery console command that displays the services and drivers.
LOADFIX – Load a program above the first 64k.
LOADHIGH – Load a device driver in to high memory.
LOCK – Lock the hard disk drive.
LOGON – Recovery console command to list installations and enable administrator login.
MAP – Displays the device name of a drive.
MD – Command to create a new directory.
MEM – Display memory on system.
MKDIR – Command to create a new directory.
MODE – Modify the port or display settings.
MORE – Display one page at a time.
MOVE – Move one or more files from one directory to another directory.
MSAV – Early Microsoft Virus scanner.
MSD – Diagnostics utility.
MSCDEX – Utility used to load and provide access to the CD-ROM.
NBTSTAT – Displays protocol statistics and current TCP/IP connections using
NET – Update, fix, or view the network or network settings
NETSH – Configure dynamic and static network information from MS-DOS.
NETSTAT – Display the TCP/IP network protocol statistics and information.
NLSFUNC – Load country specific information.
NSLOOKUP – Look up an IP address of a domain or host on a network.
PATH – View and modify the computers path location.
PATHPING – View and locate locations of network latency.
PAUSE – Command used in batch files to stop the processing of a command.
PING – Test / send information to another network computer or network device.
POPD – Changes to the directory or network path stored by the pushd command.
POWER – Conserve power with computer portables.
PRINT – Prints data to a printer port.
PROMPT – View and change the MS-DOS prompt.
PUSHD – Stores a directory or network path in memory so it can be returned to at any time.
QBASIC – Open the QBasic.
RD – Removes an empty directory.
REN – Renames a file or directory.
RENAME – Renames a file or directory.
RMDIR – Removes an empty directory.
ROUTE – View and configure windows network route tables.
RUNAS – Enables a user to execute a program on another computer.
SCANDISK – Run the scandisk utility.
SCANREG – Scan registry and recover registry from errors.
SET – Change one variable or string to another.
SETLOCAL – Enables local environments to be changed without affecting anything else.
SETVER – Change MS-DOS version to trick older MS-DOS programs.
SHARE – Installs support for file sharing and locking capabilities.
SHIFT – Changes the position of replaceable parameters in a batch program.
SHUTDOWN – Shutdown the computer from the MS-DOS prompt.
SMARTDRV – Create a disk cache in conventional memory or extended memory.
SORT – Sorts the input and displays the output to the screen.
START – Start a separate window in Windows from the MS-DOS prompt.
SUBST – Substitute a folder on your computer for another drive letter.
SWITCHES – Remove add functions from MS-DOS.
SYS – Transfer system files to disk drive.
TELNET – Telnet to another computer / device from the prompt.
TIME – View or modify the system time.
TITLE – Change the title of their MS-DOS window.
TRACERT – Visually view a network packets route across a network.
TREE – View a visual tree of the hard disk drive.
TYPE – Display the contents of a file.
UNDELETE – Undelete a file that has been deleted.
UNFORMAT – Unformat a hard disk drive.
UNLOCK – Unlock a disk drive.
VER – Display the version information.
VERIFY – Enables or disables the feature to determine if files have been written properly.
VOL – Displays the volume information about the designated drive.
XCOPY – Copy multiple files, directories, and/or drives from one location to another.