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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 1,247 views | 31/10/2014 17:39

If you create a secure password on PowerShell and output it into a txt file, you can decrypt it on another Windows machine. So we use a predefined user key to create our secure passwords:

There was a question about this post. So how you can create your own key?

So what you need to do is:

1
2
3
4
$SecureKey = New-Object byte[](16)
$RNGCryptoServiceProvider = [System.Security.Cryptography.RNGCryptoServiceProvider]::Create()
$RNGCryptoServiceProvider.GetBytes($SecureKey)
$SecureKey

That will create a random key for you. So you can replace it with predefined key.


Posted in Windows Powershell, Windows Server | No Comment | 1,829 views | 05/10/2014 15:21

You can use following script to get passthrough disk reports from Hyper-V Clusters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Get Clusters
$Clusters = Get-Content Clusters.txt
 
foreach ($Cluster in $Clusters)
{
	# Get Cluster Nodes
	$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
 
	foreach ($ClusterNode in $ClusterNodes)
	{
		Write-Host Working on $ClusterNode
 
		# Clear PT Values
		$PTDisks = $Null;
		$DiskNumber = $Null;
 
		# Get Passthrough Disks
		$PTDisks = Get-VM -ComputerName $ClusterNode | Get-VMHardDiskDrive | Where Path -like Disk*
 
		foreach ($PTDisk in $PTDisks)
		{
			# Get VM Name
			$VMName = $PTDisk.VMName
 
			Write-Host Working on $VMName
 
			# Get Passthrough Disk Info
			$PTInfo = $PTDisk.Path
			$DiskNumber = $PTDisk.DiskNumber
			$ControllerNumber = $PTDisk.ControllerNumber
			$ControllerLocation = $PTDisk.ControllerLocation
			$ControllerType = $PTDisk.ControllerType
			Write-Host Working on Disk $DiskNumber
 
			if (!$DiskNumber)
			{
				$DiskNumber = $PTInfo.Split(" ")[1]
			}
 
			# Get Disk Info
			$DiskInfo = Get-WmiObject Win32_DiskDrive -ComputerName $ClusterNode | Where Index -eq $DiskNumber
			$Model = $DiskInfo.Model
			$Caption = $DiskInfo.Caption
			$Signature = $DiskInfo.Signature
			$Size = [math]::round($DiskInfo.Size / 1GB,0)
 
			# Set Output
			$Value = $VMName + ";" + $ClusterNode + ";" + $ControllerType + ";" + $ControllerNumber + ";" + $ControllerLocation + ";" + $DiskNumber + ";" + $Model + ";" + $Signature + ";" + $Size
 
			# Informational Output
			Add-Content -Value $Value -Path Output.txt
		}
	}
}

You need to add your clusters into Clusters.txt file.