Skip to content

Set-printerpermissions

SYNOPSIS

Modify printer permissions on a specified server or local machine.

SYNTAX

Set-printerpermissions [[-ServerName] <String>] [-AccountName] <String> [[-SinglePrinterName] <String>]
 [[-AccessMask] <String>] [-Deny] [-Remove] [[-AceFlag] <Int32>] [[-IntAccessMask] <UInt32>] [-NoLog]
 [[-LogFile] <String>] [<CommonParameters>]

DESCRIPTION

This function modifies the DACL of printer objects to add or remove specific permissions for a user or group. It supports setting permissions on all printers of a target server or a specific printer. The function allows specifying access masks, propagation flags, and whether to allow or deny permissions. It also supports removing all access control entries for a specified account.

EXAMPLES

EXAMPLE 1

Set-printerpermissions -AccountName "ServerAdmins" -AccessMask ManageDocuments

Grants the "ServerAdmins" group the ManageDocuments permission on all printers of the executing host.

EXAMPLE 2

Set-printerpermissions -AccountName "bob" -Remove -NoLog

Removes all access control entries associated with "bob" on all printers of the executing host without creating a log.

EXAMPLE 3

Set-printerpermissions -ServerName "PrtSrv1" -AccountName "[email protected]" -AccessMask Print -SinglePrinterName "Printer1"

Grants "alice@upn.loc" the Print permission on "Printer1" located on the server "PrtSrv1".

EXAMPLE 4

Set-printerpermissions -ServerName "PrtSrv2" -AccountName "bob" -AccessMask ChangePermissions -Deny -LogFile "C:\Logs\PermissionsLog.txt"

Denies "bob" the ChangePermissions permission on all printers on the "PrtSrv2" server and writes the log to the specified file.

EXAMPLE 5

Set-printerpermissions -ServerName "PrtSrv1" -AccountName "ServerAdmins" -IntAccessMask 268435456

Grants the "ServerAdmins" group all permissions except "ManageDocuments" on "PrtSrv1" using an integer access mask.

PARAMETERS

-ServerName

The name of the server on which to modify printer permissions. Defaults to the local machine.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: .
Accept pipeline input: False
Accept wildcard characters: False

-AccountName

The sAMAccountName or userPrincipalName of the user or group for which permissions will be modified. This parameter is mandatory.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SinglePrinterName

The name of a specific printer to modify permissions on. If not specified, all printers on the target server will be updated.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-AccessMask

The permission access mask to be applied. Supported values are "ManagePrinters", "ManageDocuments", "Print", "TakeOwnership", "ReadPermissions", or "ChangePermissions". Defaults to "Print".

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: Print
Accept pipeline input: False
Accept wildcard characters: False

-Deny

A switch to set the access type to "Deny". By default, permissions are set to "Allow".

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Remove

A switch to remove all access control entries associated with the specified account name.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-AceFlag

A bit flag that indicates permission propagation. Supported values include: - 0x0001: OBJECT_INHERIT_ACE - 0x0002: CONTAINER_INHERIT_ACE - 0x0004: NO_PROPAGATE_INHERIT_ACE - 0x0008: INHERIT_ONLY_ACE - 0x0010: INHERITED_ACE

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 7
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-IntAccessMask

A uint32 representation of an access mask. If specified, it overrides the AccessMask parameter.

Type: UInt32
Parameter Sets: (All)
Aliases:

Required: False
Position: 8
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-NoLog

A switch to disable log file creation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 9
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-LogFile

The path and file name of the desired log file. If not specified, a log file is created in the executing directory.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES