Questions tagged [scriptblock]

Single unit of operation of expression and statements.

Multiple expressions or statements which make up a single unit of operations. The block can accept return values and arguments. Usually found in a statement list in braces such as {<list of statements>}.

154 questions
-1
votes
1 answer

PowerShell ternary and default operator

Based on this answer I tried to create another operator (alias) that reuses that ternary one, and I get error when executing the command: The expression after '&' in a pipeline element produced an object that was not valid. It must result in a…
SOReader
  • 5,697
  • 5
  • 31
  • 53
-1
votes
1 answer

function inside Scriptblock unable to understand

I am having issues trying to understand how to integrate a function on a scriptblock. The reason why I need the scriptblock is because I want to run a powershell script in orchestrator unless someone can help me how can I run a working customized…
-1
votes
1 answer

Powershell psql block of code using EOF

I have multiline injection to 'psql' command in linux using EOF. psql << EOF sql1 sql2 EOF I want to do the same in windows powershell because(yes it's hard on me) we moved from linux to windows. I tried scriptblock, using psql as the block and…
Arun Srini
  • 17
  • 1
  • 6
-1
votes
1 answer

How to create a scriptblock item that can be used in Invoke-Command command

I would like to run a few lines of code on a remote machine, so I have to use the "Invoke-command" cmdlet to achieve that. The script I want to run is rather long (not just a simple command, but a few loops, conditionals, etc.), so it is not…
FrozenLand
  • 259
  • 1
  • 4
  • 14
1 2 3
10
11