0

In an attempt to improve my PowerShell and VB.NET coding and scripting skills I decided to build a sort of control interface that would control the sound of a system, shut down a system, turn off the network adapters and the like. And for the weirdest reason I'm having trouble with the sound.

I've been attempting a few things, mostly using the SendKeys method.

Specifically, the code is:

Invoke-Command -ComputerName computerName -Credential $creds -ScriptBlock {
  $ob = New-Object -ComObject wscript.shell | {1..50 | % { $ob.SendKeys([char]174)}}
}

I also tried:

Invoke-Command -ComputerName computerName -Credential $creds -ScriptBlock {
  $ob = New-Object -ComObject wscript.shell | $ob.SendKeys([char]173)
}

I found these after searching through Google for some time, and unfortunately I can only get these commands to work on my local Windows 8 base machine, while the remote computer I am testing with is Windows 7. I realize that the difference in operating systems will change the encoding for the sent keys required but I can't find anything different than this and was hoping someone much smarter than me could help.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Prog
  • 33
  • 1
  • 5
  • Your session does not have access to everything. I don't have the best explanation but a parallel to draw would be like starting notepad and expecting to see it on the screen. It is open but not using the logged on user session. The sound might have played but no one is there to hear it. – Matt May 28 '15 at 03:49
  • Alright, that seems to make sense @matt. – Prog May 28 '15 at 03:55
  • Do you have any suggestions on how to accomplish controlling the sound from a remote computer with powershell? – Prog May 28 '15 at 03:56
  • There has been no small amount of effort put into Windows security systems to prevent hackers and malware mongers from remotely interacting with the interactive user session. If the objective is simply to improve your coding skills you would probably do better to choose a project that doesn't require you to have to circumvent those systems. – mjolinor May 28 '15 at 11:05

0 Answers0