Powershell script inside powershell script

Ask and answer questions related to any type of OSA scripting.
Post Reply
Message
Author
amz4u2nv
Posts: 115
Joined: Mon Sep 03, 2012 3:12 am

Powershell script inside powershell script

#1 Post by amz4u2nv » Wed Oct 23, 2013 7:22 am

Hi,
I want to call a powershell script from another powershell script.

Add To Shop

$shop_var = get-osa -name "Shopping List"
$shopValue = $shop_var.properties["Value"].value

set-osa -name "Shopping List" -property "Value" -value "$shopValue PARAMETERINPUT"

Add Bread
invoke-osascript -name "Add To Shop" -parameter2 "Bread"

But how do i get the parameter inside Add to Shop script?

Cheers

fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Re: Powershell script inside powershell script

#2 Post by fiveHellions » Wed Oct 23, 2013 9:36 am

there is a -nested parameter when calling another powershell script which will run the second script in the same process so it will have access to any variable created in the first script

$item = "Bread"
invoke-osascript -name "Add To Shop" -nested "TRUE"

then inside your add to shop script you will be able to access the $item variable

User avatar
Mat
Posts: 501
Joined: Thu Aug 09, 2012 2:35 pm
Location: UK

Re: Powershell script inside powershell script

#3 Post by Mat » Thu Oct 24, 2013 7:40 am

Going from memory I think what he is looking for is $Parameter2 or $Parameter2.value

Post Reply