For querying all the data from table MachineName we can use the command like below one.
$Query="Select * from MachineName"
$Inst="ServerInstance"
$DbName="DatabaseName
$UID="User ID"
$Password="Password"
Invoke-Sqlcmd2 -Serverinstance $Inst -Database $DBName -query $Query -Username $UID -Password $Password