Command library

PowerShell command library

Search commands by name or purpose. Each command page gives syntax, parameters, an example with illustrative output, common mistakes, and related lessons.

102 commands in the library

Showing 102 of 102 commands.

Chapter 1: How Windows Works Underneath

4 commands from this chapter. Grouping follows each command's related lesson.

  • Get-Disk

    Lists physical disks on the computer, with size, status, and partition style.

    Get-Disk [-Number <Number>]

  • Get-Partition

    Lists partitions on a disk, with drive letter, size, and type.

    Get-Partition [-DiskNumber <Number>] [-DriveLetter <Letter>]

  • Get-SecureBootUEFI

    Reads a Secure Boot UEFI variable, such as the platform key.

    Get-SecureBootUEFI -Name <Name>

  • Get-Volume

    Lists volumes, which are the formatted parts of disks that you see as drive letters.

    Get-Volume [-DriveLetter <Letter>]

Chapter 2: Your First PowerShell Commands

7 commands from this chapter. Grouping follows each command's related lesson.

  • Get-Alias

    Lists aliases, which are short names for commands.

    Get-Alias [-Name <Name>]

  • Get-Command

    Lists commands available in the session, optionally filtered by noun or verb.

    Get-Command [-Noun <Noun>] [-Verb <Verb>]

  • Get-Help

    Shows help for a command, including syntax, parameters, and examples.

    Get-Help <Command> [-Examples | -Full]

  • Get-Host

    Shows facts about the current PowerShell host program.

    Get-Host

  • Get-Process

    Lists running processes as objects, with properties such as Name, Id, and CPU.

    Get-Process [-Name <Name>]

  • Get-Verb

    Lists approved verbs used in cmdlet names.

    Get-Verb

  • Update-Help

    Downloads the newest help files for installed modules.

    Update-Help

Chapter 3: Think in Objects, Not Text

3 commands from this chapter. Grouping follows each command's related lesson.

  • Get-Member

    Lists the properties and methods of objects.

    Get-Command | Get-Member

  • Get-Variable

    Lists variables in the session, or one named variable.

    Get-Variable [-Name <Name>]

  • Set-Variable

    Creates or changes a variable, with options such as read only.

    Set-Variable -Name <Name> -Value <Value>

Chapter 4: Everyday Commands That Save Hours

11 commands from this chapter. Grouping follows each command's related lesson.

  • Format-List

    Formats objects as a list, one object at a time, for display only.

    Format-List [-Property <Props>]

  • Format-Table

    Formats objects as a table, for display only. Use it last.

    Format-Table [-Property <Props>] [-AutoSize]

  • Get-Service

    Lists services with their status, name, and display name.

    Get-Service [-Name <Name>]

  • Read-Host

    Asks the user for input and returns it as text.

    Read-Host [-Prompt <Text>]

  • Restart-Service

    Stops and then starts a service again.

    Restart-Service -Name <Name>

  • Select-Object

    Picks properties, or the first or last objects, from input.

    Select-Object [-Property <Props>] [-First <N>]

  • Set-Service

    Changes a service, such as its startup type or status settings.

    Set-Service -Name <Name> -StartupType <Type>

  • Sort-Object

    Orders objects by a property, ascending or descending.

    Sort-Object [-Property <Prop>] [-Descending]

  • Stop-Service

    Stops a running service.

    Stop-Service -Name <Name>

  • Where-Object

    Keeps only objects that pass a test.

    Where-Object { <test> }

  • Write-Output

    Sends a value to the pipeline, which usually displays it.

    Write-Output <Value>

Chapter 5: Turn Commands Into Scripts You Can Reuse

1 command from this chapter. Grouping follows each command's related lesson.

  • Set-ExecutionPolicy

    Sets the execution policy for scripts.

    Set-ExecutionPolicy <Policy> [-Scope <Scope>]

Chapter 6: Toolboxes You Can Load When You Need Them

