Sunday, January 10, 2010

Running Scripts in Remote Sytems

As a System Administrator we would want to run some simple scripts in multiple computers. Microsoft has some great tools to ease the job, PsTools is really powerful easy tool.

PsTools is a bundle, we are look at PsExec. Which can be used to run scripts on remote computers.

Below is a simple example to find uptime of multiple systems and dumping to a file.

- Enter the system names in a notepad and save as a batch file (eg. mc.bat)
- Have a script written and save it as a batch file. (eg. uptime.bat "systeminfo | find "Up Time")
- This script will write the uptime of the systems on the command prompt
- Now use the tool to run it. Ensure you are in the directory where the tool is. Also ensure admin share is enabled in the remote systems.
psexec @mc.bat -u "username" -p "password" /c "path to script"
- This will execute the script in the remote systems mentioned in the mc.bat file.

Just makes our task easier. We can lots with this. Have it downloaded and explored in the below link,
http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

Enjoy Scripting!

Saturday, December 19, 2009

XP - Useful RUN commands


If you are a Windows XP user and love to work with the keyboard fast, below shortcuts would help,

















































































VMware ESX 3.x - Changing Queue depth

We could change the Queue depth in the ESX server which would help if we have high IO intensive VM running. You could set the Queue depth upto 255, i guess 64 should be a good value to be configured. Below are the steps,

- Login to service console as root.
- Verify which QLogic HBA module is currently loaded: vmkload_mod -l | grep qla2300
- Depending on the model of the HBA, the module can be one of the following: qla2300_707 (ESX Server 3.0.x) qla2300_707_vmw (ESX Server 3.5)
- Run the following commands. The example shows the qla2300_707 module. Use the appropriate module based on the outcome of Step 2.
                     a) esxcfg-module -s ql2xmaxqdepth=64 qla2300_707
                     b) esxcfg-boot –b .
- Reboot.
- To verify the current qlogic queue depth -grep -i qla /etc/vmware/esx.conf. you will find the Queue depth set.

Windows XP - Concurrent RDP sessions

We could make XP to allow concurrent RDP sessions, below are the steps

- Replace the termsrv.dll in the following paths %windir%/system32/dllcache & %windir%/system32 with the dll found in the below link. Link also explains the steps in detail,
http://alonbilu.wordpress.com/2008/05/17/enabling-multiple-concurrent-remote-sessions-on-windows-xp-sp3-patched-file-included/

- Change the registry settings as below,
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\Licensing Core]
"EnableConcurrentSessions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"EnableConcurrentSessions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AllowMultipleTSSessions"=dword:00000001
 
- You can set the number of connections, go to gpedit.msc > computer configuration > windows components > Terminal services > limit muber of connections (set to the number you want).
 
- If you are using RDP, ensure you do all these in safe mode.
 
- Restart the system.

VI tool kit - Changing Shares and limit

VI toolkit is a powerful tool. Guess we could do all kind of stuff in VI using it. Below is a simple script which would change the resource settings (ie. shares to normal & limit to unlimited).

clear
#Connect-VIServer localhost
$vm = Get-Cluster "clustername" | get-vm | Get-View
$res = New-Object vmware.Vim.virtualmachineconfigspec
$res.CpuAllocation = New-Object vmware.Vim.ResourceAllocationInfo
$res.CpuAllocation.Shares = New-Object vmware.Vim.SharesInfo
$res.CpuAllocation.Shares.Level = "normal"
$res.CpuAllocation.Limit = "-1"
$res.MemoryAllocation = New-Object vmware.Vim.ResourceAllocationInfo
$res.MemoryAllocation.Shares = New-Object vmware.Vim.SharesInfo
$res.MemoryAllocation.Shares.Level = "normal"
$res.MemoryAllocation.Limit = "-1"
foreach ($v in $vm)
{
$v.reconfigvm_task($res)
}

Thursday, December 3, 2009

Getting Performance report of VM's from VC - VIToolkit

Below is the script to collect the performance report of the VM's mentioned in the specific folder. It uses VI tool kit, exports the average value to excel and sends a mail.

clear
$excel = new-object -comobject excel.application
$excel.visible = $false
$workbook = $excel.workbooks.add()
$sheet = $workbook.WorkSheets.Item(1)
$sheet.cells.item(1,1) = "Hostname"
$sheet.cells.item(1,2) = "CPU AVG"
$sheet.cells.item(1,3) = "MEM AVG"
$sheet.cells.item(1,4) = "Disk AVG"
$sheet.cells.item(1,5) = "NW AVG"
$x = 2
$strpath = "c:\perf.xls"
Connect-VIServer -server
$start = "MM/DD/YY 00:01"
$finish = "MM/DD/YY 23:59"
$vm = Get-VM -Location (Get-Folder "folder")
foreach($v in $vm)
{
$cpuavg = get-stat -Entity $v -Start $start -Finish $finish -Stat cpu.usage.average | `
Measure-Object -Property value -Average
$memavg = get-stat -Entity $v -Start $start -Finish $finish -Stat mem.usage.average |`
Measure-Object -Property value -Average
$diskavg = get-stat -Entity $v -Start $start -Finish $finish -Stat disk.usage.average |`
Measure-Object -Property value -Average
$netavg = get-stat -Entity $v -Start $start -Finish $finish -Stat net.usage.average |`
Measure-Object -Property value -Average
$sheet.cells.item($x,1) = $v.name
$sheet.cells.item($x,2) = $cpuavg.average
$sheet.cells.item($x,3) = $memavg.average
$sheet.cells.item($x,4) = $diskavg.average
$sheet.cells.item($x,5) = $netavg.average
$x++
}
$range = $sheet.usedRange
$range.EntireColumn.AutoFit()
out-null
IF(Test-Path $strPath)
{
Remove-Item $strPath
$Excel.ActiveWorkbook.SaveAs($strPath)
}
ELSE
{
$Excel.ActiveWorkbook.SaveAs($strPath)
}
$excel.quit()
spps -name excel
$filename = “c:\perf.xls”
$smtpServer = “SMTP server”
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filename)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = “mail@domain.com”
$msg.To.Add(”mail@domain.com”)
$msg.Subject = “”
$msg.Body = “”
$msg.Attachments.Add($att)
$smtp.Send($msg)

VMware View 4 - PCoIP

-VMware are trying to move forward in Desktop virtulization . They have tied up with Teradici and have introduced a protocol PCoIP, claiming better performance for VD over WAN & LAN.

- PCoIP uses UDP datagrams and it builds the images progressively in slow WAN.

- Below are the links which would be useful in learning more about it,

http://blogs.vmware.com/view-point/2009/10/why-pcoip-is-the-best-protocol-for-virtual-desktops.html
http://www.teradici.com/pcoip/pcoip-technology/pcoip-faqs.php
http://www.vmware.com/files/pdf/VMware-View4-PCoIP-IG-EN.pdf