$i
and $web
aren't special variables. They are just popular names that people reuse. The name of the current object in a foreach
-loop is defined by you.
Ex:
#Creating a simple array for the demonstration
$MyArrayOfAwesomeObjects = 1,2,3
foreach ($ThisVariableIsAwesome in $MyArrayOfAwesomeObjects) {
#Here, $ThisVariableIsAwesome is the current object, and we can call methods on it.
$ThisVariableIsAwesome.GetType()
}
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
As for %
-> Foreach-Object
, that is just an alias. You can view all aliases with Get-Alias