2 commands from this chapter. Grouping follows each command's related lesson.

  • Get-Module

    Lists loaded modules, or, with ListAvailable, installed modules.

    Get-Module [-ListAvailable]

  • Import-Module

    Loads a module into the current session.

    Import-Module <ModuleName>

Chapter 7: One Way to Explore Every Store

3 commands from this chapter. Grouping follows each command's related lesson.

  • Get-ChildItem

    Lists items in a location, such as files in a folder or keys in a provider drive.

    Get-ChildItem [-Path <Path>] [-Recurse]

  • Get-PSDrive

    Lists PowerShell drives, with their providers and roots.

    Get-PSDrive [-Name <Name>]

  • Set-Location

    Moves the current location to a new drive or folder.

    Set-Location [-Path <Path>]

Chapter 10: Run Commands on Other Computers

4 commands from this chapter. Grouping follows each command's related lesson.

  • Enter-PSSession

    Opens an interactive session on a remote computer.

    Enter-PSSession -ComputerName <Computer>

  • Get-ComputerInfo

    Shows facts about the computer, such as Windows version.

    Get-ComputerInfo

  • Invoke-Command

    Runs a script block on remote computers and returns the results.

    Invoke-Command -ComputerName <Computer> -ScriptBlock { <code> }

  • Test-WSMan

    Tests whether WinRM answers on a computer, for remoting.

    Test-WSMan [-ComputerName <Computer>]

Chapter 11: Manage People, Computers, and Names

19 commands from this chapter. Grouping follows each command's related lesson.

  • Add-Computer

    Joins a computer to a domain, or to a workgroup.

    Add-Computer -DomainName <Domain>

  • Add-DnsServerResourceRecord

    Creates a DNS resource record on a DNS server.

    Add-DnsServerResourceRecord -ZoneName <Zone> -A -Name <Host> -IPv4Address <Address>

  • Get-ADComputer

    Reads Active Directory computer objects.

    Get-ADComputer [-Filter <Filter>]

  • Get-ADDomainController

    Lists domain controllers in a domain.

    Get-ADDomainController [-Filter *]

  • Get-ADRootDSE

    Reads RootDSE facts about a directory server.

    Get-ADRootDSE

  • Get-ADUser

    Reads Active Directory user objects.

    Get-ADUser [-Identity <Id> | -Filter <Filter>]

  • Get-DnsServerZone

    Lists DNS zones on a DNS server.

    Get-DnsServerZone

  • Get-LocalUser

    Lists local user accounts on one computer.

    Get-LocalUser [-Name <Name>]

  • Install-ADDSDomainController

    Adds a domain controller to an existing domain. Server only.

    Install-ADDSDomainController -DomainName <Domain>

  • Install-ADDSForest

    Creates a new forest and its first domain. Server only.

    Install-ADDSForest -DomainName <Domain>

  • New-ADGroup

    Creates an Active Directory group.

    New-ADGroup -Name <Name> -GroupScope <Scope> -GroupCategory <Category>

  • New-ADOrganizationalUnit

    Creates an organisational unit in Active Directory.

    New-ADOrganizationalUnit -Name <Name> -Path <ParentDN>

  • New-ADUser

    Creates an Active Directory user.

    New-ADUser -Name <Name> -SamAccountName <Logon>

  • New-DnsServerZone

    Creates a DNS zone on a DNS server.

    New-DnsServerZone -Name <Zone>

  • Remove-ADUser

    Deletes an Active Directory user. Hard to undo, so confirm first.

    Remove-ADUser -Identity <Id> [-Confirm]

  • Set-ADUser

    Changes an Active Directory user, such as title or department.

    Set-ADUser -Identity <Id> [-Title <Title>]

  • Test-ADDSDomainControllerInstallation

    Tests whether adding a domain controller can succeed, without installing.

    Test-ADDSDomainControllerInstallation -DomainName <Domain>

  • Test-ADDSDomainInstallation

    Tests whether a forest install can succeed, without installing.

    Test-ADDSDomainInstallation -DomainName <Domain>

  • Test-Connection

    Tests network connectivity to a computer, similar to ping.

    Test-Connection -ComputerName <Computer> [-Count <N>]

