-3

I wish to run a 'IE Rest Script' to a node present in the same network.

The Script is present in the MachineA and it should be executed in the MachineB which is present in the same network.

Script:

add-type -AssemblyName System.Windows.Forms
add-type -AssemblyName microsoft.visualbasic

RunDll32.exe InetCpl.cpl,ResetIEtoDefaults

[Microsoft.VisualBasic.Interaction]::AppActivate("rundll32")
[System.Windows.Forms.SendKeys]::SendWait("{tab}")
[System.Windows.Forms.SendKeys]::SendWait(" ")
[System.Windows.Forms.SendKeys]::SendWait("r")
[System.Windows.Forms.SendKeys]::SendWait("c")

taskkill.exe /f /im iexplore.exe`
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40

1 Answers1

2

Sure it is:

Invoke-Command -ComputerName myremotehost.mydomain.tld -ScriptBlock {
    # This code here runs on the remote system
}

You have to make sure, that PowerShell Remoting is activated on the target system.

TobyU
  • 3,718
  • 2
  • 21
  • 32
  • Will this code work for the above Script? But on execution of the above script it will Internet Explorer Reset pop up on the running machine (local host) but its not working on the Remote machines. – parthivijay Jul 19 '18 at 12:52
  • If the necessary assemblies are installed/present on the remote system: yes – TobyU Jul 19 '18 at 12:54
  • Yep the assembly are available on the remote system. And if the same script work executed on that targeted system its working fine – parthivijay Jul 19 '18 at 13:40
  • Then what is keeping you from just trying it out? – TobyU Jul 19 '18 at 13:43
  • But when i trigger the same script from the machine A to machine B it is not executing and the IE is not reseted. – parthivijay Jul 19 '18 at 13:51