Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Running the above line from an admin level command line will run powershell as admin, then from the powershell instance, it will run whatever .ps1 file you give it. Additionally, it won't alter the default policies set for the machine or user.

Invoking commands

Again, PowerShell is object-oriented, and every object has methods and properties. In order to view an object's methods and properties, we use the Get-Member command.

Get-Process -Name Chrome | Get-Member

shows us all the methods and properties associated with the Chrome browser. This syntax can be used with every object and command (to the best of my knowledge). Using the above syntax can get write heavy so I suggest using Get-Member's shortcut, gm.

Get-Process -Name Chrome | gm

will function the same as the former line. Once you have a property or method in mind, you can then invoke it.

If it's a method then you must use parenthesis at the end like such:

(Get-Process -Name Chrome).Start()

If it's a property then you do not need the parenthesis:

(Get-Process -Name Chrome).SessionId

If you store an object into a variable, then invoking commands becomes a bit simpler:

$Process.Start()
$Process.SessionId

External Resources

List of  Aliases

...