Set-Printercode
SYNOPSIS
Generate and assign a printer code for MFK users.
SYNTAX
Set-Printercode [-identity] <Object> [[-sizelimit] <Int32>] [[-printercode] <String>] [-mail] [-clear]
[<CommonParameters>]
DESCRIPTION
This function assigns a permanent printer code to a user (via the AD property `extensionAttribute2`), either randomly or by specifying a custom code. It ensures that duplicate codes are not assigned and optionally sends an email to the user with their code. The function also supports clearing existing codes.
EXAMPLES
EXAMPLE 1
Assigns a random printer code to the user "jdoe".
EXAMPLE 2
Assigns the printer code "123456" to the user "jdoe" and sends it via email.
EXAMPLE 3
Clears the printer code for the user "jdoe".
PARAMETERS
-identity
The name or identity of the user(s). If ambiguous, multiple users will be updated.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-sizelimit
The limit on the number of users to update (default is 10). Use this to prevent bulk updates from affecting all users.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 10
Accept pipeline input: False
Accept wildcard characters: False
-printercode
An optional custom printer code. The code must be 6 digits and unique. If not provided or invalid, a random code will be generated. Note: When specifying multiple users, only the first user will receive the custom code, and others will get random codes.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A switch to send the printer code to the user via email.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-clear
A switch to clear the existing printer code.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
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.