so I a have this huge set of scripts made of scriptblocks in files. The problem is that some functionality is repeated in different scriptblocks, so I am thinking that it would be more elegant if I could split the scriptblocks to even smaller parts and join them as necessary. When I tried to join them just with + operator it does not work though. Any ideas if that's possible?
$sb1={some commands}
$sb2={some more commands}
$sb3=$sb1+$sb2
invoke-command $sb3
Hm, this ain't exactly pretty, but as a quick adhoc, instead of combining the actual scriptblock objects, you can load the scriptblocks as strings, concatenate them with a newline, and create a scriptblock out of that new string.