powershell

References

Summary

Powershell is a scripting language, like Bash

The pipeline in Bash only sends text In powershell it sends objects

Cmdlets

Commandlets are the built-in commands in powershell They all have the same form

Verb-SingularNoun

Common verbs:

Common nouns

Most of the cmdlets actually have aliases, which are short forms that will apply the corresponding command

So ri will produce remove-item rni = rename-item

The list of aliases is stored in the PSDrive called Alias

If you travel there with

cd alias:

Because alias is a drive, you need the colon at the end

Things you can do

Get a random file

$folder =
Get-ChildItem -Path $folder -File | Get-Random | Invoke-Item

Execution Policy Scope

MachinePolicy: Set via Group Policy (GPO) for all users of the computer. It cannot be overridden by local commands.

UserPolicy: Set via Group Policy for the current user. Like MachinePolicy, this is managed by IT administrators and overrides manual settings.

Process: Affects only the current PowerShell session (the window you are currently in). It is stored in memory and disappears once you close the window.

CurrentUser: Affects only the user currently logged in. It is stored in the HKEYCURRENTUSER registry branch.

LocalMachine: The default scope that affects all users on the computer. It is stored in the HKEYLOCALMACHINE registry branch and requires Administrator rights to change

Because LocalUser is higher than LocalMachine, even if LocalMachine sets defaults, LocalUser can override them

Local Scripts

There is a hidden tag called zone.identifier on files

When you unblock a file, it just removes the zone id