एक दूरस्थ कंप्यूटर से नेटवर्क प्रिंटर प्राप्त करें


4

मैं इसका उपयोग दूरस्थ कंप्यूटर पर प्रिंटर की सूची प्राप्त करने के प्रयास में कर रहा हूं:

Get-WmiObject win32_printer -ComputerName "$oldPcName" 

समस्या यह है कि मुझे केवल स्थानीय प्रिंटर ही मिलते हैं, न कि प्रिंटर जो कंप्यूटर से जुड़े प्रिंट सर्वर से हैं। मुझे नेटवर्क प्रिंटर की सूची कैसे मिल सकती है?

मेरा लक्ष्य दूरस्थ कंप्यूटर पर नेटवर्क प्रिंटरों की एक सूची प्राप्त करना है, उन्हें निकालना है और एक अलग प्रिंट सर्वर से विभिन्न प्रिंटर जोड़ना है।

धन्यवाद

जवाबों:


0
#--------------------------
#Set Execution Of PSScripts
#--------------------------

Set-ExecutionPolicy Unrestricted -force

#------------
#Turn Off UAC
#------------

New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force

#------------------------------
#Enter The Name Of The Computer
#------------------------------

$comp = "Name of computer"

#or if you wish to be prompted for the computer name

$comp = Read-host 'Enter the name of the computer?'

#---------------------------------------
#Starts WinRM Service On Remote Computer
#---------------------------------------

Import-Module Remote_PSRemoting -force
Set-WinRMListener -computername $comp
Restart-WinRM -computername $comp
Set-WinRMStartUp -computername $comp

Start-Sleep -Seconds 60

#----------------------------------------------
#Establish a PSSession With The Remote Computer
#----------------------------------------------

New-PSSession $comp | Enter-PSSession

#All of the replace commands are used to strip the extra characters and just #give a \\server\printer path return
#-----------------------
#Gets A List Of Printers
#-----------------------

$printers1 = Get-childitem -Path HKCU:\printers\connections | select name
$printers2 = $printers1 -replace '.*,,'
$printers3 = $printers2 -replace ',','\'
$printers = $printers3 -replace '}', ''

------------------------------------------------------
#To Replace The Old Print Server Name With The New One
------------------------------------------------------

$newprinters = $printers -replace 'oldserver','\\newserver'

#--------------------
#Gets Default Printer
#--------------------

$default = Get-itemproperty -Path "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows" | select device
$default1 = $default -replace '.*='
$default2 = $default1 -replace '()'
$default3 = $default2 -replace ',winspool'
$defaultprinter = $default3 -replace ',.*'

------------------------------------------------------
#To Replace The Old Print Server Name With The New One
------------------------------------------------------

$newdefaultprinter = $defaultprinter -replace 'oldserver','\\newserver'

#------------------------
#Deletes The Old Printers
#------------------------

Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}

#----------------------------------------
#Exits PSSession With The Remote Computer
#----------------------------------------

Exit-PSSession

#-----------
#Turn UAC On
#-----------

#Value = 0 through 4 depending on the level of UAC

New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 2 -Force

#------------------------------------
#Turn Off Execution Policy Of Scripts
#------------------------------------

Set-ExecutionPolicy undefined -Force

#####This is as far as I could get with it. I always turn off UAC and Enable Scripts in the beginning and turn them back on ant the end.  The summary of this script will give you the new network Printer paths and the users default printers.  It also deletes the users old network printers. With powershell versions before windows 8 and server 2012, you would have to create a logon script to add the new printers and mark the default printer using WMI commands.  Use could also use a csv file with a list of computer names as an input if you wish to run this command on multiple computers.  It would look something like...


