VeeamÂ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.
Function Read-Integer([string]$Prompt) {
Do {
$InputOK = $False
$Input = Read-Host -Prompt $Prompt
$Input = $Input.Trim()
If ([string]::IsNullOrEmpty($Input)) {
Write-Host "Empty input is not allowed!" -ForegroundColor Red
Continue
}
$Integer = 0
If (-Not [uint64]::TryParse($Input, [ref]$Integer)) {
Write-Host "Input '$($Input)' is not a positive integer!" -ForegroundColor Red
Continue
}
If ($Integer -eq 0) {
Write-Host "Input '0' is not allowed!" -ForegroundColor Red
Continue
}
$InputOK = $True
} Until ($InputOK)
Return $Integer
}
$VMhost = HostSystem-host-8
$disks = Get-Datastore -VMHost (Get-VMHost -Id $VMHost)
$capacity = $disks.capacityMB
$freespace = $disks.FreeSpaceMB
if ($freespace -le ($capacity *0.15)) { # less than 15% available) }; else { #more than 15% available }
cls
Write-Host "*******************************************************************************"
Write-Host -ForegroundColor Green "CALCULATOR to calculate FREE SPACE PERCENTAGE after reclaiming storage space"
Write-Host "*******************************************************************************"
Write-Host ""
function CalcPercent {
param(
[parameter(Mandatory = $true)]
[int]$InputNum1,
[parameter(Mandatory = $true)]
[int]$InputNum2)
$InputNum1 / $InputNum2*100
}
$CapacityMB = Read-Host -Prompt 'Input Datastore CAPACITY in MB '
$A = [Math]::Round($CapacityMB)
$CurrentFreeSpaceMB = Read-Host -Prompt 'Input Datastore CURRENT FREE SPACE in MB '
$B = [Math]::Round($CurrentFreeSpaceMB)
$SpaceToReclaimMB = Read-Host -Prompt 'Input Space that you want to RECLAIM in MB '
$C = [Math]::Round($SpaceToReclaimMB)
$FreeSpaceMB = [float]$B-$C
$D = [Math]::Round($FreeSpaceMB)
$PercentFree = CalcPercent $D $A
$PercentFree = "{0:N2}" -f $PercentFree
$E = [Math]::Round($PercentFree)
Write-Host ""
Write-Host -ForegroundColor Yellow "Datastore Free Space will be $PercentFree % after reclaiming $SpaceToReclaimMB MB storage"
if ($E -lt 15)
{
Write-Host -BackgroundColor Red "Free space is less than 15%. You have to add additional storage before you reclaim $SpaceToReclaimMB MB."
}
else
{
Write-Host -ForegroundColor Green "YOU CAN GO AHEAD WITH RECLAIMING $SpaceToReclaimMB MB OF SPACE."
}
cls
Write-Host "*******************************************************************************"
Write-Host "CALCULATOR to calculate FREE SPACE PERCENTAGE after reclaiming storage space" -ForegroundColor Green
Write-Host "*******************************************************************************"
Write-Host ""
Function ConvertTo-Percent {
Param(
[parameter(Mandatory = $true)][Alias('Numerator')]
[int]$Antecedent,
[parameter(Mandatory = $true)][Alias('Denominator')]
[int]$Consequent,
[int]$DecimalPlaces = 0
)
Return [math]::Round((100 * $Antecedent) / $Consequent, $DecimalPlaces)
}
Function Read-Integer([string]$Prompt) {
Do {
$InputOK = $False
$Input = Read-Host -Prompt $Prompt
$Input = $Input.Trim()
If ([string]::IsNullOrEmpty($Input)) {
Write-Host "Empty input is not allowed!" -ForegroundColor Red
Continue
}
$Integer = 0
If (-Not [uint64]::TryParse($Input, [ref]$Integer)) {
Write-Host "Input '$($Input)' is not a positive integer!" -ForegroundColor Red
Continue
}
If ($Integer -eq 0) {
Write-Host "Input '0' is not allowed!" -ForegroundColor Red
Continue
}
$InputOK = $True
} Until ($InputOK)
Return $Integer
}
$CapacityMB = Read-Integer -Prompt 'Input Datastore CAPACITY in MB (no decimal places) '
$CurrentFreeSpaceMB = Read-Integer -Prompt 'Input Datastore CURRENT FREE SPACE in MB (no decimal places) '
$SpaceToReclaimMB = Read-Integer -Prompt 'Input Space that you want to RECLAIM in MB (no decimal places) '
$FreeSpaceMB = $CurrentFreeSpaceMB - $SpaceToReclaimMB
$PercentFree = ConvertTo-Percent $FreeSpaceMB $CapacityMB -DecimalPlaces 2
Write-Host ""
Write-Host -ForegroundColor Yellow "Datastore Free Space will be $PercentFree % after reclaiming $SpaceToReclaimMB MB storage"
if ($PercentFree -lt 15)
{
Write-Host -BackgroundColor Red "Free space is less than 15%. You have to add additional storage before you reclaim $SpaceToReclaimMB MB."
}
else
{
Write-Host -ForegroundColor Green "YOU CAN GO AHEAD WITH RECLAIMING $SpaceToReclaimMB MB OF SPACE."
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.