Chapter 12: Let the Computer Do the Work on Time

7 commands from this chapter. Grouping follows each command's related lesson.

  • Disable-ScheduledTask

    Disables a scheduled task without deleting it.

    Disable-ScheduledTask -TaskName <Name>

  • Enable-ScheduledTask

    Enables a disabled scheduled task.

    Enable-ScheduledTask -TaskName <Name>

  • Get-ScheduledTask

    Lists scheduled tasks, with names, states, and paths.

    Get-ScheduledTask [-TaskName <Name>]

  • New-ScheduledTaskAction

    Builds the action part of a scheduled task.

    New-ScheduledTaskAction -Execute <Program> [-Argument <Args>]

  • New-ScheduledTaskTrigger

    Builds the trigger part of a scheduled task.

    New-ScheduledTaskTrigger -Daily -At <Time>

  • Register-ScheduledTask

    Creates a scheduled task from an action, trigger, and settings.

    Register-ScheduledTask -TaskName <Name> -Action <Action> -Trigger <Trigger>

  • Start-ScheduledTask

    Runs a scheduled task once, on demand.

    Start-ScheduledTask -TaskName <Name>

Chapter 13: Control Who Gets In and Out

6 commands from this chapter. Grouping follows each command's related lesson.

  • Enable-NetFirewallRule

    Enables a disabled firewall rule.

    Enable-NetFirewallRule -Name <Name>

  • Get-NetConnectionProfile

    Shows the network profile for each adapter.

    Get-NetConnectionProfile [-InterfaceAlias <Adapter>]

  • Get-NetFirewallProfile

    Shows firewall profiles: Domain, Private, and Public.

    Get-NetFirewallProfile [-Name <Name>]

  • Get-NetFirewallRule

    Lists firewall rules with direction, action, and state.

    Get-NetFirewallRule [-Name <Name>]

  • New-NetFirewallRule

    Creates a firewall rule.

    New-NetFirewallRule -DisplayName <Name> -Direction <Dir> -Action <Action>

  • Set-NetFirewallRule

    Changes a firewall rule in place.

    Set-NetFirewallRule -Name <Name> [-Action <Action>]

Chapter 14: Set Rules Once, Apply Them Everywhere

7 commands from this chapter. Grouping follows each command's related lesson.

  • Backup-Gpo

    Backs up a GPO to a folder.

    Backup-Gpo -Name <Name> -Path <Folder>

  • Get-GPO

    Lists Group Policy Objects in a domain.

    Get-GPO [-All | -Name <Name>]

  • Get-GPOReport

    Generates a report for a GPO, as HTML or XML.

    Get-GPOReport -Name <Name> -ReportType <Html|Xml> -Path <Path>

  • Get-GPResultantSetOfPolicy

    Shows the resultant set of policy for a user or computer.

    Get-GPResultantSetOfPolicy -User <User> -ReportType <Type>

  • Import-Gpo

    Imports a backed up GPO into a target GPO.

    Import-Gpo -BackupId <Id> -TargetName <Name> -Path <Folder>

  • Invoke-GPUpdate

    Forces a Group Policy refresh, locally or remotely.

    Invoke-GPUpdate [-Computer <Computer>] [-Force]

  • Restore-Gpo

    Restores a GPO from a backup.

    Restore-Gpo -Name <Name> -Path <Folder> -BackupId <Id>

Chapter 15: Small Commands, Big Everyday Wins

