I am rather new, as in this my first script, to powershell so forgive me if this is a simple fix but I’ve written this:
`Write-Host "$(Get-Date) Changing buffer on virtual machines" -ForegroundColor Green
$GetVM = Get-VM -ComputerName localhost
Foreach ($vm in $GetVM)
{
$vm_name = $vm.Name
Write-Host "vm =" $vm_name
if ($(GET-VMMemory -vmname $vm_name | select DynamicMemoryEnabled) -eq $TRUE){
Write-Host "`n$vm_name is running with dynamic memory`n"
Write-Host "Changing buffer to 35% on $vm" -ForegroundColor White
Set-VMMemory $vm -Buffer 35
Write-Host "Changed buffer to 35% on $vm" -ForegroundColor White
}
else
{
Write-Host "`n$vm_name is NOT running with dynamic memory`n"
}
}
Write-Host "$(Get-Date) Buffer Change Completed" -ForegroundColor Green `
It should be pretty simple. It worked until I added the check to make sure the memory was dynamic but now it is always coming back false. I know that most of my machine are set up with dynamic memory so this shouldn’t be the case.
Anyone see what I am doing wrong?