Take any powershell script. It doesn’t have to be a 1-liner. Then surround it with the following code:
$code = {
#Put your code here
rundll32.exe user32.dll,LockWorkStation
}
[convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($code))
Then it will output a 64-digit encoded string.
Use the one-liner string as follows (This string is a popup that shows your hostname):
powershell -EncodedCommand DQAKAAkAJAB3AHMAaABlAGwAbAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAALQBDAG8AbQBPAGIAagBlAGMAdAAgAFcAcwBjAHIAaQBwAHQALgBTAGgAZQBsAGwADQAKAAkAJAB3AHMAaABlAGwAbAAuAFAAbwBwAHUAcAAoACIAWQBvAHUAcgAgAGMAbwBtAHAAdQB0AGUAcgAgAG4AYQBtAGUAIABpAHMAOgAgACIAIAArACAAIAAkAGUAbgB2ADoAYwBvAG0AcAB1AHQAZQByAG4AYQBtAGUALAAwACwAIgBDAG8AbQBwAHUAdABlAHIAIABOAGEAbQBlACIALAAwAHgAMAApAA0ACgA=
You have successfully converted a full script to a 1-liner for the tray icon.