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