PowerTip: Return remainder after dividing two numbers

Summary: Use Windows PowerShell to return the remainder after dividing two numbers.

Hey, Scripting Guy! Question How can use Windows PowerShell to divide two numbers and only return the remainder (called a modulo operation)?

Hey, Scripting Guy! Answer In Windows PowerShell, the modulo operator is the % sign. Here are a few examples of how to use it:

PS C:\> 3 % 2


PS C:\> 5 % 2


PS C:\> 11 % 2


Comments (0)

Skip to main content