Cmdlets, Parameters, and the Help System

Find any PowerShell command with Get-Command, read its syntax and help, use named, positional and switch parameters, and preview changes safely with -WhatIf and -Confirm.

By The Dark DebuggerUpdated 21 min read

This article teaches the skill that makes every later PowerShell topic easier: finding a command you've never used, reading how to call it, and running it safely. It assumes you have PowerShell 7 installed (Installing PowerShell 7) and have read the Introduction. Next comes The Object Pipeline, where these commands start working together.

Why discovery matters more than memorising

Picture a Linux build server whose logs folder needs archiving before a release. You know PowerShell can make zip files, but not the command's name, its parameters, or whether it overwrites existing archives. You could search the web, but PowerShell can answer all three questions itself, offline, with information that matches the exact version installed. That is the workflow this article teaches:

  1. Find the command: Get-Command.
  2. Learn how to call it: -Syntax and Get-Help.
  3. Inspect what it returns: Get-Member.
  4. Preview before changing anything: -WhatIf.

We'll do exactly that archive job at the end. First, the pieces.

Cmdlets and the Verb-Noun convention

A cmdlet is a command compiled into a PowerShell module, named Verb-Noun. Functions and scripts written in PowerShell follow the same convention, so from the caller's side they look identical. The verb comes from a list of approved verbs, grouped by purpose:

Get-Verb | Group-Object -Property Group -NoElement
 
Count Name
----- ----
   34 Common
    6 Communications
   24 Data
    7 Diagnostic
   22 Lifecycle
    1 Other
    6 Security
 

Get-Verb -Group Lifecycle lists the 22 verbs for starting, stopping, installing and deploying things (Start, Stop, Install, Deploy, Invoke, Register and so on). Verbs you might reach for from other languages, such as Fetch or Grab, aren't on the list:

Get-Verb -Verb Fetch, Grab, Get
 
Verb AliasPrefix Group  Description
---- ----------- -----  -----------
Get  g           Common Specifies an action that retrieves a resource
 

That matters once you write your own commands. Here's a small module with one approved and one unapproved verb:

# InventoryTools.psm1
function Get-Inventory {
    param([string]$Path = './inventory.csv')
    Import-Csv -Path $Path
}
 
function Fetch-Inventory {
    param([string]$Url)
    Invoke-RestMethod -Uri $Url
}
Import-Module ./InventoryTools.psm1
WARNING: The names of some imported commands from the module 'InventoryTools' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

The module still loads and Fetch-Inventory still works, but everyone who imports it gets that warning. Rename it to Get-RemoteInventory (or similar) and the warning disappears. We'll write modules properly in Scripts, Scope, and Modules.

Finding commands with Get-Command

Get-Command searches every command PowerShell can run: cmdlets, functions, aliases, and executables on your PATH. Search by noun, verb, name pattern or module.

By noun, when you know what you want to work with:

Get-Command -Noun Csv
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          ConvertFrom-Csv                                    7.0.0.0    Microsoft.PowerShell…
Cmdlet          ConvertTo-Csv                                      7.0.0.0    Microsoft.PowerShell…
Cmdlet          Export-Csv                                         7.0.0.0    Microsoft.PowerShell…
Cmdlet          Import-Csv                                         7.0.0.0    Microsoft.PowerShell…
 

The answer depends on the platform. Get-Command -Noun Service returns nothing at all in PowerShell 7 on Linux, because the service cmdlets are Windows-only. In Windows PowerShell 5.1 on my laptop it returned eight: Get-Service, New-Service, Restart-Service, Resume-Service, Set-Service, Start-Service, Stop-Service and Suspend-Service.

By verb, when you know what you want to do: Get-Command -Verb Export lists Export-Alias, Export-Clixml, Export-Csv, Export-FormatData, Export-ModuleMember and Export-PSSession.

By wildcard, when you only remember part of the name. Add -CommandType Cmdlet, because otherwise every matching executable on your PATH is included too; on my WSL machine, Get-Command *json* also listed json_pp, jsonschema and a handful of Windows files:

