header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Background job - run a ps1 script with a parameter
Last Post 09 Nov 2009 08:58 AM by Shay Levy. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
piotrp04User is Offline
New Member
New Member
Posts:1
Avatar

--
09 Nov 2009 08:44 AM
    Hi,

    how can I start a background job that will run a ps1 script with a parameter?
    does the -filepath option of start-job expect only the script file path, or can I add parameters at the end as well?

    My scenario is to get exchange mailbox details (and store in SQL) for each exchange server in parallel. So obviously want to run my ps1 script that does it, with a paramter which server to export mailboxes from.

    Piotr
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    09 Nov 2009 08:58 AM
    Use the -ArgumentList parameter to pass values:

    Start-Job -Name TestJob -FilePath testScript.ps1 -ArgumentList foo,foo1 | Wait-Job | Receive-Job

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer