Unless you have PSremoting enabled, and you are the local admin on the remote host. You cannot do this.
You also must use implicit / explicit remoting to run this type of commands.
You also, must understand how to use local variables in remote session, if you plan to use them.
If these remote host are in domain joined, you have to manually setup PSRemoting in workgroup mode.
All this is documented on TechNet and all over the web.
Just do a search for:
PSRemoting powershell
PSRemoting workgroup
PSRemoting local variables
PSRemoting permissions
Function Set-Speaker($Volume){$wshShell=new-object -com wscript.shell;1..50|%{$wshShell.SendKeys([char]174)};
1..$Volume|%{$wshShell.SendKeys([char]175)}}