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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Server | No Comment | 1,963 views | 12/09/2015 17:19

You can send extra parameters to HTML.Partial with following example:

@{Html.RenderPartial("~/Views/Shared/GlobalScripts.cshtml", new ViewDataDictionary { { "timeRangeSessionValue", timeRangeSessionValue }, { "apiUrl", apiUrl } });}

You can get parameters with following:

@ViewData["apiUrl"]

You can populate parameters.


Posted in Windows Server | No Comment | 1,168 views | 02/08/2015 18:51

Just a reminder for myself :)

@(userRole == 0 ? "Yes" : "No")

Also you can use this like “else if”:

@(userRole == 0 ? "Yes" : userRole == 1 ? "Yes" : "No")

You can use this statement in div tags without problem.


Posted in Windows Server | No Comment | 2,680 views | 04/03/2015 10:36

If you want to see SQL Server Shrink status, you can use following query:

SELECT 
	percent_complete,
	total_elapsed_time,
	start_time,
	status,
	estimated_completion_time
FROM 
	sys.dm_exec_requests
WHERE
	command = 'DbccFilesCompact'

You can execute this query via SQL PowerShell cmdlet.

This is also a reminder for me :)


Posted in Windows Powershell, Windows Server | No Comment | 2,570 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.


Posted in Windows Powershell, Windows Server | No Comment | 2,171 views | 23/09/2014 04:25

This is an example script to show how you can monitor Supermicro servers via PowerShell:

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
55
56
57
58
59
60
61
# Test Supermicro CLI Path
$TestSupermicroCLIPath = Test-Path -Path "C:\Program Files\Supermicro\SuperDoctor5\sdc.bat"
 
if ($TestSupermicroCLIPath -eq $True)
{				
	# Test Supermicro CLI Output
	$SensorInfo = Invoke-Command -ScriptBlock {
		&'C:\Program Files\Supermicro\SuperDoctor5\sdc.bat' "-d"
	}
}
 
# Create Supermicro Sensors Function
function Get-SupermicroSensor
{
	param ($SensorSource)
 
	if ($SensorSource)
	{
		# Get Supermicro Sensors
		$SupermicroSensors = $SensorSource | Select-String "2.1.1.1.1.2."
 
		# Parse Supermicro Output
		foreach ($SupermicroSensor in $SupermicroSensors)
		{
			# Clear Values
			$SupermicroSensorCurrentReading = $Null;
			$SupermicroSensorHighLimit = $Null;
			$SupermicroSensorLowLimit = $Null;
			$SupermicroSensorMetric = $Null;
 
			# Get Sensor Information
			$SupermicroSensorValues = $SupermicroSensor.ToString().Split(",")
			$SupermicroSensorID = ($SupermicroSensorValues[0]).Split(".")[-1]
			$SupermicroSensorName = $SupermicroSensorValues[-1]
 
			# Get Sensor Results
			$SupermicroSensorCurrentReading = $SensorSource | Select-String "2.1.1.1.1.4.$SupermicroSensorID\b"
			$SupermicroSensorHighLimit = $SensorSource | Select-String "2.1.1.1.1.5.$SupermicroSensorID\b"
			$SupermicroSensorLowLimit = $SensorSource | Select-String "2.1.1.1.1.6.$SupermicroSensorID\b"
			$SupermicroSensorMetric = $SensorSource | Select-String "2.1.1.1.1.11.$SupermicroSensorID\b"
 
			# Parameter Validation
			if (!$SupermicroSensorCurrentReading) { [string]$SupermicroSensorCurrentReading = "Unknown" } else { [string]$SupermicroSensorCurrentReading = $SupermicroSensorCurrentReading.ToString().Split(",")[-1] }
			if (!$SupermicroSensorHighLimit) { [string]$SupermicroSensorHighLimit = "Unknown" } else { [string]$SupermicroSensorHighLimit = $SupermicroSensorHighLimit.ToString().Split(",")[-1] }
			if (!$SupermicroSensorLowLimit) { [string]$SupermicroSensorLowLimit = "Unknown" } else { [string]$SupermicroSensorLowLimit = $SupermicroSensorLowLimit.ToString().Split(",")[-1] }
			if (!$SupermicroSensorMetric) { [string]$SupermicroSensorMetric = "Unknown" } else { [string]$SupermicroSensorMetric = $SupermicroSensorMetric.ToString().Split(",")[-1] }
 
			$Properties = New-Object Psobject
			$Properties | Add-Member Noteproperty ID $SupermicroSensorID
			$Properties | Add-Member Noteproperty Name $SupermicroSensorName
			$Properties | Add-Member Noteproperty CurrentReading $SupermicroSensorCurrentReading
			$Properties | Add-Member Noteproperty Metric $SupermicroSensorMetric
			$Properties | Add-Member Noteproperty HighLimit $SupermicroSensorHighLimit
			$Properties | Add-Member Noteproperty LowLimit $SupermicroSensorLowLimit
			Write-Output $Properties
		}
	}
}
 