Get-Command -Name *json* -CommandType Cmdlet
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          ConvertFrom-Json                                   7.0.0.0    Microsoft.PowerShell…
Cmdlet          ConvertTo-Json                                     7.0.0.0    Microsoft.PowerShell…
Cmdlet          Test-Json                                          7.0.0.0    Microsoft.PowerShell…
 

By module, to see everything a module offers:

Get-Command -Module Microsoft.PowerShell.Archive
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Compress-Archive                                   1.2.6      Microsoft.PowerShell…
Function        Expand-Archive                                     1.2.6      Microsoft.PowerShell…
 

The CommandType column tells you what a name actually is, which is useful when the same word could be several things:

Get-Command -Name tar, gci, Get-ChildItem
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     tar                                                0.0.0.0    /usr/bin/tar
Alias           gci -> Get-ChildItem
Cmdlet          Get-ChildItem                                      7.0.0.0    Microsoft.PowerShell…
 

Reading syntax blocks

Once you've found a command, -Syntax shows how to call it:

Get-Command Get-ChildItem -Syntax
 
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Depth <uint>] [-Force] [-Name] [-Attributes <FlagsExpression[FileAttributes]>] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [<CommonParameters>]
 
Get-ChildItem [[-Filter] <string>] -LiteralPath <string[]> [-Include <string[]>] [-Exclude <string[]>] [-Recurse] [-Depth <uint>] [-Force] [-Name] [-Attributes <FlagsExpression[FileAttributes]>] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [<CommonParameters>]
 

The brackets carry all the meaning:

NotationMeaning
-Filter <string>The parameter takes a value of that type.
[-Include <string[]>]Square brackets around the whole thing: optional.
[[-Path] <string[]>]Brackets around the name too: positional, so you may leave out -Path.
[-Path] <string[]>Name in brackets but not the whole: mandatory, and positional.
-LiteralPath <string[]>No brackets at all: mandatory and must be named.
<string[]>The [] means it accepts several values: -Path a, b.
[-Recurse]No type: a switch, on when present.
[<CommonParameters>]-Verbose, -ErrorAction and friends, covered below.

Parameter sets

Each block in the syntax output is a parameter set: a valid combination of parameters. The two Get-ChildItem sets differ only in -Path versus -LiteralPath (literal paths don't expand wildcards, which matters for file names containing [ or ]). Get-Process has six:

Get-Command Get-Process -Syntax
 
Get-Process [[-Name] <string[]>] [-Module] [-FileVersionInfo] [<CommonParameters>]
 
Get-Process [[-Name] <string[]>] -IncludeUserName [<CommonParameters>]
 
Get-Process -Id <int[]> [-Module] [-FileVersionInfo] [<CommonParameters>]
 
Get-Process -Id <int[]> -IncludeUserName [<CommonParameters>]
 
Get-Process -InputObject <Process[]> [-Module] [-FileVersionInfo] [<CommonParameters>]
 
Get-Process -InputObject <Process[]> -IncludeUserName [<CommonParameters>]
 

-Name and -Id never appear in the same block, so you can't use them together. PowerShell picks the set from the parameters you supply; if none fits, you get an error (see Common mistakes).

The help system

PowerShell 7 ships without full help

The first time you ask for help in a fresh PowerShell 7 install, you get a stub built from the command's metadata:

Get-Help Get-ChildItem
 
NAME
    Get-ChildItem
 
SYNTAX
    Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Include <string[]>] [-Exclude <string
    []>] [-Recurse] [-Depth <uint>] [-Force] [-Name] [-Attributes {None | ReadOnly | Hidden | Syste
    m | Directory | Archive | Device | Normal | Temporary | SparseFile | ReparsePoint | Compressed
    | Offline | NotContentIndexed | Encrypted | IntegrityStream | NoScrubData}] [-FollowSymlink] [-
    Directory] [-File] [-Hidden] [-ReadOnly] [-System] [<CommonParameters>]
[…]
 
ALIASES
    gci
    dir
 
 
REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only par
    tial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-
    Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Get-ChildItem -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=2096492.
 

Download the real help with Update-Help. With no arguments it updates every installed module; I limited it to the four core modules this article uses:

