Getting started with PowerShellLoopsOperatorsUsing ShouldProcessPowerShell ClassesSwitch statementWorking with ObjectsUsing existing static classesBasic Set OperationsPowerShell FunctionsSending EmailHandling Secrets and CredentialsPowershell RemotingPowerShell "Streams"; Debug, Verbose, Warning, Error, Output and InformationVariables in PowerShellCommunicating with RESTful APIsWorking with the PowerShell pipelinePowerShell Background JobsReturn behavior in PowerShellWorking with XML FilesIntroduction to PsakeUsing the progress barStringsTCP Communication with PowerShellSharePoint ModuleAliasesAutomatic VariablesEnvironment VariablesPowershell profilesEnforcing script prerequisitesUsing the Help SystemSplattingDesired State ConfigurationSigning ScriptsSecurity and CryptographyCSV parsingIntroduction to PesterModules, Scripts and FunctionsPowerShell.exe Command-LineCommon parametersParameter setsRegular ExpressionsPowerShell Dynamic ParametersWMI and CIMGUI in PowershellConditional logicURL Encode/DecodeMongoDBRunning ExecutablesError handlingHashTablesActiveDirectory modulepowershell sql queriesAutomatic Variables - part 2Package managementCmdlet NamingBuilt-in variablesCreating DSC Class-Based ResourcesPowershell ModulesPowerShell WorkflowsHow to download latest artifact from Artifactory using Powershell script (v2.0 or below)?Calculated PropertiesSpecial OperatorsAnonymize IP (v4 and v6) in text file with PowershellComment-based helpAmazon Web Services (AWS) Simple Storage Service (S3)Amazon Web Services (AWS) RekognitionPSScriptAnalyzer - PowerShell Script AnalyzerNaming ConventionsEmbedding Managed Code (C# | VB)Archive ModuleInfrastructure AutomationScheduled tasks moduleISE module

Common parameters

Other topics

Remarks:

Common parameters can be used with any cmdlet (that means as soon as you mark your function as cmdlet [see CmdletBinding()], you get all of these parameters for free).

Here is the list of all common parameters (alias is in parenthesis after corresponding parameter):

-Debug (db)
-ErrorAction (ea)
-ErrorVariable (ev)
-InformationAction (ia) # introduced in v5
-InformationVariable (iv) # introduced in v5
-OutVariable (ov)
-OutBuffer (ob)
-PipelineVariable (pv)
-Verbose (vb) 
-WarningAction (wa)
-WarningVariable (wv)
-WhatIf (wi)
-Confirm (cf)

ErrorAction parameter

Possible values are Continue | Ignore | Inquire | SilentlyContinue | Stop | Suspend.

Value of this parameter will determine how the cmdlet will handle non-terminating errors (those generated from Write-Error for example; to learn more about error handling see [topic not yet created]).

Default value (if this parameter is omitted) is Continue.

-ErrorAction Continue

This option will produce an error message and will continue with execution.

PS C:\> Write-Error "test" -ErrorAction Continue ; Write-Host "Second command"

-ErorrAction Continue

-ErrorAction Ignore

This option will not produce any error message and will continue with execution. Also no errors will be added to $Error automatic variable.
This option was introduced in v3.

PS C:\> Write-Error "test" -ErrorAction Ignore ; Write-Host "Second command"

-ErorrAction Ignore

-ErrorAction Inquire

This option will produce an error message and will prompt user to choose an action to take.

PS C:\> Write-Error "test" -ErrorAction Inquire ; Write-Host "Second command"

-ErorrAction Inquire

-ErrorAction SilentlyContinue

This option will not produce an error message and will continue with execution. All errors will be added to $Error automatic variable.

PS C:\> Write-Error "test" -ErrorAction SilentlyContinue ; Write-Host "Second command"

-ErorrAction SilentlyContinue

-ErrorAction Stop

This option will produce an error message and will not continue with execution.

PS C:\> Write-Error "test" -ErrorAction Stop ; Write-Host "Second command"

-ErorrAction Stop

-ErrorAction Suspend

Only available in Powershell Workflows. When used, if the command runs into an error, the workflow is suspended. This allows investigation of such error and gives a possibility to resume the workflow. To learn more about Workflow system, see [topic not yet created].

Contributors

Topic Id: 5951

Example Ids: 20867

This site is not affiliated with any of the contributors.