0

I am new to WSUS, Powershell and AutoIt. I am writing a program to approve multiple updates just with a few clicks (instead of 5 clicks per update and Group). Therefore i have a Powershell-Script that searches for all the computer-Groups and available Updates.

The scripts themselves aher working, i just have Problems calling them in AutoIt (as i already found out, i have to import the module UpdateServices but i can´t get it working).

Here is one part of my AutoIt-Program:

$sComSend = '-ExecutionPolicy ByPass import-module UpdateServices; ' & $sScript & '\Search_Updates.ps1 -FilePath ' & $sUpdateOutput
ShellExecuteWait("powershell.exe", $sComSend)

But this doesn´t work. Another try was this:

$sComSend = 'powershell.exe import-module UpdateServices; "-ExecutionPolicy ByPass ' & $sScript & '\Search_Updates.ps1 -FilePath ' & $sUpdateOutput & '"'
RunWait(@ComSpec & " /c " & $sComSend, "", @SW_SHOW , $stdout_child)

But this also didn´t work. To be honest, in the second one, i don´t even know what the most of These Parameters exactly mean. Does anybody see my mistake?

Thanks :-)

Robert
  • 5,278
  • 43
  • 65
  • 115

1 Answers1

0

I suggest it to keep simple.

Create a new powershell file called "myStuff.ps1", and in there, put:

param([string]$FilePath)

Import-Module UpdateServices

Write-Host "FilePath = $FilePath"

after that is done, just invoke it:

$fileLocation = "C:\myAbsolutePath\myStuff.ps1"
$arguments = '-FilePath "C:\Testing one two three"'

$commandLine = '-WindowStyle Normal -NoExit -NoLogo -NoProfile -Command & "' & $fileLocation & '" ' & $arguments

Run($commandLine, @SystemDir, @SW_SHOW , $stdout_child)
Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78
  • Thanks! But this also does not work (hope it isn´t because i replaced Run by RunWait). I am not even sure if this what i want is possible –  Apr 23 '15 at 11:45