Update-Help -Module Microsoft.PowerShell.Core, Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility, Microsoft.PowerShell.Archive -UICulture en-US

It shows a progress bar per module and prints nothing on success. In PowerShell 7 help installs for the current user by default, so no admin rights are needed. Windows PowerShell 5.1 stores help under C:\Windows\System32 and needs an elevated prompt for Update-Help. Re-run it occasionally; help is updated independently of PowerShell itself.

The views you'll actually use

Short description only:

Get-Help Get-ChildItem | Select-Object -ExpandProperty Synopsis
Gets the items and child items in one or more specified locations.

Examples, which is usually the fastest way to learn a command: Get-Help Get-ChildItem -Examples prints only the synopsis and the numbered examples, each with the command, sample output and an explanation. We'll use it on an unfamiliar command at the end of this article.

One parameter, when you need the details of a single option:

Get-Help Get-ChildItem -Parameter Filter
 
-Filter [<System.String>]
    Specifies a filter to qualify the **Path** parameter. The FileSystem provider is the only insta
    lled
    PowerShell provider that supports filters. Filters are more efficient than other parameters. Th
    e
    provider applies the filter when the cmdlet gets the objects rather than having PowerShell filt
    er
    the objects after they're retrieved.
[…]
    Required?                    false
    Position?                    1
    Default value
    Accept pipeline input?       false
    Aliases                      none
    Accept wildcard characters?  true
 

The odd line breaks ("insta lled") are how help text wrapped in my 100-column terminal; a wider window reads better. -Full gives everything, descriptions, every parameter, inputs, outputs, notes and examples; for Get-ChildItem that was 917 lines, so page it with | more or use -Online, which opens the web version in your browser. On a machine without a browser it says so:

Get-Help Get-Process -Online
Get-Help: Starting a browser to display online Help failed. No program or browser is associated to open the URI https://go.microsoft.com/fwlink/?LinkID=2096814.

about_ topics: the manual

Concepts that aren't a single command (operators, quoting, scopes, parameters) live in about_ topics. After updating help for Microsoft.PowerShell.Core I had 147 of them:

Get-Help about_* | Select-Object -First 8 Name
 
Name
----
about_Parameter_Binding
about_Telemetry
about_Redirection
about_Comparison_Operators
about_Operator_Precedence
about_Remote_Requirements
about_Functions_Argument_Completion
about_Switch
 

Read one like any other topic, Get-Help about_Parameters. If you don't know a name at all, give Get-Help a keyword and it searches:

Get-Help -Name ExecutionPolicy
 
Name                              Category  Module                    Synopsis
----                              --------  ------                    --------
Get-ExecutionPolicy               Cmdlet    Microsoft.PowerShell.Sec… …
Set-ExecutionPolicy               Cmdlet    Microsoft.PowerShell.Sec… …
 

Parameters in practice

The demo folder for the rest of the article has a logs directory with six files: access.log, access.log.1, access.log.2.gz, error.log, payment service.log and worker.log.

Named and positional

Named parameters can go in any order:

Get-ChildItem -Path logs -Filter *.log
 
    Directory: /home/sid/demo/logs
 
UnixMode         User Group         LastWriteTime         Size Name
--------         ---- -----         -------------         ---- ----
-rw-r--r--        sid sid        11/09/2026 21:05      2420077 access.log
-rw-r--r--        sid sid        11/09/2026 19:47        36023 error.log
-rw-r--r--        sid sid        11/09/2026 21:04       926458 payment service.log
-rw-r--r--        sid sid        11/09/2026 20:58       514014 worker.log
 

The syntax said [[-Path] <string[]>] [[-Filter] <string>], so Path is position 0 and Filter is position 1. Get-ChildItem logs *.log gives exactly the same output. Positional values are bound in order, which is why swapping them is a quiet bug (see Common mistakes).

Abbreviated names

You can shorten a parameter name as long as it stays unambiguous:

Get-ChildItem -Pa logs -Fi *.gz
 
    Directory: /home/sid/demo/logs
 
UnixMode         User Group         LastWriteTime         Size Name
--------         ---- -----         -------------         ---- ----
-rw-r--r--        sid sid        11/07/2026 23:59       211648 access.log.2.gz
 

