Posted in
Windows Powershell,
Windows Server |
2 Comments | 2,172 views | 13/02/2014 10:51
You can get memory usage of Hyper-V clusters 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
| $Clusters = Get-Content Clusters.txt
foreach ($Cluster in $Clusters)
{
[int]$TotalFreeMemory = 0;
[int]$TotalMemory = 0;
[int]$NodeCount = 0;
$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
foreach ($ClusterNode in $ClusterNodes)
{
[int]$FreeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).FreePhysicalMemory / 1MB), 0)
[int]$TotalFreeMemory = [int]$TotalFreeMemory + [int]$FreeMemory
[int]$NodeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).TotalVisibleMemorySize / 1MB), 0)
[int]$TotalMemory = [int]$TotalMemory + [int]$NodeMemory
[int]$NodeCount = [int]$NodeCount + 1
}
[int]$TotalAvailableMemory = [int]$TotalFreeMemory - [int]$NodeMemory
Write-Host "Cluster: $Cluster"
Write-Host "Total Memory: $TotalMemory"
Write-Host "Total Free Memory: $TotalFreeMemory"
Write-Host "Total Available Memory: $TotalAvailableMemory"
Write-Host "Node Count: $NodeCount"
Write-Host " "
$Value = $Cluster + ";" + $TotalMemory + ";" + $TotalFreeMemory + ";" + $TotalAvailableMemory + ";" + $NodeCount + ";" + $NodeMemory
Add-Content -Value $Value -Path Memory.txt
} |
$Clusters = Get-Content Clusters.txt
foreach ($Cluster in $Clusters)
{
[int]$TotalFreeMemory = 0;
[int]$TotalMemory = 0;
[int]$NodeCount = 0;
$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
foreach ($ClusterNode in $ClusterNodes)
{
[int]$FreeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).FreePhysicalMemory / 1MB), 0)
[int]$TotalFreeMemory = [int]$TotalFreeMemory + [int]$FreeMemory
[int]$NodeMemory = [math]::round(((Get-WmiObject -ComputerName $ClusterNode -Class Win32_OperatingSystem).TotalVisibleMemorySize / 1MB), 0)
[int]$TotalMemory = [int]$TotalMemory + [int]$NodeMemory
[int]$NodeCount = [int]$NodeCount + 1
}
[int]$TotalAvailableMemory = [int]$TotalFreeMemory - [int]$NodeMemory
Write-Host "Cluster: $Cluster"
Write-Host "Total Memory: $TotalMemory"
Write-Host "Total Free Memory: $TotalFreeMemory"
Write-Host "Total Available Memory: $TotalAvailableMemory"
Write-Host "Node Count: $NodeCount"
Write-Host " "
$Value = $Cluster + ";" + $TotalMemory + ";" + $TotalFreeMemory + ";" + $TotalAvailableMemory + ";" + $NodeCount + ";" + $NodeMemory
Add-Content -Value $Value -Path Memory.txt
}
You will see detailed memory usage information of your Hyper-V clusters.
Posted in
Virtual Machine Manager,
Windows Powershell |
No Comment | 6,692 views | 04/02/2014 14:16
You can use following script to set domain join user credentials to SCVMM 2012/R2 templates.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # Get Templates
$Templates = Get-SCVMTemplate
# Set Domain
$Domain = "domain.domain.com"
# Get Credentials
$DomainJoinCredential = Get-Credential
# Set Templates
foreach ($Template in $Templates)
{
$Template | Set-SCVMTemplate -Domain $Domain -DomainJoinCredential $DomainJoinCredential
} |
# Get Templates
$Templates = Get-SCVMTemplate
# Set Domain
$Domain = "domain.domain.com"
# Get Credentials
$DomainJoinCredential = Get-Credential
# Set Templates
foreach ($Template in $Templates)
{
$Template | Set-SCVMTemplate -Domain $Domain -DomainJoinCredential $DomainJoinCredential
}
You should change domain name as your current domain name.