Thursday, November 10, 2011

TCP/IP missing in the network adapter.

Problem Solution:
The problem was due to N/W entries of registry corruption.
1. Click Start, click Run, type regedit, and then click OK.
2. Locate and then delete the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\Config
3. If your server is a domain controller, go to step 5. (This includes servers that are running Windows Small Business Server 2003.) If your server is not a domain controller, delete the following registry subkeys:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters\ {GUID}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{GUID}
4. Click Start, click Run, type sysdm.cpl, and then click OK.
5. In the Systems Properties dialog box, click the Hardware tab, and then click Device Manager.
6. In Device Manager, expand Network adapters, right-click the network adapter that you want, and then click Uninstall.
7. Restart the computer.
8. Reassign the IP address and Restart the System.
Reference:
http://support.microsoft.com/kb/937056
http://forums.techarena.in/windows-server-help/20016.htm

Wednesday, October 12, 2011

SCVMM PowerShell scripts simplify administrative tasks

If you think Microsoft Hyper-V PowerShell cmdlets are comprehensive, System Center Virtual Machine Manager (SCVMM) PowerShell scripts offer even greater functionality and options for administrative tasks. These scripts can make a huge difference in the day to day of Hyper-V admins.

SCVMM PowerShell scripts can run on several virtualization platforms, including Hyper-V (R1 and R2), Virtual Server 2005 and VMware. Unlike with Hyper-V PowerShell scripts, which perform tasks directly on hosts, SCVMM acts more like a proxy that can translate PowerShell commands into executables for various hosts.



More on PowerShell in Hyper-V environments
How to use PowerShell or VBScript scripting with Hyper-V

Optimizing Hyper-V cluster performance among multiple sites



Because SCVMM PowerShell scripts are compatible with a broad array of systems, its scripting guide is very thorough. Here are some basic cmdlets and scripts that I use frequently.

Get-VM. Both Hyper-V and SCVMM feature the Get-VM cmdlet. But entering Get-VM from the SCVMM command prompt retrieves much more information.

The Get-VM cmdlet returns the attributes of every VM that's managed by SCVMM, which is usually too much information to digest. Here's how to obtain information about a single virtual machine( VM):



If you're interested in the VM's name and memory information, enter the following SCVMM PowerShell command:

Get-VM | ft name, memory
Get-VM is a versatile cmdlet that retrieves an enormous amount of information, but you can granularly search for information by attaching attributes to it. Insert "ft" (Format-Table) or "fl" (Format-List), for example, to customize the format of the results.

Set-VM. The Set-VM cmdlet allows administrators to bypass time-intensive graphical user interface (GUI) wizards and change VM settings from the command line. Below are my favorite Set-VM commands:
To set a VM's memory utilization, enter


Set-VM < SERVERNAME> -memory 2048


Helpful SCVMM PowerShell definitions
Cmdlets: These are the building blocks for commands. Cmdlets perform an action and provide a Microsoft .NET framework object to the next command. All cmdlets follow a verb, noun format (e.g., Get-VM, Get-Help).

Commands: The execution of one or more cmdlets, along with defining parameters that implement specific functions. For more information on SCVMM PowerShell cmdlets and commands, in addition to their differences, visit Microsoft's Cmdlet Overview page



To adjust a VM's CPU count, run this SCVMM PowerShell script:

Set-VM < SERVERNAME> -cpucount 2
The following command designates which users can access a VM through the SCVMM Self-Service Portal. The Self-Service Portal is a stripped-down version of the SCVMM Administration Console, which can grant privileges to users.


Set-VM -owner "DOMAIN\GROUPNAME or USERNAME"
The basic Get-VM and Set-VM cmdlets can simplify many administrative tasks. As you become more familiar with PowerShell, you can create powerful SCVMM scripts that are brief and simple.

Who are you?
Frequently, you'll have bits of information without an identifier for a VM's name. These obscure messages are usually found in the event log. Here are simple SCVMM PowerShell scripts to help identify mysterious VMs.

This script determines a VM's name from its MAC address (e.g., 00:03:ff:07:e7:dc):


Get-VirtualNetworkAdapter -all | where {$_.ethernetaddress -eq "< Insert VM MAC Address>"}
To acquire a VM name from its VM ID (e.g., 1CA3996C-C089-4896-A806-B396BC88F0BB), run this script:


Get-VM | where{$_.VMid -eq ""} | ft name
Unmerged snapshots
Forgotten snapshots and checkpoints can occupy valuable disk space. Often these snapshots were created before an application upgrade but then abandoned. I frequently run, the following script to delete and merge these snapshots before they create management and performance problems.

Here's how to find VMs with snapshots:


Get-VM | where {$_.LastRestoredVMCheckpoint -like "* *"} | ft name, LastRestoredVMCheckpoint, hostname

OR

