#Requires -RunAsAdministrator $PrinterPath = "\\EA1196SV\EA - Follow Me" Write-Host "Installing printer: $PrinterPath" -ForegroundColor Cyan try { # Make sure Print Spooler is running $spooler = Get-Service -Name Spooler -ErrorAction Stop if ($spooler.Status -ne 'Running') { Start-Service -Name Spooler } # Check whether printer is already installed $existingPrinter = Get-Printer -ErrorAction SilentlyContinue | Where-Object { $_.Name -eq $PrinterPath } if ($existingPrinter) { Write-Host "Printer is already installed." -ForegroundColor Yellow exit 0 } # Add shared printer Add-Printer -ConnectionName $PrinterPath -ErrorAction Stop Write-Host "Printer installed successfully." -ForegroundColor Green } catch { Write-Host "Failed to install printer." -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor Red exit 1 }