PoshHosts is a Cross-Platform module that allows you to control the hosts file from the Command Line.
Installation will install the module for PowerShell, and PowerShell Core (if it is installed).