PowerProfile.Commands.PSPreference.psm1
#Requires -Version 5.1 function Set-PSPreference { <# .SYNOPSIS Add/change/remove a PowerShell preference variable .DESCRIPTION Adds a PowerShell preference variable to the PowerProfile configuration .PARAMETER ConfirmPreference Determines whether PowerShell automatically prompts you for confirmation before running a cmdlet or function. .PARAMETER DebugPreference Determines how PowerShell responds to debugging messages generated by a script, cmdlet or provider, or by a Write-Debug command at the command line. .PARAMETER ErrorActionPreference Determines how PowerShell responds to a non-terminating error, an error that doesn't stop the cmdlet processing. For example, at the command line or in a script, cmdlet, or provider, such as the errors generated by the Write-Error cmdlet. .PARAMETER FormatEnumerationLimit Determines how many enumerated items are included in a display. This variable doesn't affect the underlying objects, only the display. When the value of $FormatEnumerationLimit is fewer than the number of enumerated items, PowerShell adds an ellipsis (...) to indicate items not shown. .PARAMETER InformationPreference The $InformationPreference variable lets you set information stream preferences that you want displayed to users. Specifically, informational messages that you added to commands or scripts by adding the Write-Information cmdlet. If the InformationAction parameter is used, its value overrides the value of the $InformationPreference variable. Write-Information was introduced in PowerShell 5.0. .PARAMETER LogCommandHealthEvent Logs errors and exceptions in command initialization and processing. The default is $false (not logged). .PARAMETER LogCommandLifecycleEvent Logs the starting and stopping of commands and command pipelines and security exceptions in command discovery. The default is $false (not logged). .PARAMETER LogEngineHealthEvent Logs errors and failures of sessions. The default is $true (logged). .PARAMETER LogEngineLifecycleEvent Logs the opening and closing of sessions. The default is $true (logged). .PARAMETER LogProviderLifecycleEvent Logs provider errors, such as read and write errors, lookup errors, and invocation errors. The default is $true (logged). .PARAMETER LogProviderHealthEvent Logs adding and removing of PowerShell providers. The default is $true (logged). .PARAMETER MaximumHistoryCount Determines how many commands are saved in the command history for the current session. .PARAMETER OFS The Output Field Separator (OFS) specifies the character that separates the elements of an array that is converted to a string. .PARAMETER OutputEncoding Determines the character encoding method that PowerShell uses when it sends text to other applications. .PARAMETER ProgressPreference Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet. The Write-Progress cmdlet creates progress bars that show a command's status. .PARAMETER PSDefaultParameterValues Specifies default values for the parameters of cmdlets and advanced functions. The value of $PSDefaultParameterValues is a hash table where the key consists of the cmdlet name and parameter name separated by a colon (:). The value is a custom default value that you specify. .PARAMETER PSEmailServer Specifies the default e-mail server that is used to send email messages. This preference variable is used by cmdlets that send email, such as the Send-MailMessage cmdlet. .PARAMETER PSModuleAutoloadingPreference Enables and disables automatic importing of modules in the session. All is the default. Regardless of the variable's value, you can use Import-Module to import a module. .PARAMETER PSSessionApplicationName Specifies the default application name for a remote command that uses Web Services for Management (WS-Management) technology. .PARAMETER PSSessionConfigurationName Specifies the default session configuration that is used for PSSessions created in the current session. This preference variable is set on the local computer, but it specifies a session configuration that's located on the remote computer. .PARAMETER PSSessionOption Establishes the default values for advanced user options in a remote session. These option preferences override the system default values for session options. .PARAMETER Transcript Used by Start-Transcript to specify the name and location of the transcript file. If you do not specify a value for the Path parameter, Start-Transcript uses the path in the value of the $Transcript global variable. If you have not created this variable, Start-Transcript stores the transcripts in the $Home\My Documents directory as \PowerShell_transcript.<time-stamp>.txt files. .PARAMETER VerbosePreference Determines how PowerShell responds to verbose messages generated by a script, cmdlet, or provider, such as the messages generated by the Write-Verbose cmdlet. Verbose messages describe the actions performed to execute a command. .PARAMETER WarningPreference Determines how PowerShell responds to warning messages generated by a script, cmdlet, or provider, such as the messages generated by the Write-Warning cmdlet. .PARAMETER WhatIfPreference Determines whether WhatIf is automatically enabled for every command that supports it. When WhatIf is enabled, the cmdlet reports the expected effect of the command, but doesn't execute the command. .INPUTS None .OUTPUTS None .LINK https://PowerProfile.sh/ #> [CmdletBinding(PositionalBinding=$false)] Param( [ValidateSet('High','Medium','Low','None')] [string]$ConfirmPreference, [ValidateSet('SilentlyContinue','Stop','Continue','Inquire','Ignore','Suspend','Break')] [string]$DebugPreference, [ValidateSet('SilentlyContinue','Stop','Continue','Inquire','Ignore','Suspend','Break')] [string]$ErrorActionPreference, [ValidateSet('ConciseView','NormalView','CategoryView')] [String]$ErrorView, [ValidateRange([System.Management.Automation.ValidateRangeKind]::Positive)] [Int32]$FormatEnumerationLimit, [ValidateSet('SilentlyContinue','Stop','Continue','Inquire','Ignore','Suspend','Break')] [string]$InformationPreference, [bool]$LogCommandHealthEvent, [bool]$LogCommandLifecycleEvent, [bool]$LogEngineHealthEvent, [bool]$LogEngineLifecycleEvent, [bool]$LogProviderLifecycleEvent, [bool]$LogProviderHealthEvent, [ValidateRange([System.Management.Automation.ValidateRangeKind]::Positive)] [Int32]$MaximumHistoryCount, [string]$OFS, [ValidateSet('ASCIIEncoding','UTF7Encoding','UTF8Encoding','UTF32Encoding','UnicodeEncoding')] [string]$OutputEncoding, [ValidateSet('SilentlyContinue','Stop','Continue','Inquire','Ignore','Suspend','Break')] [string]$ProgressPreference, [hashtable]$PSDefaultParameterValues, [string]$PSEmailServer, [ValidateSet('All','ModuleQualified','None')] [string]$PSModuleAutoLoadingPreference, [string]$PSSessionApplicationName, [string]$PSSessionConfigurationName, [System.Management.Automation.PSSessionTypeOption]$PSSessionOption, [System.IO.DirectoryInfo]$Transcript, [ValidateSet('SilentlyContinue','Stop','Continue','Inquire','Ignore','Suspend','Break')] [string]$VerbosePreference ) if ($PSBoundParameters.Count -gt 0) { foreach ($Pref in $PSBoundParameters) { Set-Variable -Scope Global -Name $Pref.Keys -Value $Pref.Values -Confirm:$false } } else { # foreach ($Pref in (Get-PSPreference)) { # Set-Variable -Scope Global -Name $Pref.Keys -Value $Pref.Values -Confirm:$false # } } } |