Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $usb = (get-wmiobject win32_logicaldisk | Where-Object{$_.Volumename -match "SysAdmin-Data"}).DeviceID
- if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
- if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
- $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
- Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
- Exit
- }
- }
- Write-Output "Gdzie leci sprzet?"
- $Opt1 = New-Object System.Management.Automation.Host.ChoiceDescription "&Wroclaw","Wroclawska maszyna"
- $Opt2 = New-Object System.Management.Automation.Host.ChoiceDescription "&Bialystok", "Bialostocka maszyna"
- $options = [System.Management.Automation.Host.ChoiceDescription[]]($Opt1, $Opt2)
- $result = $host.ui.PromptForChoice($title, $message, $options, 0)
- $printerNameKonica = "KONICA Hieronimus"
- $printerDriverKonica = "KONICA MINOLTA Universal PCL"
- $printerNameXeroxWro = "Xerox Hieronimus"
- $printerNameXeroxBialy = "Xerox Handlowa 6G"
- $printerDriverXerox = "Xerox WorkCentre 3225"
- $XeroxInf = "$usb\install\Drivers\XeroxLatest\*.inf"
- $KonicaInf = "$usb\install\Drivers\KonicaLatest\*.inf"
- $drivers = Get-WindowsDriver -online | Where-Object {$_.ClassName -eq "Printer" -and ($_.ProviderName -eq "Xerox" -or $_.ProviderName -eq "KONICA MINOLTA")}
- $listKonica = Get-Content -Path $KonicaInf | where {$_ -match "DriverVer=" }
- $DriverVerKonica = $listKonica.Split(",")[1]
- $listXerox = Get-Content -Path $XeroxInf | where {$_ -match "DriverVer=" }
- $DriverVerXerox = $listXerox.Split(",")[1]
- #Write-Output "Stopping Spooler Service..."
- #Get-Service -Name spooler | Stop-Service
- foreach($driver in $drivers)
- {
- if (($driver.ProviderName -contains "KONICA MINOLTA") -and ([System.Version]$DriverVerKonica -gt [System.Version]$driver.Version) -and ($result -eq 0))
- {
- Write-Output $result+"KONICA GT"
- <# pnputil /delete-driver $driver.Driver
- Remove-PrinterDriver -name "Konica*"
- Remove-Printer -Name "Konica*"
- Remove-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
- Start-Sleep -s 10
- pnputil.exe /add-driver $KonicaInf /install
- Add-PrinterDriver -Name $printerDriverKonica
- Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
- Add-Printer -Name $printerNameKonica -PortName IP_10.98.40.10 -DriverName $printerDriverKonica
- #>
- }
- elseif (($driver.ProviderName -contains "Xerox") -and ([System.Version]$DriverVerXerox -gt [System.Version]$driver.Version))
- {
- if ($result -eq 0)
- {
- Write-Output $result+"XEROX GT"
- <#
- pnputil /delete-driver $driver.Driver
- Remove-PrinterDriver -name "Xerox*"
- Remove-Printer -Name "Xerox*"
- Remove-PrinterPort -Name "IP_10.98.40.11"
- Start-Sleep -s 10
- pnputil.exe /add-driver $XeroxInf /install
- Add-PrinterDriver -Name $printerDriverXerox
- Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
- Add-Printer -Name $printerNameXeroxWro -PortName IP_10.98.40.10 -DriverName $printerDriverXerox
- #>
- }
- if ($result -eq 1)
- {
- Write-Output $result+"XEROX GT BIALY"
- <#
- pnputil /delete-driver $driver.Driver
- Remove-PrinterDriver -name "Xerox*"
- Remove-Printer -Name "Xerox*"
- Remove-PrinterPort -Name "IP_10.99.40.10"
- Start-Sleep -s 10
- pnputil.exe /add-driver $XeroxInf /install
- Add-PrinterDriver -Name $printerDriverXerox
- Add-PrinterPort -Name "IP_10.99.40.10" -PrinterHostAddress "10.99.40.10"
- Add-Printer -Name $printerNameXeroxBialy -PortName IP_10.99.40.10 -DriverName $printerNameXerox
- #>
- }
- }
- elseif ($driver.ProviderName -notmatch ("KONICA MINOLTA" -or "Xerox"))
- {
- if ($result -eq 0)
- {
- Write-Output $result+"KONICA & XEROX WRO MISSING AND NOT MATCH"
- <#
- pnputil.exe /add-driver $XeroxInf /install
- Add-PrinterDriver -Name $printerDriverXerox
- Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
- Add-Printer -Name $printerNameXeroxWro -PortName IP_10.98.40.10 -DriverName $printerDriverXerox
- pnputil.exe /add-driver $KonicaInf /install
- Add-PrinterDriver -Name $printerDriverKonica
- Add-PrinterPort -Name "IP_10.98.40.10" -PrinterHostAddress "10.98.40.10"
- Add-Printer -Name $printerNameKonica -PortName IP_10.98.40.10 -DriverName $printerDriverKonica
- #>
- }
- elseif ($result -eq 1)
- {
- Write-Output $result+"XEROX BIALY MISSING"
- <#
- pnputil.exe /add-driver $XeroxInf /install
- Add-PrinterDriver -Name $printerDriverXerox
- Add-PrinterPort -Name "IP_10.99.40.10" -PrinterHostAddress "10.99.40.10"
- Add-Printer -Name $printerNameXeroxBialy -PortName IP_10.99.40.10 -DriverName $printerNameXerox
- #>
- }
- }
- }
- Read-Host "WPISZ COS KURWA"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement