UniversalPrintManagementPowerShell module設計用於從命令列管理與管理通用列印資源。 當你想建立自動化工具時,可以使用這個模組。
本文將協助你入門 UniversalPrintManagement 模組,並說明其核心概念。
安裝 UniversalPrintManagement
從 PowerShell 會話中執行以下指令:
Install-Module UniversalPrintManagement
根據預設,PowerShell 資源庫未設為 PowerShellGet 的信任存放庫。 你第一次使用 PSGallery 時,會看到以下提示:
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the `Set-PSRepository` cmdlet.
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
回答 Yes 或 Yes to All 繼續安裝。
注意
關於離線場景中安裝 PSGallery 模組的更多資訊,請參閱 PowerShell 資源庫。
解除安裝 UniversalPrintManagement
從 PowerShell 會話中執行以下指令:
Uninstall-Module -Name UniversalPrintManagement
登入 通用列印
用 Connect-UPService 指令長互動式登入。
Connect-UPService
你會看到一個登入對話框,輸入 Azure 帳號的使用者名稱和密碼,或選擇先前儲存的帳號之一。
注意
此指令本的主要目的是允許自動化腳本進行非互動式登入。 例如,可以使用 Connect-UPService -UserPrincipalName username@tenantname.com -Password $variableHoldingSecureString 語法來做到這一點,並從安全儲存體中擷取密碼。
登入後,使用模組中的可用指令碼來存取和管理印表機資源。
通用列印管理 Cmdlet
UniversalPrintManagement cmdlets 遵循 PowerShell 的標準命名規則。 VERB-NOUN 動詞描述動作(例如、、、),名詞描述資源類型(例如、GetSetGrant、)。 RevokeUPPrinterUPPrintJobUPAccess UniversalPrintManagement 中的名詞總是以 為前綴 UP開頭。
了解名詞和動詞有助於你用 Get-Command 指令檔找到指令。 例如,若要尋找使用 Get 動詞的命令:
Get-Command -Verb Get -Module UniversalPrintManagement
若要取得 cmdlet 的詳細資訊及其範例:
Get-Help Get-UPPrinter -Detailed
[註]UniversalPrintManagement
Get指令集現在會以延續標記回傳結果,允許分頁處理大型集合並重新標記失敗的請求。 學習如何使用續集標記。 由於為了容納延續標記所需的模型變更,現在建議將 cmdlet 結果儲存Get在變數中,並透過.results來存取。 請參考此處的範例。
Sign-in
| Cmdlet | Description |
|---|---|
| Connect-UPService | 連線到已驗證的帳戶,以用於 通用列印 Cmdlet 要求。 |
Printers
| Cmdlet | Description |
|---|---|
| Get-UPPrinter | 使用此指令小程式取得單一或清單印表機的資訊。 |
| Remove-UPPrinter | 使用此 cmdlet 來解除印表機註冊。 |
印表機特性
| Cmdlet | Description |
|---|---|
| Set-UPPrinterProperty | 使用此 cmdlet 來更新印表機的可變屬性。 |
印表機共享
| Cmdlet | Description |
|---|---|
| New-UPPrinterShare | 用這個 cmdlet 來共用印表機。 |
| Get-UPPrinterShare | 使用此 cmdlet 來取得單一或多台共用印表機的資訊。 |
| Remove-UPPrinterShare | 使用此 cmdlet 來取消共用先前已共用的印表機。 |
| 設定印表機共享 | 使用此 cmdlet 來更新印表機共用,將一台因需要維護而須更換的已註冊印表機替換為一台可正常運作的印表機。 |
使用者權限
| Cmdlet | Description |
|---|---|
| Grant-UPAccess | 使用此 cmdlet 可授權使用者或群組或組織中所有使用者列印權限。 |
| Revoke-UPAccess | 使用此 cmdlet 可撤銷使用者、群組或組織中所有使用者的列印權限。 |
| Get-UPAllowedMember | 使用此 cmdlet 取得擁有特定印表機列印權限的使用者與群組資訊。 |
連接器
| Cmdlet | Description |
|---|---|
| Get-UPConnector | 使用此指令碼來取得單一或多個連接器的資訊。 |
| 移除-UPConnector | 使用這個指令碼來取消註冊連接器。 |
連接器特性
| Cmdlet | Description |
|---|---|
| Set-UPConnectorProperty | 使用這個 cmdlet 來更新連接器的可變屬性。 |
列印工作
| Cmdlet | Description |
|---|---|
| Get-UPPrintJob | 使用這個指令小程式來取得送往印表機的列印工作資訊。 |
列印工作報告
| Cmdlet | Description |
|---|---|
| Get-UPUsageReport | 使用這個指令小程式來取得不同類型的列印使用報告。 |