# Generated by ImpTune — Printer: Imprimante Levallois # Install command: powershell.exe -NoProfile -ExecutionPolicy Bypass -File "install.ps1" # # This script installs the printer "Imprimante Levallois" via Intune Win32 app deployment. # It must be launched with -File (not -Command) so $PSScriptRoot is populated. # --------------------------------------------------------------------------- # WOW64 Guard — relaunch in 64-bit PowerShell if running under WOW64 (Intune # runs Win32 app scripts in a 32-bit process; pnputil is 64-bit only). # This block MUST be the first executable code in the script. # --------------------------------------------------------------------------- if ($env:PROCESSOR_ARCHITECTURE -eq "x86" -and $env:PROCESSOR_ARCHITEW6432) { $ps64 = "$env:WINDIR\SysNative\WindowsPowerShell\v1.0\powershell.exe" & $ps64 -NoProfile -ExecutionPolicy Bypass -File "$PSCommandPath" @args exit $LASTEXITCODE } # --------------------------------------------------------------------------- # SYSTEM vs User context detection + UAC self-elevation # Skip elevation when already running as SYSTEM (Intune MDM context). # --------------------------------------------------------------------------- $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $isSystem = $id.IsSystem $isAdmin = ([System.Security.Principal.WindowsPrincipal]$id).IsInRole( [System.Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isSystem -and -not $isAdmin) { Start-Process powershell.exe ` -Verb Runas ` -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" ` -Wait exit $LASTEXITCODE } # --------------------------------------------------------------------------- # pnputil two-step driver staging # Step 1: Stage INF + all associated files into Windows Driver Store # Step 2: Install the named driver from the Driver Store # --------------------------------------------------------------------------- pnputil.exe /add-driver "$PSScriptRoot\drivers\UNIV_5.1076.4.0_PCL6_x64_Driver.inf/x3UNIVX.inf" /install Add-PrinterDriver -Name "Xerox GPD PCL6 V5.1076.4.0" # --------------------------------------------------------------------------- # Idempotent port creation # --------------------------------------------------------------------------- if (-not (Get-PrinterPort -Name "IP_10_123_1_5" -ErrorAction SilentlyContinue)) { Add-PrinterPort -Name "IP_10_123_1_5" -PrinterHostAddress "10.123.1.5" } # --------------------------------------------------------------------------- # Idempotent printer creation # --------------------------------------------------------------------------- if (-not (Get-Printer -Name "Imprimante Levallois" -ErrorAction SilentlyContinue)) { Add-Printer -Name "Imprimante Levallois" ` -PortName "IP_10_123_1_5" ` -DriverName "Xerox GPD PCL6 V5.1076.4.0" } # --------------------------------------------------------------------------- # Configure print settings # --------------------------------------------------------------------------- Set-PrintConfiguration -PrinterName "Imprimante Levallois" ` -DuplexingMode OneSided ` -Color $false ` -PaperSize A4 ` -Collate $true