#Requires -Version 5.1 # ============================================================================= # MEPRO IT AUTO-DEPLOY SCRIPT # PT Meprofarm - Corporate IT Deployment Automation # Author : IT Department # Version : 1.0 # Deskripsi: Script otomatisasi deployment software dan konfigurasi Windows # untuk lingkungan kerja PT Meprofarm. # ============================================================================= # --- Global: Matikan progress bar bawaan PowerShell & Invoke-WebRequest --- $ProgressPreference = 'SilentlyContinue' # Jalankan sebagai Administrator, jika belum, restart dengan elevasi if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Warning "Script membutuhkan hak Administrator. Melakukan elevasi..." Start-Process -FilePath "powershell.exe" ` -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" ` -Verb RunAs exit } # ============================================================================= # REGION: HELPER FUNCTIONS # ============================================================================= function Write-Header { # Fungsi untuk menampilkan header ASCII art utama Clear-Host $banner = @" ███╗ ███╗███████╗██████╗ ██████╗ ██████╗ ██╗████████╗ ████╗ ████║██╔════╝██╔══██╗██╔══██╗██╔═══██╗ ██║╚══██╔══╝ ██╔████╔██║█████╗ ██████╔╝██████╔╝██║ ██║ ██║ ██║ ██║╚██╔╝██║██╔══╝ ██╔═══╝ ██╔══██╗██║ ██║ ██║ ██║ ██║ ╚═╝ ██║███████╗██║ ██║ ██║╚██████╔╝ ██║ ██║ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ "@ Write-Host $banner -ForegroundColor Cyan Write-Host ("=" * 70) -ForegroundColor DarkCyan Write-Host " AUTO-DEPLOY SYSTEM | PT MEPROFARM | IT DEPARTMENT" -ForegroundColor Yellow Write-Host ("=" * 70) -ForegroundColor DarkCyan Write-Host "" } function Write-Step { # Fungsi untuk menampilkan langkah proses dengan format konsisten param([string]$Message) Write-Host "[>>] " -ForegroundColor DarkYellow -NoNewline Write-Host $Message -ForegroundColor White } function Write-OK { # Fungsi untuk menampilkan status sukses param([string]$Message) Write-Host " [OK] " -ForegroundColor Green -NoNewline Write-Host $Message -ForegroundColor Gray } function Write-Fail { # Fungsi untuk menampilkan status gagal param([string]$Message) Write-Host " [!!] " -ForegroundColor Red -NoNewline Write-Host $Message -ForegroundColor DarkRed } function Write-Info { # Fungsi untuk menampilkan informasi umum param([string]$Message) Write-Host " [--] " -ForegroundColor Cyan -NoNewline Write-Host $Message -ForegroundColor DarkGray } function Write-SectionBanner { # Fungsi untuk menampilkan pemisah section param([string]$Title) Write-Host "" Write-Host ("─" * 70) -ForegroundColor DarkGray Write-Host " ◆ $Title" -ForegroundColor Magenta Write-Host ("─" * 70) -ForegroundColor DarkGray Write-Host "" } function Pause-ForUser { Write-Host "" Write-Host " Tekan [ENTER] untuk melanjutkan..." -ForegroundColor DarkGray $null = Read-Host } # ============================================================================= # REGION 1: WINGET BOOTSTRAPPER # Cek apakah winget tersedia; jika tidak, install otomatis dari GitHub Release # ============================================================================= function Invoke-WingetBootstrap { Write-SectionBanner "WINGET BOOTSTRAPPER — Prerequisite Check" # Cek apakah winget sudah tersedia di sistem $wingetCmd = Get-Command "winget" -ErrorAction SilentlyContinue if ($wingetCmd) { Write-OK "Winget ditemukan: $($wingetCmd.Source)" return } Write-Step "Winget tidak ditemukan. Memulai proses instalasi otomatis..." try { # URL resmi Microsoft dari GitHub untuk App Installer (winget) $wingetUrl = "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" $wingetInstaller = "$env:TEMP\WingetInstaller.msixbundle" Write-Info "Mengunduh App Installer dari GitHub Microsoft..." Invoke-WebRequest -Uri $wingetUrl -OutFile $wingetInstaller -UseBasicParsing -ErrorAction Stop Write-Info "Menginstal App Installer (Winget)..." Add-AppxPackage -Path $wingetInstaller -ErrorAction Stop Write-OK "Winget berhasil diinstal." Remove-Item -Path $wingetInstaller -Force -ErrorAction SilentlyContinue } catch { Write-Fail "Gagal menginstal Winget secara otomatis." Write-Fail "Detail error: $_" Write-Host "" Write-Host " Silakan install 'App Installer' dari Microsoft Store secara manual," -ForegroundColor Yellow Write-Host " lalu jalankan script ini kembali." -ForegroundColor Yellow Pause-ForUser exit 1 } } # ============================================================================= # REGION 2: SOFTWARE INSTALLATION ENGINE # Fungsi untuk install per-aplikasi via Winget dengan error handling # ============================================================================= function Install-ViaWinget { param( [string]$PackageId, [string]$DisplayName, [string]$Source = "winget" # bisa "winget" atau "msstore" ) Write-Step "Menginstal: $DisplayName ($PackageId)..." try { # Jalankan winget install dengan flag silent dan tanpa interaksi $result = winget install --id $PackageId ` --source $Source ` --silent ` --accept-package-agreements ` --accept-source-agreements ` --disable-interactivity ` 2>&1 # Cek exit code dari winget if ($LASTEXITCODE -eq 0 -or $LASTEXITCODE -eq -1978335189) { # Exit code -1978335189 (0x8A150011) = sudah terinstal, dianggap OK Write-OK "$DisplayName — Selesai." } else { Write-Fail "$DisplayName — Winget keluar dengan kode: $LASTEXITCODE" } } catch { Write-Fail "Exception saat menginstal $DisplayName : $_" } } function Install-SparkMessenger { # Fungsi khusus untuk instalasi Spark Messenger 2.7.7 dari server internal Write-Step "Menginstal: Spark Messenger 2.7.7 (Internal)..." $sparkUrl = "https://nekahost.com/installer/spark_2_7_7.exe" $sparkInstaller = "$env:TEMP\spark_setup.exe" try { # Unduh installer Spark dari server internal Meprofarm Write-Info "Mengunduh Spark Messenger dari server internal..." Invoke-WebRequest -Uri $sparkUrl -OutFile $sparkInstaller -UseBasicParsing -ErrorAction Stop Write-Info "Menjalankan silent install Spark Messenger..." # Argument "-q" = quiet/silent mode $proc = Start-Process -FilePath $sparkInstaller ` -ArgumentList "-q" ` -Wait ` -PassThru ` -ErrorAction Stop if ($proc.ExitCode -eq 0 -or $proc.ExitCode -eq 1) { Write-OK "Spark Messenger 2.7.7 — Selesai." } else { Write-Fail "Spark Messenger installer keluar dengan kode: $($proc.ExitCode)" } } catch { Write-Fail "Gagal menginstal Spark Messenger: $_" } finally { # Hapus file installer sementara if (Test-Path $sparkInstaller) { Remove-Item -Path $sparkInstaller -Force -ErrorAction SilentlyContinue Write-Info "File installer sementara telah dihapus." } } } # ============================================================================= # REGION: KATEGORI APLIKASI # Definisi daftar aplikasi per-kategori # ============================================================================= function Install-Category-Browser { Write-SectionBanner "KATEGORI: BROWSER" Install-ViaWinget -PackageId "Google.Chrome" -DisplayName "Google Chrome" Install-ViaWinget -PackageId "Mozilla.Firefox" -DisplayName "Mozilla Firefox" } function Install-Category-Office { Write-SectionBanner "KATEGORI: OFFICE SUITE" Install-ViaWinget -PackageId "Apache.OpenOffice" -DisplayName "Apache OpenOffice" Install-ViaWinget -PackageId "Kingsoft.WPSOffice" -DisplayName "Kingsoft WPS Office" } function Install-Category-Utility { Write-SectionBanner "KATEGORI: UTILITY" Install-ViaWinget -PackageId "7zip.7zip" -DisplayName "7-Zip" Install-ViaWinget -PackageId "Adobe.Acrobat.Reader.64-bit" -DisplayName "Adobe Acrobat Reader DC (64-bit)" Install-ViaWinget -PackageId "Mozilla.Thunderbird" -DisplayName "Mozilla Thunderbird" } function Install-Category-Security { Write-SectionBanner "KATEGORI: SECURITY (Microsoft Store)" # AVG AntiVirus Free menggunakan ID Microsoft Store Install-ViaWinget -PackageId "XP8BX2DWV7TF50" -DisplayName "AVG AntiVirus Free" -Source "msstore" } function Install-Category-Internal { Write-SectionBanner "KATEGORI: APLIKASI INTERNAL MEPROFARM" Install-SparkMessenger } # ============================================================================= # REGION 3: WINDOWS TWEAKS ENGINE # Konfigurasi fitur Windows dan Visual Effects via Registry & DISM # ============================================================================= function Invoke-WindowsTweaks { Write-SectionBanner "WINDOWS TWEAKS & KONFIGURASI SISTEM" # ── 1. Aktifkan SMB 1.0 Client (untuk kompatibilitas legacy file sharing) ── Write-Step "Mengaktifkan SMB 1.0 Client..." try { Enable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol-Client" ` -NoRestart -ErrorAction Stop | Out-Null Write-OK "SMB 1.0 Client — Diaktifkan." } catch { Write-Fail "Gagal mengaktifkan SMB 1.0 Client: $_" } # ── 2. Install WMIC via Windows Capability ── Write-Step "Menginstal WMIC (Windows Management Instrumentation Command-line)..." try { Add-WindowsCapability -Online -Name "WMIC~~~~" -ErrorAction Stop | Out-Null Write-OK "WMIC — Berhasil diinstal." } catch { # WMIC mungkin sudah terinstal, tangani gracefully if ($_.Exception.Message -match "already installed" -or $LASTEXITCODE -eq 0) { Write-OK "WMIC — Sudah terinstal sebelumnya." } else { Write-Fail "Gagal menginstal WMIC: $_" } } # ── 3. Set Wallpaper ke Default Windows Dark Theme ── Write-Step "Mengatur wallpaper ke tema gelap default Windows..." try { # Path standar wallpaper Windows default $wallpaperPath = "$env:SystemRoot\Web\Wallpaper\Windows\img0.jpg" if (Test-Path $wallpaperPath) { # Update registry agar wallpaper tercatat Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" ` -Name "Wallpaper" -Value $wallpaperPath -ErrorAction Stop # Panggil SystemParametersInfo via P/Invoke untuk apply langsung tanpa restart Add-Type @" using System; using System.Runtime.InteropServices; public class WallpaperHelper { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); } "@ -ErrorAction SilentlyContinue # SPI_SETDESKWALLPAPER = 20, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE = 3 [WallpaperHelper]::SystemParametersInfo(20, 0, $wallpaperPath, 3) | Out-Null Write-OK "Wallpaper — Diatur ke: $wallpaperPath" } else { Write-Fail "File wallpaper tidak ditemukan: $wallpaperPath" } } catch { Write-Fail "Gagal mengatur wallpaper: $_" } # ── 4. Performance Tweaks — Visual Effects Custom ── Write-Step "Menerapkan Visual Effects Custom (Best Performance + exceptions)..." $visualEffectsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" $desktopPath = "HKCU:\Control Panel\Desktop" $advancedPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" try { # Pastikan key registry ada if (-not (Test-Path $visualEffectsPath)) { New-Item -Path $visualEffectsPath -Force | Out-Null } # VisualFXSetting = 3 → Custom Set-ItemProperty -Path $visualEffectsPath -Name "VisualFXSetting" -Value 3 -Type DWord -ErrorAction Stop # ── Matikan SEMUA animasi / efek visual untuk performa terbaik ── # UserPreferencesMask = byte array yang mengontrol efek visual Windows # 0x90,0x12,0x03,0x80,0x10,0x00,0x00,0x00 = minimal effects $minimalMask = [byte[]](0x90,0x12,0x03,0x80,0x10,0x00,0x00,0x00) Set-ItemProperty -Path $desktopPath -Name "UserPreferencesMask" ` -Value $minimalMask -Type Binary -ErrorAction Stop # ── AKTIFKAN kembali 4 efek yang dikecualikan ── # 1. Smooth edges of screen fonts (FontSmoothing = 2 = ClearType) Set-ItemProperty -Path $desktopPath -Name "FontSmoothing" -Value 2 -Type String -ErrorAction Stop Set-ItemProperty -Path $desktopPath -Name "FontSmoothingType" -Value 2 -Type DWord -ErrorAction Stop Write-Info "[+] Font Smoothing (ClearType) — Diaktifkan" # 2. Show thumbnails instead of icons (IconsOnly = 0 = tampilkan thumbnail) Set-ItemProperty -Path $advancedPath -Name "IconsOnly" -Value 0 -Type DWord -ErrorAction Stop Write-Info "[+] Thumbnail Preview — Diaktifkan" # 3. Show translucent selection rectangle (ListviewAlphaSelect = 1) Set-ItemProperty -Path $advancedPath -Name "ListviewAlphaSelect" -Value 1 -Type DWord -ErrorAction Stop Write-Info "[+] Translucent Selection Rectangle — Diaktifkan" # 4. Show window contents while dragging (DragFullWindows = 1) Set-ItemProperty -Path $desktopPath -Name "DragFullWindows" -Value 1 -Type String -ErrorAction Stop Write-Info "[+] Show Window Contents While Dragging — Diaktifkan" Write-OK "Visual Effects Custom — Konfigurasi selesai." # ── Restart Explorer agar semua perubahan visual langsung berlaku ── Write-Step "Merestart Windows Explorer untuk menerapkan perubahan..." try { Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue Start-Sleep -Milliseconds 1500 # Explorer akan restart sendiri; jika tidak, paksa start $explorerProc = Get-Process "explorer" -ErrorAction SilentlyContinue if (-not $explorerProc) { Start-Process "explorer.exe" } Write-OK "Windows Explorer — Berhasil direstart." } catch { Write-Fail "Gagal merestart Explorer: $_" } } catch { Write-Fail "Gagal menerapkan Visual Effects tweaks: $_" } } # ============================================================================= # REGION: MENU PILIHAN KATEGORI MANUAL (untuk Opsi 2) # ============================================================================= function Show-CategoryMenu { Write-SectionBanner "PILIHAN KATEGORI MANUAL" Write-Host " Pilih kategori yang ingin diinstal (Y/N):" -ForegroundColor Yellow Write-Host "" # Browser Write-Host " [1] Browser (Google Chrome, Mozilla Firefox)" -ForegroundColor Cyan $browser = (Read-Host " Install Browser? [Y/N]").Trim().ToUpper() # Office Write-Host "" Write-Host " [2] Office Suite (Apache OpenOffice, WPS Office)" -ForegroundColor Cyan $office = (Read-Host " Install Office? [Y/N]").Trim().ToUpper() # Utility Write-Host "" Write-Host " [3] Utility (7-Zip, Adobe Reader, Thunderbird)" -ForegroundColor Cyan $utility = (Read-Host " Install Utility? [Y/N]").Trim().ToUpper() # Security Write-Host "" Write-Host " [4] Security (AVG AntiVirus Free)" -ForegroundColor Cyan $security = (Read-Host " Install Security? [Y/N]").Trim().ToUpper() # Internal Write-Host "" Write-Host " [5] Internal (Spark Messenger 2.7.7)" -ForegroundColor Cyan $internal = (Read-Host " Install Aplikasi Internal? [Y/N]").Trim().ToUpper() Write-Host "" Write-Host ("─" * 70) -ForegroundColor DarkGray Write-Step "Memulai instalasi kategori yang dipilih..." Write-Host "" if ($browser -eq "Y") { Install-Category-Browser } if ($office -eq "Y") { Install-Category-Office } if ($utility -eq "Y") { Install-Category-Utility } if ($security -eq "Y") { Install-Category-Security } if ($internal -eq "Y") { Install-Category-Internal } } # ============================================================================= # REGION 5: FINISHING TOUCH # Tampilkan pesan selesai dan dialog MessageBox native Windows # ============================================================================= function Show-CompletionDialog { Write-Host "" Write-Host ("═" * 70) -ForegroundColor Green Write-Host "" Write-Host " ██████╗ ██████╗ ███╗ ██╗███████╗ ██╗" -ForegroundColor Green Write-Host " ██╔══██╗██╔═══██╗████╗ ██║██╔════╝ ██║" -ForegroundColor Green Write-Host " ██║ ██║██║ ██║██╔██╗ ██║█████╗ ██║" -ForegroundColor Green Write-Host " ██║ ██║██║ ██║██║╚██╗██║██╔══╝ ╚═╝" -ForegroundColor Green Write-Host " ██████╔╝╚██████╔╝██║ ╚████║███████╗ ██╗" -ForegroundColor Green Write-Host " ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝" -ForegroundColor Green Write-Host "" Write-Host " SEMUA INSTALASI SELESAI" -ForegroundColor Green Write-Host "" Write-Host ("═" * 70) -ForegroundColor Green Write-Host "" # Tampilkan native Windows MessageBox menggunakan Windows Forms # Assembly harus di-load terlebih dahulu Add-Type -AssemblyName System.Windows.Forms -ErrorAction SilentlyContinue $msgTitle = "Mepro IT Auto-Deploy — Selesai" $msgContent = "Instalasi & Konfigurasi Selesai!`n`nHarap Restart PC Anda untuk mengaktifkan SMB 1.0 dan menerapkan semua perubahan sistem." [System.Windows.Forms.MessageBox]::Show( $msgContent, $msgTitle, [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information ) | Out-Null Write-Host " Terima kasih telah menggunakan Mepro IT Auto-Deploy." -ForegroundColor DarkGray Write-Host " Harap restart PC Anda segera.`n" -ForegroundColor Yellow } # ============================================================================= # REGION: MAIN ENTRYPOINT — MENU UTAMA # ============================================================================= function Main { # ── Step 1: Jalankan Winget Bootstrapper ── Write-Header Invoke-WingetBootstrap # ── Step 2: Tampilkan Menu Utama via CLI ── Write-Header Write-Host " Selamat datang di sistem deployment otomatis PT Meprofarm." -ForegroundColor Gray Write-Host " Pastikan koneksi internet aktif sebelum melanjutkan.`n" -ForegroundColor DarkGray Write-Host ("─" * 70) -ForegroundColor DarkGray Write-Host "" Write-Host " [1] Install Semua Aplikasi & Tweak Windows" -ForegroundColor White Write-Host " [2] Pilih Kategori Aplikasi Manual" -ForegroundColor White Write-Host " [3] Cuma Eksekusi Tweak Windows & Setting" -ForegroundColor White Write-Host " [Q] Keluar" -ForegroundColor DarkGray Write-Host "" Write-Host ("─" * 70) -ForegroundColor DarkGray Write-Host "" $choice = (Read-Host " >> Masukkan pilihan Anda [1/2/3/Q]").Trim().ToUpper() switch ($choice) { "1" { # ── Opsi 1: Install semua kategori + jalankan semua tweak ── Write-Header Write-Host " Mode: INSTALL SEMUA APLIKASI & TWEAK WINDOWS`n" -ForegroundColor Yellow Install-Category-Browser Install-Category-Office Install-Category-Utility Install-Category-Security Install-Category-Internal Invoke-WindowsTweaks } "2" { # ── Opsi 2: Pilih kategori secara manual (tidak include tweak) ── Write-Header Write-Host " Mode: PILIHAN KATEGORI APLIKASI MANUAL`n" -ForegroundColor Yellow Show-CategoryMenu } "3" { # ── Opsi 3: Hanya jalankan Windows Tweaks & Setting ── Write-Header Write-Host " Mode: TWEAK WINDOWS & KONFIGURASI SISTEM SAJA`n" -ForegroundColor Yellow Invoke-WindowsTweaks } "Q" { Write-Host "`n Keluar dari program. Sampai jumpa!`n" -ForegroundColor DarkGray exit 0 } default { Write-Host "`n [!!] Pilihan tidak valid. Harap masukkan 1, 2, 3, atau Q.`n" -ForegroundColor Red Pause-ForUser Main # Rekursif kembali ke menu utama return } } # ── Step 5: Tampilkan Pesan & Dialog Selesai ── Show-CompletionDialog } # ── Jalankan fungsi utama ── Main