Handy at the prompt; in scripts, write names in full. A future version can add a parameter that makes your abbreviation ambiguous.

Switches and arrays

A switch is on when present. To set one from a variable or turn it off explicitly, use a colon: -Recurse:$false. A <string[]> parameter takes a comma-separated list, and -Verbose (a common parameter) shows what the command did:

Copy-Item -Path logs/error.log, logs/worker.log -Destination backup/ -Verbose
VERBOSE: Performing the operation "Copy File" on target "Item: /home/sid/demo/logs/error.log Destination: /home/sid/demo/backup/error.log".
VERBOSE: Performing the operation "Copy File" on target "Item: /home/sid/demo/logs/worker.log Destination: /home/sid/demo/backup/worker.log".

Common parameters: -WhatIf, -Confirm, -Verbose, -ErrorAction

Every cmdlet accepts a set of common parameters, the [<CommonParameters>] at the end of each syntax line. These are the ones you'll use weekly:

ParameterWhat it does
-WhatIfDescribe what would change, change nothing. Only on commands that modify things.
-ConfirmAsk before each change.
-VerboseShow the command's VERBOSE: progress messages.
-ErrorActionWhat to do on a non-terminating error: Continue (default), SilentlyContinue, Ignore, Stop, Inquire.
-ErrorVariableAlso store errors in a named variable.
-OutVariableAlso store output in a named variable.

-WhatIf is the one I'd make a habit. Before deleting with a wildcard, look:

Remove-Item -Path logs/access.log.* -WhatIf
What if: Performing the operation "Remove File" on target "/home/sid/demo/logs/access.log.1".
What if: Performing the operation "Remove File" on target "/home/sid/demo/logs/access.log.2.gz".

-Confirm asks interactively. This is from an interactive session where I answered N:

Remove-Item reports -Recurse -Confirm
 
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove Directory" on target
"/home/sid/demo/reports".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): N

Note the default is Y: pressing Enter deletes. Read the prompt.

-ErrorAction controls what happens when a command fails for one item. SilentlyContinue hides the message; the automatic variable $? still tells you it failed:

Get-Item logs/missing.log -ErrorAction SilentlyContinue
$?
False

-ErrorVariable collects the errors so you can deal with them after processing the items that did work:

Get-Item logs/missing.log, logs/error.log -ErrorAction SilentlyContinue -ErrorVariable notFound
$notFound.Count
$notFound[0].Exception.Message
 
    Directory: /home/sid/demo/logs
 
UnixMode         User Group         LastWriteTime         Size Name
--------         ---- -----         -------------         ---- ----
-rw-r--r--        sid sid        11/09/2026 19:47        36023 error.log
 
1
Cannot find path '/home/sid/demo/logs/missing.log' because it does not exist.

-ErrorAction Stop turns the error into a terminating one, which is what you want inside try/catch. That story continues in Error Handling.

Get-Member: discovering what a command returns

Help tells you how to call a command. Get-Member tells you what came back. Suppose you want memory figures for the current PowerShell process ($PID holds its ID) but don't know the property names. Ask with a wildcard:

Get-Process -Id $PID | Get-Member -Name *Memory*, StartTime, Path
 
   TypeName: System.Diagnostics.Process
 
Name                       MemberType     Definition
----                       ----------     ----------
NonpagedSystemMemorySize   Property       int NonpagedSystemMemorySize {get;}
NonpagedSystemMemorySize64 Property       long NonpagedSystemMemorySize64 {get;}
PagedMemorySize            Property       int PagedMemorySize {get;}
PagedMemorySize64          Property       long PagedMemorySize64 {get;}
[…]
VirtualMemorySize64        Property       long VirtualMemorySize64 {get;}
StartTime                  Property       datetime StartTime {get;}
Path                       ScriptProperty System.Object Path {get=$this.Mainmodule.FileName;}
 

Two things to notice. Prefer the 64 variants: the plain int ones overflow above 2 GB. And Path is a ScriptProperty, something PowerShell adds on top of the .NET type for convenience. Methods are listed the same way with -MemberType Method; on a file object that shows CopyTo(), MoveTo() and Delete(), among others.

Get-Command itself returns objects, so you can inspect commands the same way. This is the most reliable way to answer "does this parameter accept pipeline input?", a question that matters a lot in the next article:

(Get-Command Remove-Item).Parameters.Values | Where-Object { $_.Attributes.ValueFromPipelineByPropertyName -contains $true } | Select-Object -ExpandProperty Name
Path
LiteralPath
Credential

Tab completion and Show-Command

Press Tab after a partial command, parameter, path or even a parameter value, and PowerShell completes it. The engine behind it is a function you can call, which is how I can show you real results:

(TabExpansion2 -inputScript 'Get-ChildItem -Re' -cursorColumn 17).CompletionMatches | Select-Object CompletionText, ResultType
 
CompletionText    ResultType
--------------    ----------
-Recurse       ParameterName
-ReadOnly      ParameterName
 

So Get-ChildItem -Re then Tab gives -Recurse, and a second Tab gives -ReadOnly. Completion also works for parameter values that come from a fixed list: asking TabExpansion2 about Get-Verb -Group returned all seven verb groups, from Common to Security. That saves a trip to the help.

On Windows there is also Show-Command, which opens a small form for any cmdlet with a field per parameter and builds the command line for you. It exists in Windows PowerShell 5.1 and in PowerShell 7 on Windows; I confirmed it's present in 5.1 with Get-Command Show-Command but didn't open the window. On Linux it doesn't exist:

Get-Command Show-Command
Get-Command: The term 'Show-Command' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Where you'll use this: archiving logs with a command you've never used

Back to the build server. We need to zip the .log files before a release, using only what's on the machine.

Find it. "Archive" is the obvious noun, and we already saw the module: Get-Command -Module Microsoft.PowerShell.Archive lists Compress-Archive and Expand-Archive.

Read the syntax:

Get-Command Compress-Archive -Syntax
 
Compress-Archive [-Path] <string[]> [-DestinationPath] <string> [-CompressionLevel <string>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
 
Compress-Archive [-Path] <string[]> [-DestinationPath] <string> -Update [-CompressionLevel <string>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
 
Compress-Archive [-Path] <string[]> [-DestinationPath] <string> -Force [-CompressionLevel <string>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
[…]

-Path and -DestinationPath are mandatory. There are separate sets for -Update (add to an existing archive) and -Force (overwrite it), which already answers "does it overwrite?": not unless you say so. Get-Help Compress-Archive -Examples showed a first example using a hashtable of parameters, a technique called splatting that you'll meet in Functions and Advanced Functions.

Preview it. -WhatIf caught a mistake straight away:

Compress-Archive -Path logs/*.log -DestinationPath archive/logs-2026-11-09.zip -WhatIf
Compress-Archive: The path '/home/sid/demo/archive' either does not exist or is not a valid file system path.

The destination folder doesn't exist, and Compress-Archive won't create it. Create it and preview again:

New-Item -ItemType Directory -Path archive | Out-Null
Compress-Archive -Path logs/*.log -DestinationPath archive/logs-2026-11-09.zip -WhatIf
What if: Performing the operation "Compress-Archive" on target "
/home/sid/demo/logs/access.log
/home/sid/demo/logs/error.log
/home/sid/demo/logs/payment service.log
/home/sid/demo/logs/worker.log".

Exactly the four .log files, the file with a space included, rotated logs excluded.

Run it and check the result:

Compress-Archive -Path logs/*.log -DestinationPath archive/logs-2026-11-09.zip
Get-Item archive/logs-2026-11-09.zip | Select-Object Name, Length
 
Name                Length
----                ------
logs-2026-11-09.zip 350774
 

About 3.8 MB of logs became 343 KB. Running the same command again shows the overwrite protection the syntax promised:

Compress-Archive -Path logs/*.log -DestinationPath archive/logs-2026-11-09.zip
Compress-Archive: The archive file /home/sid/demo/archive/logs-2026-11-09.zip already exists. Use the -Update parameter to update the existing archive file or use the -Force parameter to overwrite the existing archive file.

Find, read, preview, run, verify. That loop works for any module you'll ever install, including ones for Azure, VMware or your own team's tooling.

Common mistakes

Ambiguous abbreviations

Get-ChildItem -F
Get-ChildItem: Parameter cannot be processed because the parameter name 'F' is ambiguous. Possible matches include: -Filter -Force.

The error lists the candidates. Type enough letters to pick one, or better, the full name.

Positional arguments in the wrong order or too many of them

Swapping positional values doesn't always produce an error. Here *.log binds to -Path and logs to -Filter, so PowerShell looks for files named logs inside paths matching *.log, finds none, and prints nothing:

Get-ChildItem *.log logs

That empty result is easy to misread as "there are no log files". Passing more positional values than the command has positions does fail loudly:

Copy-Item logs/error.log backup/ logs/worker.log
Copy-Item: A positional parameter cannot be found that accepts argument 'logs/worker.log'.

To copy several files, give -Path an array: Copy-Item -Path logs/error.log, logs/worker.log -Destination backup/. When in doubt, name your parameters.

Mixing parameters from different sets

Get-Process -Name pwsh -Id $PID
Get-Process: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.

-Name and -Id live in different parameter sets, as Get-Command Get-Process -Syntax showed. Pick one. When the message says "cannot be resolved", go back to the syntax blocks.

Trusting the help's "Accept pipeline input?" line

While testing this article I noticed that the downloaded help for Remove-Item -Parameter Path says Accept pipeline input? false, yet the command's own metadata, shown in the Get-Member section above, says Path accepts input by property name, and piping objects with a Path property into Remove-Item works. Help is written separately from the code and can lag behind it. When help and metadata disagree, the metadata from Get-Command is what PowerShell actually uses.

Summary

  • Discovery loop: Get-Command to find, -Syntax and Get-Help to learn, Get-Member to inspect results, -WhatIf to preview.
  • Search with Get-Command -Noun, -Verb, -Module or a wildcard -Name; add -CommandType Cmdlet to keep native executables out of the results.
  • In syntax blocks, [[-Name] <type>] is optional and positional, [-Name] <type> is mandatory and positional, a bare -Name <type> is mandatory and named, <type[]> takes a list, and each block is one parameter set.
  • PowerShell 7 ships with stub help; run Update-Help once (no admin needed in 7). Use -Examples first, -Parameter <name> for details, about_* topics for concepts.
  • Common parameters work on every cmdlet: -WhatIf, -Confirm, -Verbose, -ErrorAction, -ErrorVariable, -OutVariable.
  • Name parameters in full in scripts; positional and abbreviated forms are for the prompt.
  • Approved verbs (Get-Verb) aren't decoration: unapproved verbs trigger an import warning.

Exercises

Exercise 1: Find the CSV toolkiteasy

Without the internet, list every command that works with CSV data. Then show the syntax of the one that reads a CSV file into objects.

Show Solution
Get-Command -Noun Csv
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          ConvertFrom-Csv                                    7.0.0.0    Microsoft.PowerShell…
Cmdlet          ConvertTo-Csv                                      7.0.0.0    Microsoft.PowerShell…
Cmdlet          Export-Csv                                         7.0.0.0    Microsoft.PowerShell…
Cmdlet          Import-Csv                                         7.0.0.0    Microsoft.PowerShell…
 

Import-Csv is the reader: run Get-Command Import-Csv -Syntax. Export-Csv and Import-Csv work with files, the ConvertTo/ConvertFrom pair with strings in memory. CSV handling gets a full article in CSV, JSON, and XML.

Exercise 2: Preview a cleanupeasy

Show which rotated logs (access.log.1, access.log.2.gz and any future access.log.N) a wildcard delete would remove from logs, without deleting anything.

Show Solution
Remove-Item -Path logs/access.log.* -WhatIf
What if: Performing the operation "Remove File" on target "/home/sid/demo/logs/access.log.1".
What if: Performing the operation "Remove File" on target "/home/sid/demo/logs/access.log.2.gz".

The pattern access.log.* needs a dot after log, so the live access.log is safe. Seeing that with -WhatIf is much better than finding out afterwards.

Exercise 3: Which commands have unapproved verbs?medium

Create InventoryTools.psm1 from this article, import it, and find out which of its commands caused the unapproved-verb warning.

Hint

The warning itself tells you which parameter to add.

Show Solution
Import-Module ./InventoryTools.psm1 -Force -Verbose
VERBOSE: Removing the imported "Fetch-Inventory" function.
VERBOSE: Removing the imported "Get-Inventory" function.
VERBOSE: Loading module from path '/home/sid/demo/InventoryTools.psm1'.
VERBOSE: Exporting function 'Get-Inventory'.
VERBOSE: Exporting function 'Fetch-Inventory'.
WARNING: The names of some imported commands from the module 'InventoryTools' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
VERBOSE: The 'Fetch-Inventory' command in the InventoryTools' module was imported, but because its name does not include an approved verb, it might be difficult to find. For a list of approved verbs, type Get-Verb.
VERBOSE: Importing function 'Fetch-Inventory'.
VERBOSE: Importing function 'Get-Inventory'.

Fetch-Inventory is the culprit. -Force re-imports a module that's already loaded (that's what the "Removing" lines are), and -Verbose names the offending command.

Exercise 4: When did this shell start?medium

Using only Get-Process, $PID and Get-Member, find the property that holds the start time of your current PowerShell process, and print it.

Show Solution
Get-Process -Id $PID | Get-Member -Name *Time*
 
   TypeName: System.Diagnostics.Process
 
Name                      MemberType Definition
----                      ---------- ----------
GetLifetimeService        Method     System.Object GetLifetimeService()
InitializeLifetimeService Method     System.Object InitializeLifetimeService()
ExitTime                  Property   datetime ExitTime {get;}
PrivilegedProcessorTime   Property   timespan PrivilegedProcessorTime {get;}
StartTime                 Property   datetime StartTime {get;}
TotalProcessorTime        Property   timespan TotalProcessorTime {get;}
UserProcessorTime         Property   timespan UserProcessorTime {get;}
 

The wildcard also caught two methods and the CPU-time properties, but only StartTime is a datetime that describes when the process began:

(Get-Process -Id $PID).StartTime
 
Tuesday, 10 November 2026 01:18:33
 

The value is a DateTime, so (Get-Date) - (Get-Process -Id $PID).StartTime gives you the session's uptime as a TimeSpan.

Exercise 5: Read the metadata, not the prosehard

Find every parameter of Remove-Item that accepts pipeline input by property name, using the command's metadata rather than its help text.

Hint

(Get-Command Remove-Item).Parameters is a dictionary. Each value has an Attributes collection, and the parameter attributes have a ValueFromPipelineByPropertyName property.

Show Solution
(Get-Command Remove-Item).Parameters.Values | Where-Object { $_.Attributes.ValueFromPipelineByPropertyName -contains $true } | Select-Object -ExpandProperty Name
Path
LiteralPath
Credential

$_.Attributes.ValueFromPipelineByPropertyName collects that property from every attribute of the parameter, and -contains $true checks whether any of them set it. This is why piping a CSV with a Path column into Remove-Item works, which The Object Pipeline puts to use.


Tested with: PowerShell 7.6.9 on Ubuntu 24.04 (WSL2), and Windows PowerShell 5.1.26100.9711 on Windows 11, November 2026. Every PowerShell 7 example ran as shown in a 100-column terminal; long help and syntax outputs are trimmed where marked with […]. Help was downloaded with Update-Help for the four modules listed, and the -Confirm prompt came from an interactive session. On Windows I only ran Get-Command -Noun Service and Get-Command Show-Command (read-only); Show-Command's window was not opened. The surprise while testing was the help text claiming Remove-Item -Path doesn't take pipeline input when the command metadata, and the command itself, say otherwise. Paths from the test machine's scratch directories are shown shortened to /home/sid/….

Was this page helpful?
The Dark Debugger

Written by The Dark Debugger

Engineer documenting the things that took me too long to learn, so they take you less time. Every PowerShell tutorial here is tested end to end before publishing.