Skip to content

Latest commit

 

History

History
42 lines (39 loc) · 2.05 KB

20210728231843-powershell.org

File metadata and controls

42 lines (39 loc) · 2.05 KB

Powershell

What is Powershell?

It’s a JIT scripting language that runs on top of the .NET CLR. It uses a unique Verb-Noun naming scheme for functions, and if you make a function with an unapproved verb, it might throw a warning. Variables begin with dollar signs, like in PHP, and being a scripting language you don’t need to declare them. Nor do you need to import modules, unless you’re digging very deep into .NET. Speaking of which, all of .NET’s libraries are available for use. And then there’s the optional type system, used by prepending a variable with the [type] in brackets. As a bonus, all objects are .NET Objects, and most code also works as C# code, so if you really like your script it should be pretty easy to compile.

How Powershell read input

Captured On: [2021-07-21 Wed]

ﲵ  echo $themesPath/hello
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules /hello
ﲵ  echo $themesPath.TrimEnd(' ')/hello
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules
/hello
ﲵ  echo $themesPath.TrimEnd(' ') /hello
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules
/hello
ﲵ  echo "$themesPath.TrimEnd(' ')/hello"
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules .TrimEnd(' ')/hello
ﲵ  echo "$($themesPath.TrimEnd(' '))/hello"
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules/hello
ﲵ  echo $($themesPath.TrimEnd(' '))/hello
/mnt/c/Users/nopan/OneDrive/Documents/WindowsPowerShell/Modules
/hello
  • $(x.func()) still evaluate as function variable. If it returns string and you want to combine other string altogether, without “” delimiter it will interprets as 2 arguments. This excepts for string variable which can combine remaining strings without “”. So in this case we need to use “” to instruct that’s we echo with 1 argument not two!!
  • ”” will eval $ but won’t eval .method()(treated as a string).