18 commands from this chapter. Grouping follows each command's related lesson.

  • Add-ADFineGrainedPasswordPolicySubject

    Assigns a fine grained password policy to a group or user.

    Add-ADFineGrainedPasswordPolicySubject -Identity <Policy> -Subjects <Group>

  • Add-Content

    Appends text to a file, without replacing it.

    Add-Content -Path <File> -Value <Text>

  • Export-Csv

    Writes objects to a CSV file.

    Export-Csv -Path <File> -NoTypeInformation

  • Get-ADFineGrainedPasswordPolicy

    Reads fine grained password policies.

    Get-ADFineGrainedPasswordPolicy [-Identity <Name> | -Filter *]

  • Get-Date

    Returns the current date and time as a datetime object.

    Get-Date [-Format <Format>]

  • Get-DnsClientServerAddress

    Shows DNS server addresses per adapter.

    Get-DnsClientServerAddress [-InterfaceAlias <Adapter>]

  • Get-NetAdapter

    Lists network adapters with names, status, and speeds.

    Get-NetAdapter [-Name <Name>]

  • Get-NetIPAddress

    Shows IP addresses per adapter.

    Get-NetIPAddress [-InterfaceAlias <Adapter>]

  • Get-WinUserLanguageList

    Shows the user language and keyboard layout list.

    Get-WinUserLanguageList

  • Import-Csv

    Reads a CSV file into one object per row.

    Import-Csv -Path <File> [-Delimiter <Char>]

  • Invoke-WebRequest

    Fetches web content over HTTP and returns a response object.

    Invoke-WebRequest -Uri <Url> [-OutFile <Path>]

  • New-ADFineGrainedPasswordPolicy

    Creates a fine grained password policy object.

    New-ADFineGrainedPasswordPolicy -Name <Name> -Precedence <N>

  • New-NetIPAddress

    Adds an IP address to an adapter.

    New-NetIPAddress -InterfaceAlias <Adapter> -IPAddress <Address> -PrefixLength <N>

  • Rename-Computer

    Renames the computer. Usually needs a restart.

    Rename-Computer -NewName <Name>

  • Set-Content

    Writes text to a file, replacing it if it exists.

    Set-Content -Path <File> -Value <Text>

  • Set-DnsClientServerAddress

    Sets DNS server addresses for an adapter.

    Set-DnsClientServerAddress -InterfaceAlias <Adapter> -ServerAddresses <Addresses>

  • Set-NetIPAddress

    Changes an existing IP address on an adapter.

    Set-NetIPAddress -InterfaceAlias <Adapter> -IPAddress <Address>

  • Set-WinUserLanguageList

    Sets the user language and keyboard layout list.

    Set-WinUserLanguageList -LanguageList <List>

Chapter 16: PowerShell for Ethical Hackers

4 commands from this chapter. Grouping follows each command's related lesson.

  • Get-LocalGroupMember

    Lists members of a local group on one computer.

    Get-LocalGroupMember -Group <Name>

  • Get-NetTCPConnection

    Lists TCP connections, including listening ports and the process that owns each one.

    Get-NetTCPConnection [-State <State>] [-LocalPort <Port>]

  • Get-SmbShare

    Lists shared folders on the local computer.

    Get-SmbShare [-Name <Name>]

  • Get-WinEvent

    Reads events from a Windows event log.

    Get-WinEvent -LogName <Log> [-MaxEvents <Number>]

Chapter 17: PowerShell Security and Hardening

3 commands from this chapter. Grouping follows each command's related lesson.

  • Get-AuthenticodeSignature

    Checks the digital signature on a file, such as a script.

    Get-AuthenticodeSignature -FilePath <Path>

  • Start-Transcript

    Starts recording console input and output to a text file.

    Start-Transcript [-Path <Path>]

  • Stop-Transcript

    Stops the transcript started by Start-Transcript.

    Stop-Transcript

Chapter 18: PowerShell Automation Projects

3 commands from this chapter. Grouping follows each command's related lesson.

  • New-ScheduledTaskSettingsSet

    Builds the settings part of a scheduled task, such as retry and battery behaviour.

    New-ScheduledTaskSettingsSet [-AllowStartIfOnBatteries] [-StartWhenAvailable]

  • Test-Path

    Tests whether a path exists, and returns True or False.

    Test-Path -Path <Path>

  • Write-Error

    Writes an error message to the error stream, without throwing a terminating error by default.

    Write-Error -Message <Text>