header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Call a Powershell script from a powerscript and return a value
Last Post 02 May 2008 09:31 AM by BauerShell. 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Anton1701User is Offline
New Member
New Member
Posts:13
Avatar

--
01 May 2008 10:30 PM  

Hello Powershell Friends,

 

I have a script the creates a string.

**********************First Start**********************************

# do fun stuff to create string

Return $stringOfInterest

**********************First End**********************************

Now the I would like to call the first script from the second.

 

**********************Second Start************************

$wshShell = New-Object -com WScript.Shell 

$PSCommand = "powershell.exe -command "
$PathToFUN = "
\\server-01\Utilities\fun\fun.ps1"
$PSFUNCommand = [string]::Concat([Char] 34,$PathToFUN,[Char] 34)
$PSFUNCommand = [string]::Concat($PSCommand,$PSFUNCommand)
Write-Host $PSFUNCommand
Write-Host $wshShell.Exec($PSPODCommand).StdOut.ReadAll
****************Secind End*******************************

 

Now if I run the first script from Powershell, all is good. I get the correct string value.

If I Run the second script that calls the first one I get  "string ReadAll()"

 

What am I missing?

 

Thanks for you Thoughts

 

Anton

BauerShellUser is Offline
New Member
New Member
Posts:7
Avatar

--
02 May 2008 09:31 AM  
Maybe I am missunderstanding you, but I don't see the need for a ComObject, when you call a Powershellscript.

a simple:

write-host (&$PathToFun)

should fit your needs.
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer