ShellSpells
  • πŸ§™β€β™‚οΈWelcome!
    • ShellSpells
    • FAQs
    • License & Disclaimer
  • 🐧Linux
    • System Ops
      • Transcripts
      • Help
      • System Info
        • Date/Time
        • System Details
        • Patches & Updates
        • Init System Identification
        • Hostname / Host ID
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Shares
        • Packages
        • Connected Devices
        • Kernel Modules (Drivers)
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Jobs
        • Enumerate
        • Modify
      • Processes
        • Enumerate
        • Modify
        • Custom Script and Shared Object
        • Process I/O Redirection
      • Services
        • Enumerate
        • Modify
        • Create a Service
      • Startup/Boot Scripts
        • Enumerate
        • Modify
      • Security
        • Antivirus
        • Firewall
        • SSH Keys
      • History & Logs
        • History
        • Logs
    • File Ops
      • Search
        • Filename
        • Content
        • Users (Owners)
        • Time
        • Size
        • Permission
        • Hidden Files
        • Inode
        • Find + Exec
        • Notes
      • Enumerate Metadata
      • Modify Metadata
      • Read Content
      • Modify Content
      • Extract Content
      • Sort / Compare / Count
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
    • Terminal Ops
      • Keyboard Shortcuts
      • Tmux Shortcuts
  • πŸͺŸWindows
    • System Ops
      • Transcripts
      • Help
      • System Info
        • One-liners
        • Date/Time
        • System Details
        • Hotfixes
        • Domain or Workgroup
        • Data Execution Prevention
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Installed Software
        • Drivers
        • Shares
      • Registry
        • Enumerate
        • Modify
        • Forensically Relevant Keys
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Tasks
      • Processes
        • Enumerate
        • Modify
      • Services
        • Enumerate
        • Modify
      • Autorun / Startup
        • Enumerate
        • Modify
      • Security
        • Permissions
          • Enumerate
          • Page
        • Antivirus
        • Firewall
          • Enumerate
          • Modify
        • Audit Policies
        • Remoting
          • Enumerate
          • Modify
          • Registry Locations
        • Stored Credentials
      • Remote Command Execution
      • Active Directory
        • Enumerate
        • Modify
      • History & Logs
        • History
        • Logs
      • PowerShell Config
      • Scripting
      • WMIC Notes
    • File Ops
      • Search
        • Filename
        • Time
        • Size
        • Permissions
        • Attributes
        • Wildcarding
      • Enumerate Metadata
        • One Liners
        • Users (Owners)
        • Timestamps
        • Size
        • Permissions
        • Attributes
      • Modify Metadata
        • Change Owner
        • Timestamps
        • Size
        • Attributes
      • Read Content
      • Modify Content
        • Overwrite
        • Insert
        • Append
        • Replace / Remove
        • Convert Case
        • Alternate Data Streams
      • Extract Content
      • Sort / Compare / Count
        • Sort
        • Count
        • Compare
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
      • Output Formatting / Filtering
      • File Formatting
      • Operators
  • ⛓️Network
    • Traffic Manipulation
      • iptables
        • Option List
        • General Commands
        • Filter Tables
        • NAT
        • Mangle
        • Filter for SSH Traffic (Example)
      • nftables
    • Packet Capture
      • Syntax
      • TCPDump Examples
    • Packet Analysis
      • Wireshark
  • πŸš—Maneuver
    • SSH
    • Control Sockets
    • RDP
    • Windows Port Proxy
  • πŸ›©οΈData Transfer
    • SCP
    • FTP
    • Netcat
      • Netcat Relays
    • Server Interactions
    • Alternate Methods
  • πŸͺ„REGEX
    • Examples
Powered by GitBook
On this page
  • Version
  • PowerShell Profiles
  • Switch Versions
  • PowerShell Execution Policy
  • Notes

Was this helpful?

  1. Windows
  2. System Ops

PowerShell Config

Version

get-host | select-object Version

Get PowerShell version using get-host.

echo $PSVERSIONTABLE

Shows all version and build information.

$PSVersionTable.PSVersion

Get PowerShell version using $PSVersionTable.PSVersion.

powershell -command "$PSVersionTable.PSVersion"

Get PowerShell version in Command Prompt.

Queries the installed versions of PowerShell using Common Information Model (CIM) and filters based on the product name:

Get-CimInstance -ClassName Win32_Product -Filter "Name LIKE 'Microsoft PowerShell%'" | Select-Object -Property Name, Version

Retrieves the PowerShell version as part of the operating system information using CIM:

Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property PSVersion

Lists installed versions of PowerShell using (WMI):

wmic product where "Name like 'Microsoft PowerShell%'" get Name, Version 

Retrieves the PowerShell version as part of the operating system information using WMIC:

wmic os get PowerShellVersion

PowerShell Profiles

$PsHome

Stores the installation directory for PowerShell.

$Home

Stores the current user’s home directory.

$PROFILE

Stores the path to the current user's profile script.

ISE $profile

Opens the user's profile script in the Integrated Scripting Environment (ISE).

$PsHome\\Profile.ps1

Profile script for all users and all hosts.

$PsHome\\Microsoft.PowerShell_profile.ps1

Profile script for all users on the current host.

$Home\\[My]Documents\\Profile.ps1

Profile script for the current user and all hosts.

$Home\\[My]Documents\\WindowsPowerShell\\Profile.ps1

Profile script for the current user on the current host.

$profile | Get-Member -Type NoteProperty

Displays the profile values of Names, MemberType, and Paths.

$Profile | get-member -type noteproperty | ft -wrap

Displays the profile values with wrapped text.

$PROFILE | Get-Member -MemberType noteproperty | select name

Displays only the Names of profile properties.

Test-Path -Path $profile.currentUsercurrentHost

Checks if the profile for the current user and host exists.

Test-Path -Path $profile.currentUserAllHosts

Checks if the profile for the current user and all hosts exists.

Test-Path -Path $profile.AllUsersAllHosts

Checks if the profiles for all users and all hosts exist.

Test-Path -Path $profile.AllUserscurrentHost

Checks if the profiles for all users on the current host exist.

New-Item -ItemType File -Path $profile -Force

Creates a new profile script for the current user, ignoring errors.

Switch Versions

Switch to PSv7:

pwsh

PowerShell Execution Policy

Get-ExecutionPolicy -list

Lists all of the Scopes and ExecutionPolicies on the system.

Get-ExecutionPolicy

Gets the current user's ExecutionPolicy.

powershell.exe Get-ExecutionPolicy

Retrieves the current PowerShell execution policy using CMD.

Sets the ExecutionPolicy for the CurrentUser to Unrestricted:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser 

Queries the registry for the execution policy setting:

reg query "HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" /v ExecutionPolicy

Retrieves the execution policy setting from the registry:

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" -Name ExecutionPolicy

Generates an HTML report containing the Group Policy settings, including the PowerShell execution policy, and opens it in the default web browser:

gpresult /h result.html && start result.html

Notes

Restricted: No scripts are allowed to run, offering the highest security level. Useful for locked-down environments or when testing untrusted code.

AllSigned: Requires all scripts and configuration files, even those written locally, to be signed by a trusted publisher before execution. Provides strong security but requires additional setup for signing your own scripts.

RemoteSigned: Permits execution of scripts downloaded from the internet only if they are signed by a trusted publisher. Offers a balance between security and functionality, allowing some remote script execution.

Bypass: No restrictions are in place, allowing all scripts to run without warnings or prompts. Least secure option, use with caution only in trusted environments.

Default: Sets the execution policy to the default for your system, which is: Restricted for Windows client operating systems. RemoteSigned for Windows server operating systems.

PreviousLogsNextScripting

Last updated 1 year ago

Was this helpful?

πŸͺŸ