search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 4,495 views | 25/06/2013 08:40

If you need to sync OS name with VM name on Hyper-V, you can use KVP exchange feature:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$HyperVHost = "MyHyperV"
filter Import-CimXml
{
   $CimXml = [Xml]$_
   $CimObj = New-Object -TypeName System.Object
   foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY"))
   {
       $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
   }
   $CimObj
}
 
$VMs = Get-VM -ComputerName $HyperVHost
foreach ($VM in $VMs)
{
   $VMInfo = Get-WmiObject -ComputerName $HyperVHost -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='$VM'"
   $KVPData = Get-WmiObject -ComputerName $HyperVHost -Namespace root\virtualization -Query "Associators of {$VMInfo} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"
   $KVPExport = $KVPData.GuestIntrinsicExchangeItems
   $Hostname = ($KVPExport | where {$_.Name -eq "FullyQualifiedDomainName"}).Data
   $VM | Rename-VM -NewName $Hostname
}

Btw, I haven’t tested this script yet. But that should work :)


Posted in Windows Server | No Comment | 3,014 views | 24/06/2013 14:01

If you use HP 3PAR OS 3.1.1 MU2 (and only MU2) with Windows Server 2012, you need to run following command for both NTFS and REFS filesystem types. After that you will be able to do quick format on disk.

fsutil behavior set disabledeletenotify 1

When you finish your quick format on disk, then you can re-enable with following command:

fsutil behavior set disabledeletenotify 0

These steps are not required with later versions of HP 3PAR OS with Windows Server 2012.


Posted in Windows Powershell, Windows Server | No Comment | 1,904 views | 21/06/2013 16:55

You can search a VM name in your Hyper-V host list like this:

$VMName = "Server Name"
$Servers = Get-Content C:\servers.txt
foreach ($Server in $Servers)
{
	$VMs = Get-WMIObject -Class Msvm_ComputerSystem -Namespace "root\virtualization" -ComputerName $Server
	foreach ($VM in $VMs)
	{
		if ($VM.ElementName -eq $VMName)
		{
			Write-Host $Server
		}
	}
}

It uses WMI so both works on Windows Server 2008 and Windows Server 2012.


Posted in Windows Powershell, Windows Server | No Comment | 9,343 views | 21/06/2013 16:34

You may get this error when you try to open Failover Cluster Manager (Windows Server 2012):

Failover Cluster Manager failed while managing one or more cluster. The error was ‘An error occurred trying to display the cluster information.’. For more information see the Failover Cluster Manager Diagnostic channel.

Capture

You can fix this problem by this command via CMD:

1
2
cd C:\Windows\System32\wbem
mofcomp .\ClusWMI.mof

If you have SCCM agent on your server, then that might cause this error. Try to update your SCCM agent to latest version.


Posted in Windows Powershell | No Comment | 2,048 views | 21/06/2013 15:54

You can resolve ip addresses of many servers via Powershell.

1
2
3
4
5
6
7
8
9
10
11
12
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$IPAddress = $null
	$IPAddress = [System.Net.Dns]::GetHostAddresses("$Server").IPAddressToString
	Add-Content -Path C:\ServerName.txt -Value $Server
	if ($IPAddress -eq $null)
	{
		$IPAddress = "Server IP cannot resolve."
	}
	Add-Content -Path C:\ServerIP.txt -Value $IPAddress
}

It creates two different txt file, so you can merge them in an excel file.


Posted in Windows Powershell, Windows Server | 2 Comments | 2,253 views | 21/06/2013 09:49

You can check ip addresses of server names like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$IPAddress = [System.Net.Dns]::GetHostAddresses("$Server").IPAddressToString
	If ($IPAddress -like "172.29*")
	{
		Write-Host "Test Server"
		Add-Content -Path C:\testservers.txt -Value $Server
	}
	else
	{
		Write-Host "Prod Server"
		Add-Content -Path C:\prodservers.txt -Value $Server
	}
}

As you see, i split them into 2 different groups.


Posted in Windows Powershell, Windows Server | No Comment | 2,867 views | 19/06/2013 10:29

You can use this script to get virtual machines which has Virtual HBA support.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$Servers = Get-Content C:\hosts.txt
foreach ($Server in $Servers)
{
	$VMs = Get-VM -ComputerName $Server
	Write-Host $Server
	foreach ($VM in $VMs)
	{
		$TestFC = $VM | Select -expand FibreChannelHostBusAdapters
		if ($TestFC)
		{
			$Value = $VM.Name + "," + $VM.ComputerName
			Add-Content -Value $Value -Path C:\Servers.txt
		}
	}
}

I’ve added all my Hyper-V hostnames into C:\hosts.txt to use this script.