AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1713713
Accepted
ChristAHFER
ChristAHFER
Asked: 2022-03-31 10:46:18 +0800 CST2022-03-31 10:46:18 +0800 CST 2022-03-31 10:46:18 +0800 CST

确定哪个组策略适用于哪个打印机

  • 772

所以在工作中有成千上万的打印机和数百个打印机组策略组。

如何确定哪个组将部署哪台打印机?

请忽略命名约定等。

我想知道有哪些可能的方法,我在网上查看过,大多数建议是使用我不需要的组策略部署打印机。

printer group-policy
  • 1 1 个回答
  • 81 Views

1 个回答

  • Voted
  1. Best Answer
    harrymc
    2022-03-31T11:12:54+08:002022-03-31T11:12:54+08:00

    我无权访问像您这样的域,但以下是我找到的。我假设您在域内使用 Windows,因此最好使用的工具是 PowerShell。

    获取在 Active Directory 域中发布的打印机列表的文章 有这个 PowerShell 命令行来获取域中的打印服务器和打印机的列表:

    Get-ADObject -LDAPFilter "(objectCategory=printQueue)" -Properties cn, drivername, location, printername, portname, servername | select portname, cn, drivername, location, printername, servername | Format-Table -Property * -AutoSize | Out-String -Width 4096 | Out-File C:\wisefaq\printerlist.txt
    

    另一篇有用的文章是 使用 WMI 从计算机获取打印机名称、IP 地址和驱动程序, 其中包含一个 PowerShell 脚本,该脚本需要输入域中的打印机服务器列表:

    $ReportFileName = "C:\printerreport.csv" 
    $PrintServersList="C:\PrintServersList.txt"         
    $servers =  Get-Content -Path $PrintServersList 
    $allprinters = @()  
    foreach( $server in $servers ){ 
      Write-Host "checking $server ..." 
      $printers = $null 
      $printers = Get-WmiObject -class Win32_Printer -computername $server | 
      select Name,Shared,ShareName,Local, DriverName, PortName,
      @{n="PrinterIp";e={(((gwmi win32_tcpipprinterport -ComputerName $server -filter "name='$($_.PortName)'") | select HostAddress).HostAddress)}},
      @{n='PrintServer';e={$_.SystemName}}, Location,Comment,SpoolEnabled,Published,
      @{n='Trustee Name';e={(($_.GetSecurityDescriptor()).Descriptor.DACL.Trustee.Name | Select-Object -Unique) -join ','}}
      @{n='Trustee SID';e={($_.GetSecurityDescriptor()).Descriptor.DACL.Trustee.SIDString -join ','}}
      $allprinters += $printers  
    }     
    Write-Host "exporting to printers.csv" 
    $allprinters | Export-CSV -Path $ReportFileName -NoTypeInformation -Force -Encoding UTF8
    Write-Host "Done!"
    

    要识别 GPO 和打印机,请参阅 使用 PowerShell 获取所有 GPO 部署的打印机一文。脚本本身太长了,但我还是在这里列出来。您可以在文章中找到有关其使用的说明。

    获取 GPOPrinters.ps1

    <#
    .SYNOPSIS     
    The script finds all shared printers deployed with GPO (both deployed printers GPP.) in your domain. 
    .NOTES     
               File Name: Get-GPOPrinters.ps1     
               Author   : Johan Dahlbom, johan[at]dahlbom.eu     
               The script are provided “AS IS” with no guarantees, no warranties, and it confer no rights. 
               Blog     : 365lab.net
    #>
    #Import the required module GroupPolicy
    try
    {
    Import-Module GroupPolicy -ErrorAction Stop
    }
    catch
    {
    throw "Module GroupPolicy not Installed"
    }
    $GPO = Get-GPO -All
    
    foreach ($Policy in $GPO){
    
            $GPOID = $Policy.Id
            $GPODom = $Policy.DomainName
            $GPODisp = $Policy.DisplayName
            $PrefPath = "\\$($GPODom)\SYSVOL\$($GPODom)\Policies\{$($GPOID)}\User\Preferences"
    
                #Get GP Preferences Printers
                $XMLPath = "$PrefPath\Printers\Printers.xml"
                if (Test-Path "$XMLPath")
                {
                     [xml]$PrintXML = Get-Content "$XMLPath"
    
                            foreach ( $Printer in $PrintXML.Printers.SharedPrinter )
    
                                {New-Object PSObject -Property @{
                                    GPOName = $GPODisp
                                    PrinterPath = $printer.Properties.Path
                                    PrinterAction = $printer.Properties.action.Replace("U","Update").Replace("C","Create").Replace("D","Delete").Replace("R","Replace")
                                    PrinterDefault = $printer.Properties.default.Replace("0","False").Replace("1","True")
                                    FilterGroup = $printer.Filters.FilterGroup.Name
                                    GPOType = "Group Policy Preferences"
                                }
                            }
               }
               #Get Deployed Printers
               [xml]$xml = Get-GPOReport -Id $GPOID -ReportType xml
               $User = $xml.DocumentElement.User.ExtensionData.extension.printerconnection
               $Computer = $xml.DocumentElement.computer.ExtensionData.extension.printerconnection
    
                    foreach ($U in $User){
                        if ($U){
    
                                New-Object PSObject -Property @{
                                    GPOName = $GPODisp
                                    PrinterPath = $u.Path
                                    GPOType = "GPO Deployed Printer - User"
                                }
                        }
    
                    }
    
                    foreach ($C in $Computer){
                        if ($c){
    
                                New-Object PSObject -Property @{
                                    GPOName = $GPODisp
                                    PrinterPath = $c.Path
                                    GPOType = "GPO Deployed Printer - Computer"
                                }
                        }
    
                    }
    }
    
    • 2

相关问题

  • Windows 10 中的对象访问和文件(系统)访问有什么区别?

  • Windows 10 中的 PrintWorkflow_<6-hex-digits> 服务是什么?

  • 我可以将只有 RJ11 插座的打印机连接到路由器的 RJ45 以太网电缆吗?

  • 如何将共享网络设备与其他用户隔离

  • 佳能 MP450 墨水吸收器更换

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve