Compartilhar via


Set-PrintConfiguration

Set-PrintConfiguration

Sets the configuration information for the specified printer.

Syntax

Parameter Set: PrintConfigObject
Set-PrintConfiguration [-InputObject] <CimInstance> [-AsJob] [-CimSession <CimSession> ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: PrinterName
Set-PrintConfiguration [-PrinterName] <String> [-AsJob] [-CimSession <CimSession> ] [-Collate <Boolean> ] [-Color <Boolean> ] [-ComputerName <String> ] [-DuplexingMode <DuplexingModeEnum> ] [-PaperSize <PaperSizeEnum> ] [-PrintTicketXml <String> ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: PrinterObject
Set-PrintConfiguration [-PrinterObject] <CimInstance> [-AsJob] [-CimSession <CimSession> ] [-Collate <Boolean> ] [-Color <Boolean> ] [-DuplexingMode <DuplexingModeEnum> ] [-PaperSize <PaperSizeEnum> ] [-PrintTicketXml <String> ] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Set-PrintConfiguration cmdlet sets the printer configuration for the specified printer. Using the Set-PrintConfiguration cmdlet, you can manage the configuration of the following features:

● Collate

● Color

● Duplexing Mode

● N-Up

● Paper Size

The Set-PrintConfiguration cmdlet also accepts print configuration objects using Get-PrintConfiguration cmdlet.

You cannot use wildcard characters with Set-PrintConfiguration. You can use Set-PrintConfiguration in a Windows PowerShell remoting session.

You need administrator privileges to use Set-PrintConfiguration.

Parameters

-AsJob

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<CimSession>

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Collate<Boolean>

Specifies whether or not to collate the output of the printer by default.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Color<Boolean>

Specifies whether the printer should use either color or grayscale printing by default.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String>

Specifies the name of the computer on which the printer is located.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-DuplexingMode<DuplexingModeEnum>

Specifies the duplexing mode the printer uses by default.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<CimInstance>

Specifies the object which contains the printer configuration settings to set.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-PaperSize<PaperSizeEnum>

Specifies the paper size the printer uses by default.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PrintTicketXml<String>

Specifies the print ticket XML defining the default print settings for this printer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PrinterName<String>

Specifies the printer on which to set the configuration information.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-PrinterObject<CimInstance>

Specifies the object which contains the printer on which to change the configuration settings.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/StandardCimv2/MSFT_Printer

    This cmdlet accepts one printer object.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • This cmdlet produces no output objects.

Examples

-------------------------- ExampleXAMPLE 1: Set the default paper size -------------------------- xample:Set the default paper size

This command sets the default paper size of the printer named "Microsoft XPS Document Writer" printer to A4.

PS C:\> Set-PrintConfiguration –PrinterName "Microsoft XPS Document Writer" -PaperSize A4

Example 2: Set the default paper size using print configuration object

This set of commands retrieves a print configuration object into a variable ($PrintConfiguration) using Get-PrintConfiguration, sets the paper size in the printer configuration object to A4 and then passes the contents of the variable to Set-PrintConfiguration.

PS C:\> $PrintConfiguration = Get-PrintConfiguration –PrinterName "Microsoft XPS Document Writer"
PS C:\> $PrintConfiguration.paperSize = A4
PS C:\> Set-PrintConfiguration –InputObject $PrintConfiguration

Example 3: Set the default paper size of all printers

This command gets all the printers into a variable $printers and then loops through all the printers and displays the properties.

PS C:\> $printers = get-printer * 
foreach ($printer in $printers)
{ 
    Set-printconfiguration –printerName $printer.name -PaperSize A4
}

Get-PrintConfiguration