11
$BizTalkHelper = "d:\Scripts\BizTalkHelper.ps1"
.$BizTalkHelper # "dot source" the helper library.
Write-Host *** BEGIN ***

Write-Host $(Get-Date) " Desc:" {GetHostStateDesc 1 }
Write-Host $(Get-Date) " Desc:" GetHostStateDesc 2 

$result = GetHostStateDesc 1 
Write-Host $result 

My functions prints "hello", in addition to a switch statement to translate 1 to 'Stopped', 2 to 'Start Pending', 4 to 'Running', etc... So I know it's not getting called in the first two cases.

Results:

*** BEGIN *** 
3/29/2013 11:03:34 AM  Desc: GetHostStateDesc 1 
3/29/2013 11:03:34 AM  Desc: GetHostStateDesc 2 
hello 
Function GetHostStateDesc  1 
Stopped

2 Answers 2

15

Try this:

function SayHello {'Hello'}
write-host $(SayHello)

This prints:

Hello
Sign up to request clarification or add additional context in comments.

1 Comment

also without sub-expression write-host (SayHello)
6

Looks like it is this:

Write-Host $(Get-Date) " Desc:" $(GetHostStateDesc 1 )

I noticed the $() syntax around Get-Date, so if it's a function, I guessed it would work on my function and it did.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.