PowerShell module and CSV import

The module WePrintEasy.psm1 is used by the admin console and the agent – and you can use it in your own scripts, for example to import many assignments at once.

On this page

Loading the module

The installer copies the module to the installation folder. Import it in a PowerShell session on the terminal server:

Import-Module 'C:\Program Files\WePrintEasy\WePrintEasy.psm1'

All commands use the configuration path stored during installation (registry value ConfigPath under HKLM\SOFTWARE\WePrintEasy) – the local config.json or the central file on a share. With -ConfigPath you can work on another file. To change the configuration you need write access to it, just as in the admin console.

Commands for assignments

Command Purpose
Get-WpeAssignment [-Type User|Group] [-Name <pattern>] List assignments; -Name accepts wildcards and also matches the display name
Set-WpeAssignment -Type User|Group -Name <account> -Printer <printer> [-Priority <n>] [-Comment <text>] Create or update an assignment; the SID is looked up in Active Directory
Remove-WpeAssignment -Type User|Group -Name <account> Remove an assignment
Invoke-WpeRemoteForce -ComputerName <server> -UserName <account> [-Credential <cred>] “Enforce now” from the console – see Troubleshooting
Get-WpeSystemStatus The system check of the Setup check tab as objects

Set-WpeAssignment and Remove-WpeAssignment support -WhatIf and -Confirm. Account names may be given with or without domain (COMPANY\jdoe, jdoe@company.local or jdoe).

Examples

Import-Module 'C:\Program Files\WePrintEasy\WePrintEasy.psm1'

# Show
Get-WpeAssignment | Format-Table Type, Name, DisplayName, Printer, Priority

# Set / remove individually
Set-WpeAssignment -Type User  -Name jdoe -Printer '\\printsrv01\HP-Office'
Set-WpeAssignment -Type Group -Name GG_Warehouse -Printer '\\printsrv01\Zebra-Warehouse' -Priority 20
Remove-WpeAssignment -Type User -Name jdoe

# Redirected client printer (wildcard)
Set-WpeAssignment -Type User -Name jdoe -Printer 'Brother HL-L2350DW*(redirected*' -Comment 'Home office'

The configuration is written atomically and the previous version is kept as config.json.bak. Running sessions pick up the changes automatically, at the latest after one check interval.

CSV bulk import

Many assignments can be imported from a CSV file in one go. Columns: Type;Name;Printer;Priority;Comment, separated by semicolons. Priority and Comment are optional.

Type;Name;Printer;Priority;Comment
User;mmuster;\\printsrv01\HP-Buero-Mustermann;;Raum 2.14
User;eschmidt;\\printsrv01\Kyocera-Empfang;;
Group;GG_Buchhaltung;\\printsrv01\Kyocera-Buchhaltung;10;Abteilungsdrucker
Group;GG_Lager;\\printsrv01\Zebra-Lager;20;

Download sample CSVDownload config.example.json

Import it with:

Import-Module 'C:\Program Files\WePrintEasy\WePrintEasy.psm1'

# Preview without saving
Import-Csv .\assignments.csv -Delimiter ';' | Set-WpeAssignment -WhatIf

# Import
Import-Csv .\assignments.csv -Delimiter ';' | Set-WpeAssignment
  • An existing assignment of the same user or group is updated, otherwise a new one is created.
  • An empty Priority keeps the existing priority (new assignments get 100). For groups, the smallest number wins.
  • Accounts that cannot be found in Active Directory are skipped with an error message; all others are imported.
  • The file is saved once at the end of the import.
  • Windows PowerShell 5.1 reads CSV files in the system code page by default. If the file contains umlauts or other special characters, save it as UTF-8 and add -Encoding UTF8 to Import-Csv.

Export assignments

To back up assignments or edit them in Excel, export them as CSV:

Get-WpeAssignment | Select-Object Type, Name, Printer, Priority, Comment |
    Export-Csv .\assignments-export.csv -Delimiter ';' -NoTypeInformation -Encoding UTF8

The exported file has the same columns and can be imported again with Import-Csv … | Set-WpeAssignment.

Enforce now from PowerShell

Invoke-WpeRemoteForce -ComputerName TS01 -UserName jdoe

# With other credentials (e.g. if the console runs under a local account)
Invoke-WpeRemoteForce -ComputerName TS01 -UserName jdoe -Credential (Get-Credential)

Every step is printed in colour; the result object has the properties Success and Message. Administrator rights on the terminal server are required. Details in Troubleshooting.

Download WePrintEasy ZIP with setup wizard, update and uninstall scripts. Free · MIT licence

Download WePrintEasy 1.0.3