$csv = Import-csv -Path pathofcsvfile
foreach ($line in $csv) {

#With a bracket at the end to run through each computer in the list...

यह विंडोज के नए संस्करणों के साथ बहुत आसान है क्योंकि उनके पास Get-printerscmdlet है ...

उम्मीद है कि आप शुरू कर सकते हैं ... मैं किसी को इस स्क्रिप्ट को खत्म करना पसंद करूंगा क्योंकि मुझे ऐसा करने के लिए काम पर समय नहीं मिला है ...


मैं उल्लेख करना भूल गया, आपको गैलरी से psremoting मॉड्यूल को डाउनलोड करने की आवश्यकता है ।technet.microsoft.com/scriptcenter/… और c: \ windwows \ system32 \ windowsPowerShell \ v1.0 \ Modul फ़ोल्डर में आपके द्वारा चलाए जा रहे मशीन पर रखें। से स्क्रिप्ट।
Ninjamonkeysensai

उल्लिखित फ़ोल्डर में मॉड्यूल जोड़े, यह त्रुटि प्राप्त करें: निर्दिष्ट मॉड्यूल 'Remote_PSRemoting' लोड नहीं किया गया था क्योंकि किसी भी मॉड्यूल निर्देशिका में कोई मान्य मॉड्यूल फ़ाइल नहीं मिली थी।
वेन इन याक

1
"सेट-एक्ज़ीक्यूशनपॉलिअस अनरिज़र्व्ड" यह बेहद खराब पॉवरशेल प्रैक्टिस है - आपको इसके बजाय "रिमोटसाइनड" का उपयोग करना चाहिए
इंटरलिंकड

0

विंडोज 7 पर

नेटवर्क प्रिंटर देखने के लिए, मैं रजिस्ट्री पढ़ता हूं

Function InstalledPrinters ($ComputerName)
    {
    Invoke-Command -ComputerName $ComputerName -ScriptBlock {
        $InstalledPrinters = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Connections"
        $InstalledPrinters | Add-Member -Name 'PrinterName' -MemberType NoteProperty -Value ""
        Foreach ($InstalledPrinter in $InstalledPrinters) {$InstalledPrinter.PrinterName = $InstalledPrinter.GetValue("Printer").split("\")[3]}
        Return $InstalledPrinters | sort PrinterName | select PSComputerName, PrinterName
        }
    } 

नेटवर्क प्रिंटर निकालने के लिए:

rundll32.exe PRINTUI.DLL PrintUIEntry /gd /c\\$ComputerName /n\\$PrintServer\$PrinterName Gw /q

नेटवर्क प्रिंटर स्थापित करने के लिए:

rundll32.exe PRINTUI.DLL PrintUIEntry /ga /c\\$ComputerName /n\\$PrintServer\$PrinterName Gw /q


0

हम्म। रास्पबेरी पाई के साथ ऐसा करने का एक तरीका हो सकता है। आप रास्पबेरी पाई को प्रिंटर से कनेक्ट करते हैं और वाईफाई के लिए, आप ssh के लिए पोर्ट अग्रेषण सक्षम करते हैं या रास्पबेरी पाई तक पहुंचने के लिए वीएनसी दर्शक का उपयोग करते हैं। VNC के उपयोग से, आप नेटवर्क पर रास्पबेरी पाई में फाइल ट्रांसफर कर सकते हैं। फिर आप रास्पबेरी पाई को उन फ़ाइलों को प्रिंट करना चाहते हैं जो आप चाहते हैं।

इसका सबसे अच्छा सीधा विचार नहीं है, लेकिन मुझे पता ही एकमात्र तरीका है। रास्पबेरी पाई भी बहुत सस्ती है। नवीनतम मॉडल की कीमत केवल £ 35 है। यदि आप इस तरह से करना चाहते हैं, तो आपको एक वीएनसी खाता बनाना होगा, फिर अपनी रास्पबेरी पाई को अपनी वीएनसी पता पुस्तिका में जोड़ना होगा। ऐसा करने के लिए आपको रास्पियन डेस्कटॉप होना चाहिए, और रास्पबेरी पाई पर अपने वीएनसी खाते में लॉगिन करना होगा।

रास्पबेरी पाई स्पेक्स: 1GB DDR2 रैम, 1.4GHZ आर्म प्रोसेसर, GPIO पिन


यह नहीं देखा कि यह पोस्ट 3 साल पुरानी है ... क्षमा करें यदि मैंने इसे टकरा दिया।
रॉयल नोब
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.