Notes
  • Welcome!
  • Windows Shells
    • Introduction
    • Command Prompt
      • Basics
      • Host Enumeration
      • Files & Directories
      • Environment Variables
      • Managing Services
      • Scheduled Tasks
      • Help
    • PowerShell
      • PowerShell vs. CMD
      • Basics
      • CmdLets & Modules
      • User & Group Management
      • Files & Dirs
      • Finding & Filtering
      • Services
      • Registry
      • Windows Event Log
      • Networking Management
      • Web Interaction
      • Scripting
      • Help
  • Windows
    • Commands
    • NTFS
  • APISEC
    • API Testing
      • Recon
      • Endpoint Analysis
      • Finding Security Misconfigurations
      • Authentication Attacks
      • Exploiting API Authorization
        • BOLA
        • BFLA
      • Improper Assets Management
      • Mass Assignment Attacks
      • SSRF
      • Injection Attacks
      • Evasion & Chaining
    • API Authentication
      • Authentication Types
      • OAuth Actors
      • OAuth Interaction Patterns
      • JSON Web Tokens
      • Claims
      • APIs & Gateways
  • PostSwigger
    • Web LLM Attacks
      • Overview
      • Exploiting LLM APIs, function, & Plugins
      • Indirect Prompt Injection
      • Leaking Sensitive Data
      • Defending Against LLM Attacks
    • JWT Attacks
      • JWTs
      • Attacks
        • Flawed Signature Verfication
        • Brute-forcing Secret Keys
        • JWT Header Parameter Injections
        • Algorithm Confusion
      • Prevention
    • OAuth
      • General Information
      • Exploiting OAuth Authentication Flaws
        • Flaws in Client Application
        • Flaws in the OAuth Service
      • OpenID
  • Red Teaming LLM Applications
    • LLM Vulnerabilities
    • Red Teaming LLMs
    • Red Teaming at Scale
    • Red Teaming LLMs with LLMs
    • Red Teaming Assessment
  • Fin
    • Course 1: Basics
      • Stocks
        • General Information
        • Shares
        • Stock Basics
      • Bonds
        • General Information
        • Components
        • Valuation
      • Markets
        • What is the Stock Market
        • What is the FED
    • Course 2: Stock Investing
  • Other
    • Learning Resources
Powered by GitBook
On this page
  • Using Modules
  • Execution Policy
  1. Windows Shells
  2. PowerShell

CmdLets & Modules

PreviousBasicsNextUser & Group Management

Last updated 1 year ago

A is a single-feature command that manipulates objects in PowerShell. Cmdlets are written in C# or other languages and then complise for PowerShell usage. PowerShell is similar to a script; it can contain cmdlets, functions, other scripts, etc.

  1. The most basic way to create a module is to save a Windows PowerShell script as .psm1. This is the "meat" of the module.

  2. A Powershell data file (.psd1) is called a module manifest file and contains information such as version numbers, authors, cmdlets used, etc.

is the best place to search for modules, scripts, etc. We can interact with it directly through PowerShell with the PowerShellGet cmdlet.

# list modules parameters
Get-Command -Module PowerShellGet
# find a specific module
Find-Module -Name <module>
# install module
Install-Module -Name <module>

PowerShell will auto-import a module installed the first time we run a cmdlet or function from it. This is not true for modules that we bring onto the host from elsewhere, e.g. GitHub.

Using Modules

# list loaded modules
Get-Module
# list available modules (installed but not loaded into the session)
Get-Module -ListAvailable
# load a module in the current session
Import-Module <my_module.ps1>

It is possible to permanently add a module by adding the files to the referenced directories in the PSModulePath.

$env:PSModulePath

After loading the module, we can list its parameters.

Get-Command -Module <module>

Execution Policy

A host's execution policy might prevent us from running scripts.

# check execution policy state
Get-ExecutionPolicy
Restricted
# changing execution policy (undefined -> no interecation limits)
Set-ExecutionPolicy undefined

Another way to bypass the execution policy and not leave a persistent change (as above) is to change it at the process level using -scope. This way the change will be reverted once we close the session.

Set-ExecutionPolicy -scope Process
Get-ExecutionPolicy -List

.

cmdlet
modules
PowerShell Gallery
Execution Policy bypasses