PowerShell
ABOUT
PowerShell is a powerful task automation and configuration management framework developed by Microsoft, built on the .NET framework. It includes a command-line shell and a scripting language designed to automate tasks across Windows systems, such as managing processes, services, files, and configurations. PowerShell is more powerful and flexible than the traditional Command Prompt (cmd) and integrates deeply with system administration tools.
ALSO WE COULD USE CMD COMMANDS WITH CMD /C {COMMAND}
ALIASES
Many cmdlets in PowerShell also have aliases. For example, the aliases for the cmdlet Set-Location
, to change directories, is either cd
or sl
. We can view all available aliases by typing Get-Alias
.
We can also set up our own aliases with New-Alias
and get the alias for any cmdlet with Get-Alias -Name
.
RUNNING SCRIPTS
PowerShell ISE (Integrated Scripting Environment) allows users to write PowerShell scripts on the fly. It also has an autocomplete/lookup function for PowerShell commands. The PowerShell ISE allows us to write and run scripts in the same console, which allows for quick debugging.
Examples:
Import scripts so that all functions could be used in our PowerShell session
EXECUTION POLICY
Execution Policy, is security feature to control script execution and prevent the execution of malicious scripts.
Execution policy is not a security boundary and can be bypassed by
Typing the script directly into the console.
Using encoded commands or adjusting policy temporarily.
Changing the execution policy for the current process (session).
View execution policy
AllSigned
Scripts need a trusted publisher's signature. Prompts for untrusted publishers.
Bypass
No restrictions; no warnings or prompts.
Default
Default: Restricted
for desktops, RemoteSigned
for servers.
RemoteSigned
Local scripts can run; downloaded scripts require a digital signature.
Restricted
Blocks script execution; allows individual commands.
Undefined
No policy set; defaults to Restricted
.
Unrestricted
Allows unsigned scripts; warns for non-local intranet scripts.
CMDLETS
Cmdlets are specialized commands in PowerShell. They follow a consistent verb-noun naming (Get-Process
) to indicate their action and the object they operate on.
Get more info about file
List all running Services
Examine Service permissions
List all loaded Modules
Check Defender
Listing Named Pipes
WMI
Getting Windows Version
List system information
Get SID of users
Get all service paths
Last updated