$ll=Get-VM | where {$_.LastRestoredVMCheckpoint -like "* *"} | ft name, LastRestoredVMCheckpoint, hostname
out-file report.txt -inputobject $ll -encoding ASCII -width 160




Which VMs have an ISO image mounted?
I perform this housecleaning command on a regular basis. At times, though, it can also interfere with Quick or Live Migrations.

To find any ISO image that's attached to VMs, enter the following command:


Get-VM | get-virtualdvddrive |Where {$_.iso -like "*.iso"} | ft name, iso --a
Tip: The "-a" (autosize) component at the end of the command adjusts the column widths to prevent the output from truncating.

This command ejects any ISO image attached to VMs:


Get-VM | get-virtualdvddrive |? {$_.iso -like "*.iso"} | set-virtualdvddrive --nomedia
Tip: You can substitute a"?" for "Where."

Here's how to remove specific ISO images from VMs. This command comes in handy when the VM integration components ISO image does not dismount after its installation.


Get-VM | get-virtualdvddrive |? {$_.iso -like "vmg*"} | set-virtualdvddrive --nomedia
Pesky, misconfigured network adapters
When I'm in a rush, I sometimes mistakenly create emulated virtual network adapters instead of the higher-performing synthetic network adapters. This SCVMM PowerShell script identifies virtual network adapter types:


Get-VirtualNetworkAdapter -all | where {$_.virtualnetworkadaptertype -eq "emulated" -and $_.ethernetaddress -like "00:15*"} |ft name,VirtualNetworkAdapterType,ethernetaddress
SCVMM hardware profiles help prevent these administrative mistakes by enabling IT personnel to standardize the VM components throughout a virtual environment. You can apply these hardware profiles during the VM provisioning process with a PowerShell script or GUI wizard.

Clustered VMs
SCVMM PowerShell scripts can also perform any cluster function. This command migrates a VM from one cluster node to another:


Move-VM -VM -VMHost
To set the processor compatibility mode from PowerShell (the guest must be off), enter the following text:


Set-VM -LimitCPUForMigration $True
The beauty of SCVMM is that it's built on PowerShell. As a result, these SCVMM PowerShell scripts provide administrators with in-depth control over multiple virtualization platforms. Learning the PowerShell scripting language can be arduous, but you'll reduce administrative time as you become more familiar with SCVMM scripts.

Reference: http://searchservervirtualization.techtarget.com/tip/SCVMM-PowerShell-scripts-simplify-administrative-tasks

Monday, September 19, 2011

Collect Patch Information of Cluster Hosts for last 180 Days.

Requirement: You have n MS 2008 clusters having m hosts, you need to find out the patch status (Installation Date, Installed By) of all the hosts in last 180 days.

Solution:
A. Collect the list of all nodes (n*m) of the clusters.
1. Log on to any one of the cluster.
2. Create a file servername.txt, which contains the list of all clusters.
3. Open Powershell, and type PS C:\Import-Module Failover Cluster;
4. Create a ps1 file Clusternode.ps1 having the following code,
foreach ( $server in Get-Content .\servername.txt)
{
write "------------"
write $server
write "------------"
get-clusternode -cluster $server
}
5. Run the .\ClusterNode.ps1 | out-file clusternodestatus.txt
6. The file clusternodestatus.txt will contain the list of all the cluster nodes.

B. Run Powershell Script against all the nodes to get patch information.

1. Create a file servername.txt having list of all the cluster nodes.
2. Create a ps1 file PatchStatus.ps1 having the following code,
foreach ($Server in Get-Content .\servername.txt)
{
#write "-----------------------------------------------------------------"
write $Server
#get-hotfix -computer $Server
get-hotfix -computer $Server | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date).adddays(-180) }
}
3. Run .\PatchStatus.ps1 | out-file StatusReport.txt
4. The File StatusReport.txt will contain the patch information,
Sample Report:

Source Description HotFixID InstalledBy InstalledOn
------ ----------- -------- ----------- -----------
XXXX1 Security Update KB2446709 NT AUTHORITY\SYSTEM 4/22/2011 12:00:00 AM
XXXX2 Security Update KB2476490 NT AUTHORITY\SYSTEM 6/18/2011 12:00:00 AM
XXXX3 Security Update KB2478661 NT AUTHORITY\SYSTEM 6/18/2011 12:00:00 AM


Note: Some sample query.

List All installed patches:

PS C:>get-hotfix | select Description, Hotfixid

List all patches that are installed in last 30 days:

PS C:> get-hotfix | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date).adddays(-30) }

List all patches installed on specific date:

PS C:> get-hotfix | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date 10/31/2009) }

Query for a specific hotfix by providing hotfix ID(KB12345 format):

PS C:> get-hotfix | ? {$_.HotfixID -match ” KB975025″ }

List all hotfixes installed by administrator account:

