Visible function script block, how to create 2 separate ecommands

Howdy,

I am implementing JEA, and have a working .psrc Each visble function has a script block with a single command.

To be more elegant, I want two separete commands run in succession under one visible function. Example - first stop various services, then stop a specific website. I can’t figure out how to separete it, to avoid errors when connecting to the endpoint.

I have attempted a simple carriage return, semi colon, comma, group each command with parenthesis as to separate the commands. Nothing works.

This link does not demonstrate examples of two separete commands in a script block about_Script_Blocks - PowerShell | Microsoft Learn

Am I chasing my tail? Else, is there correct syntax to separate commands in a visible function script block?

Please share some relevant code so we can try to help you better.
Remember to format your code appropriately:
Guide to Posting Code

1 Like

Ever have one of those days? It was a misplaced curly brace. Many of them, the dangers of cut 'n paste.

The correct code is:

@{
‘Name’ = ‘check_solarwinds’

‘ScriptBlock’ = {
get-service | where {($.displayname -like ‘solarwinds*’) -or ($.name -like “rabbit*”) -or ($_.name -like “nettcp*”)} | select-myobject displayname,name,status | sort status,displayname

get-website | where {$_.name -like 'solar*'} | FT -auto
} 

}

(Edit: pardon the funky way the forum shows the code)

it’s not that the forum shows code a funny way, it’s that you didn’t format the code. I provided a link with a guide to posting code.
You should edit your message, click the little gear icon on the format bar and you’ll find the “preformatted text” option.
Select all your “code” and then use that option. Or, put a line with three backticks before and after your code
```
#your code in between
```

will result in

#your code in between
2 Likes