Functions/Data/Get-RoundMultiple.ps1
Function Get-RoundMultiple { [cmdletbinding()] Param ( # Input Number to Round [Parameter(Mandatory=$true,ValueFromPipeLine=$true)] $InputObject, # Integer to round [Parameter(Mandatory=$false)] [int] $Multiple = 1, # Directionality of round [Parameter(Mandatory=$false)] [ValidateSet("Nearest","Ceiling","Floor")] [string] $Direction = "Nearest" ) Process { # Switch on Directionality switch ($Direction) { "Nearest" {[Math]::Round($InputObject/$Multiple) * $Multiple} "Ceiling" {[Math]::Ceiling($InputObject/$Multiple) * $Multiple} "Floor" {[Math]::Floor($InputObject/$Multiple) * $Multiple} } } } |