Jump to content

Display output progress of a powershell script running


Recommended Posts

 

Currently I have a powershell kick off from a menu selection and it pops up with the blue PS screen and performs the work,  takes about 1 minute. I'm wondering if there is a way to make this look better?  Right now I have a pop up progress bar that  sits in front of it Progresson(). 

What I would like to do is not use the powershell screen and display the output of the powershell script as it goes along, OR use the blue screen if I have to but actually display what is going on. Thoughts?

Func PerformScan()

   ; **** PowerShell requirement ***
   ;RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Set-executionpolicy -scope LocalMachine -executionpolicy Unrestricted -Force", @SystemDir, @SW_HIDE, 2)

   Local $PSScript = "Scan.ps1"
   Local $PSSOptions = " -Site '"&$Site&"' "
   Local $sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command . '" & @ScriptDir & "\" & $PSScript & "' " & $PSSOptions

   ProgressOn("System Scan", "System Scan Running ..")
   $PID = Run($sCMD, @SystemDir, @SW_HIDE, 2) ; $STDOUT_CHILD

   $x = 0
   $Forward = 1

   While ProcessExists($PID)
      Sleep(200)
      If $Forward Then
         If $x < 100 Then
            $x = $x + 10
         Else
            $Forward = 0
         EndIf
      Else
         If $x > 0 Then
            $x = $x - 10
         Else
            $Forward = 1
         EndIf
      EndIf
      ProgressSet($x)
   WEnd
   ProgressOff()

EndFunc

 

Link to post
Share on other sites
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...