# Get Supermicro Sensor Results
$SupermicroSensorResults = Get-SupermicroSensor -SensorSource $SensorInfo

You need to install Super Doctor 5 on your Supermicro server before using this script.


Posted in Windows Powershell, Windows Server | No Comment | 6,647 views | 05/08/2014 14:28

You can get operating system report of your remote servers via PowerShell:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	try
	{
		$OS = Get-WmiObject -ComputerName $Server -Class Win32_OperatingSystem -EA Stop
		$OSName = $OS.Caption
		$SPV = $OS.CSDVersion
 
		$Value = $Server + ";" + $OSName + ";" + $SPV
		Write-Host $Value
	}
	catch
	{
		Write-Host $_
	}
}

That will give you OS Name and Service Pack version.


Posted in Windows Powershell, Windows Server | No Comment | 1,964 views | 31/07/2014 11:30

You can get host reports with following script:

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
$Servers = "Server01","Server02"
 
foreach ($Server in $Servers)
{
	# Get Local Disks
	$Disks = (Get-WmiObject -ComputerName $Server -Class Win32_LogicalDisk)
 
	# Clear Variables
	$TotalSize = 0;
	$TotalUsedSize = 0;
 
	foreach ($Disk in $Disks)
	{
		# Get Disk Space
		$Size = $Disk.Size
		$FreeSpace = $Disk.FreeSpace
 
		# Calculate Used Size
		[int64]$UsedSize = [int64]$Size - [int64]$FreeSpace
 
		# Calculate Total Size
		$TotalSize = $TotalSize + $Size;
		$TotalUsedSize = $TotalUsedSize + $UsedSize;
	}
 
	# Convert Total Size to MB
	[int64]$TotalUsedSize = [math]::round(($TotalUsedSize / 1MB), 0)
	[int64]$TotalSize = [math]::round(($TotalSize / 1MB), 0)
	[int64]$TotalFreeSpace = $TotalSize-$TotalUsedSize
 
	# Get OS and CPU Info
	$OSInformation = Get-WmiObject -ComputerName $Server -Class "Win32_OperatingSystem"
	$CPUInformation = (Get-WmiObject -ComputerName $Server -Class "Win32_Processor").Count
 
	# Calculate Memory
	$HostTotalMemory = ([math]::round(($OSInformation.TotalVisibleMemorySize / 1MB), 0)) * 1024
	$HostFreeMemory = ([math]::round(($OSInformation.FreePhysicalMemory / 1MB), 0)) * 1024
	$HostUsedMemory = $HostTotalMemory-$HostFreeMemory
 
	# Output Results
	$Value = $Server + ";" + $CPUInformation + ";" + $HostTotalMemory + ";" + $HostUsedMemory + ";" + $HostFreeMemory + ";" + $TotalSize + ";" + $TotalUsedSize + ";" + $TotalFreeSpace
	$Value
}

You can export all results to Excel to parse values.