PS C:> get-hotfix | ? {$_.InstalledBy -match “administrator” }

You can adopt the above queries and run against remote machine by passing the computer name shown like below.
PS C:> get-hotfix -Computer remotecomp | ? {$_.InstalledOn} | where { (Get-date($_.Installedon)) -gt (get-date).adddays(-30) }

Note: Install Powershell in Win2K8 core: Ref: http://techibee.com/powershell
Thanks and Regards,
Subhag Ghosh
You can contact me on subhag.ghosh@gmail.com

Monday, September 5, 2011

List HP Services on Multiple Machines

@echo off
for /f %%C in (ServerName.txt) do (
echo %%C
sc \\%%C query type= service state= all | find "hp" /I >> HpServices.txt
)

Wednesday, August 31, 2011

Check HP Entries from Device Manager for Multiple Machines

Create a batch file HPDEV.bat having content,

@echo off
for /f %%C in (ServerName.txt) do (
echo %%C>> HPResult.txt
devcon -m:\\%%C findall * | find /i "hp">> HPResult.txt
devcon -m:\\%%C findall * | find /i "Compaq">> HPResult.txt
devcon -m:\\%%C findall * | find /i "NC7">> HPResult.txt
devcon -m:\\%%C findall * | find /i "Smart">> HPResult.txt
devcon -m:\\%%C findall * | find /i "Proliant">> HPResult.txt
devcon -m:\\%%C hwids *floppy*>> HPResult.txt
)

ServerName.txt contains the list of servers.

Wednesday, August 3, 2011

Stop and Disable HP Services

net stop "Windows Time"
net stop "HP Insight Foundation Agents"
net stop "HP Insight NIC Agent"
net stop "HP Insight Server Agents"
net stop "HP Insight Storage Agents"
net stop "HP Insight Event Notifier"
net stop "HP ProLiant Remote Monitor Service"
net stop "HP ProLiant System Shutdown Service"


sc config W32Time start= disabled
sc config CIMNotify start= disabled
sc config CqMgHost start= disabled
sc config CpqNicMgmt start= disabled
sc config CqMgServ start= disabled
sc config CqMgStor start= disabled
sc config CpqRcmc start= disabled
sc config sysdown start= disabled

Create User Account and Add migration account to administrators group

Create a file ServerName.txt which should contains list of all the server.
#Create User Account and Add migration account to administrators group
for /f %C in (ServerName.txt) do psexec \\%C net user /ADD
for /f %C in (ServerName.txt) do psexec \\%C net localgroup administrators /ADD


#ADD WINS
for /f %C in (ServerName.txt) do psexec \\%C netsh interface ip add wins "Local Area Connection" "X.X.X.X"
for /f %C in (ServerName.txt) do psexec \\%C netsh interface ip add wins "Local Area Connection" "Y.Y.Y.Y" index=2

#STOP and Disabled Windows Time Service

for /f %C in (ServerName.txt) do psexec \\%C net stop "Windows Time"
for /f %C in (ServerName.txt) do psexec \\%C sc config W32Time start= disabled

# Collect IPCONFIG and WINMSD
for /f %C in (ServerName.txt) do psexec \\%C ipconfig /all >>E:\SUBHAG\WINMSD\28JULY2011\%C_ipconfig.txt
for /f %C in (ServerName.txt) do msinfo32 /computer %C /report E:\SUBHAG\WINMSD\28JULY2011\%C_WINMSD.txt

Thanks and Regards,
Subhag Ghosh

How to check windows system uptime?

1. Open cmd, systeminfo,

System Boot Time: 7/22/2011, 10:09:23 AM

2. Check for the following system events in eventvwr,

a) Event ID: 1074 for Shutdown Event

b) Event ID: 6013 for uptime

c) Event ID: 6005 , for system start time

d) Event ID: 6006, for system stop time

Thanks and Regards,
Subhag Ghosh

Tuesday, August 2, 2011

How to find status of HP related services from a Server List

1. Create a file ServerList.txt contaning server names.

2. Create a batch file name scq.bat with the follwing content,

@echo off
for /f %%C in (ServerName.txt) do (
echo %%C
sc \\%%C query type= service state= all | find "hp" /I
)

3. Open Command Prompt, type SCQ.bat > HPServiceStatus.txt

4. The file HPServiceStatus.txt will contain the list of HP services.

Sample O/P:

ServerName
DISPLAY_NAME: HP Insight Event Notifier
DISPLAY_NAME: HP Insight NIC Agents
DISPLAY_NAME: HP Version Control Agent
DISPLAY_NAME: HP Insight Foundation Agents
DISPLAY_NAME: HP Insight Server Agents
DISPLAY_NAME: HP Insight Storage Agents
DISPLAY_NAME: HP ServiceEmulation

Thanks and Regards,
Subhag Ghosh