What does “%” (percent) do in PowerShell?

When used in the context of a cmdlet (such as your example), it’s an alias for ForEach-Object:

> Get-Alias -Definition ForEach-Object

CommandType     Name                                                Definition
-----------     ----                                                ----------
Alias           %                                                   ForEach-Object
Alias           foreach                                             ForEach-Object

When used in the context of an equation, it’s the modulus operator:

> 11 % 5

1

and as the modulus operator, % can also be used in an assignment operator (%=):

> $this = 11
> $this %= 5
> $this

1

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)