Powershell and the Left Hand Side
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
A new article, to talk about an important notion in Powershell, the Left Hand Side (LHS) notion.
When using operators in Powershell, the type of the object to the left of the operator (LHS) defines the type of the object to the right (RHS: Right Hand Side).
Only elements of the same type can be compared, added, multiplied, etc.
If the type is different between LHS and RHS then Powershell tries to convert the RHS object to the same type as the LHS object, if it can’t, it throws an exception
The expected result is 9 is smaller than 10 but the result is 9 is equal to or greater than 10.
If we check the type of variables
In the previous example, Powershell converts 10 into a string and compares 9 to 1, and 9 is much greater than 1.
Another example with the multiplication operator, an integer and a string
One last example with the multiplication operator, an array and a string where the result will be different depending on the element in LHS
This is also why comparisons with $null must be placed on the left. To find out more about using $null, you can read Kevin Marquette’s (https://powershellexplained.com) article published on the Microsoft site.
https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-null#checking-for-null
Related links
Powershell - View and manage DNS configuration of network interfaces
Powershell commands to display and manage DNS configuration of network interfacesPowershell - Managing IP configuration of network interfaces
Powershell commands to view and modify the IP configuration of network interfacesPowershell - Managing the status and configuration of network interfaces
Powershell commands to view and modify the status and configuration of network interfaces (disable IPv6, enable/disable an interface)Powershell and the Left Hand Side
An important concept in Powershell, the Left Hand SidePowershell - Managing disks, partitions and volumes
How to manage disks, partitions and volumes in PowershellPowershell - Managing System Restore Points in Windows
How to manage system restore points in Windows
Follow me on
Support me
Last content
Powershell - View and manage DNS configuration of network interfaces
Powershell - Managing IP configuration of network interfaces
Powershell - Managing the status and configuration of network interfaces
Powershell and the Left Hand Side
Powershell - Managing disks, partitions and volumes
Powershell - Managing System Restore Points in Windows
Powershell - Playing with the Windows clipboard
Powershell - Changing the state of a computer (sleep, hibernate, shutdown, restart)
Powershell - Compress-Archive and Expand-Archive to create and extract ZIP archives