Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $usb = (get-wmiobject win32_logicaldisk | Where-Object{$_.Volumename -match "SysAdmin-Data"}).DeviceID
  2.  
  3. if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
  4.     if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
  5.     $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
  6.     Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
  7.     Exit
  8.     }
  9. }
  10.  
  11.  
  12. Write-Output "Gdzie leci sprzet?"
  13. $Opt1 = New-Object System.Management.Automation.Host.ChoiceDescription "&Wroclaw","Wroclawska maszyna"
  14. $Opt2 = New-Object System.Management.Automation.Host.ChoiceDescription "&Bialystok", "Bialostocka maszyna"
  15. $options = [System.Management.Automation.Host.ChoiceDescription[]]($Opt1, $Opt2)
  16. $result = $host.ui.PromptForChoice($title, $message, $options, 0)
  17.  
  18. $printerNameKonica = "KONICA Hieronimus"
  19. $printerDriverKonica = "KONICA MINOLTA Universal PCL"
  20. $printerNameXeroxWro = "Xerox Hieronimus"
  21. $printerNameXeroxBialy = "Xerox Handlowa 6G"
  22. $printerDriverXerox = "Xerox WorkCentre 3225"
  23.  
  24. $XeroxInf = "$usb\install\Drivers\XeroxLatest\*.inf"
  25. $KonicaInf = "$usb\install\Drivers\KonicaLatest\*.inf"
  26. $drivers = Get-WindowsDriver -online  | Where-Object {$_.ClassName -eq "Printer" -and ($_.ProviderName -eq "Xerox" -or $_.ProviderName -eq "KONICA MINOLTA")}
  27.  
  28. $listKonica = Get-Content -Path $KonicaInf | where {$_ -match "DriverVer=" }
  29. $DriverVerKonica = $listKonica.Split(",")[1]
  30.  
  31. $listXerox = Get-Content -Path $XeroxInf | where {$_ -match "DriverVer=" }
  32. $DriverVerXerox = $listXerox.Split(",")[1]
  33.  
  34. #Write-Output "Stopping Spooler Service..."
  35. #Get-Service -Name spooler | Stop-Service                                  
  36.  
  37. foreach($driver in $drivers)
  38. {                        
  39.     if (($driver.ProviderName -contains "KONICA MINOLTA") -and ([System.Version]$DriverVerKonica -gt [System.Version]$driver.Version) -and ($result -eq 0))
  40.        {
  41.        Write-Output $result+"KONICA GT"
  42. <#           pnputil /delete-driver $driver.Driver
  43.            Remove-PrinterDriver -name "Konica*"
  44.            Remove-Printer -Name "Konica*"
  45.            Remove-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
  46.            Start-Sleep -s 10
  47.            pnputil.exe /add-driver $KonicaInf /install
  48.            Add-PrinterDriver -Name $printerDriverKonica
  49.            Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
  50.            Add-Printer -Name $printerNameKonica -PortName IP_10.98.40.10 -DriverName $printerDriverKonica
  51. #>
  52.        }
  53.    elseif (($driver.ProviderName -contains "Xerox") -and ([System.Version]$DriverVerXerox -gt [System.Version]$driver.Version))
  54.         {
  55.           if ($result -eq 0)
  56.              {
  57.              Write-Output $result+"XEROX GT"
  58. <#
  59.                 pnputil /delete-driver $driver.Driver
  60.                 Remove-PrinterDriver -name "Xerox*"
  61.                 Remove-Printer -Name "Xerox*"
  62.                 Remove-PrinterPort -Name "IP_10.98.40.11"
  63.                 Start-Sleep -s 10
  64.                 pnputil.exe /add-driver $XeroxInf /install
  65.                 Add-PrinterDriver -Name $printerDriverXerox
  66.                 Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
  67.                 Add-Printer -Name $printerNameXeroxWro -PortName IP_10.98.40.10 -DriverName $printerDriverXerox
  68. #>
  69.              }
  70.           if ($result -eq 1)
  71.              {
  72.              Write-Output $result+"XEROX GT BIALY"
  73. <#
  74.                 pnputil /delete-driver $driver.Driver
  75.                 Remove-PrinterDriver -name "Xerox*"
  76.                 Remove-Printer -Name "Xerox*"
  77.                 Remove-PrinterPort -Name "IP_10.99.40.10"
  78.                 Start-Sleep -s 10
  79.                 pnputil.exe /add-driver $XeroxInf /install
  80.                 Add-PrinterDriver -Name $printerDriverXerox
  81.                 Add-PrinterPort -Name "IP_10.99.40.10" -PrinterHostAddress "10.99.40.10"
  82.                 Add-Printer -Name $printerNameXeroxBialy -PortName IP_10.99.40.10 -DriverName $printerNameXerox
  83. #>    
  84.              }
  85.         }
  86.     elseif ($driver.ProviderName -notmatch ("KONICA MINOLTA" -or "Xerox"))
  87.         {
  88.           if ($result -eq 0)
  89.              {
  90.              Write-Output $result+"KONICA & XEROX WRO MISSING AND NOT MATCH"
  91.              <#
  92.                 pnputil.exe /add-driver $XeroxInf /install
  93.                 Add-PrinterDriver -Name $printerDriverXerox
  94.                 Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
  95.                 Add-Printer -Name $printerNameXeroxWro -PortName IP_10.98.40.10 -DriverName $printerDriverXerox
  96.                 pnputil.exe /add-driver $KonicaInf /install
  97.                 Add-PrinterDriver -Name $printerDriverKonica
  98.                 Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
  99.                 Add-Printer -Name $printerNameKonica -PortName IP_10.98.40.10 -DriverName $printerDriverKonica
  100.                 #>
  101.              }
  102.           elseif ($result -eq 1)
  103.             {  
  104.             Write-Output $result+"XEROX BIALY MISSING"
  105.             <#  
  106.                 pnputil.exe /add-driver $XeroxInf /install
  107.                 Add-PrinterDriver -Name $printerDriverXerox
  108.                 Add-PrinterPort -Name "IP_10.99.40.10" -PrinterHostAddress "10.99.40.10"
  109.                 Add-Printer -Name $printerNameXeroxBialy -PortName IP_10.99.40.10 -DriverName $printerNameXerox  
  110.                 #>                  
  111.             }
  112.         }      
  113. }
  114.  
  115. Read-Host "WPISZ COS KURWA"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement