Selasa, 04 November 2025

Script Buatan AI

1. Script Powershell7 Ringkasan sistem yang saya minta buatkan ke ChatGPT

# ===============================
#   Script: MySystem.ps1
#   Fungsi: Menampilkan ringkasan lengkap sistem Windows
#            (OS, Hardware, Storage, Jaringan)
#            + Suhu CPU dan usia firmware
# ===============================
# Fungsi bantu untuk menampilkan garis pemisah
function Show-Line {
    Write-Host "──────────────────────────────────────────────" -ForegroundColor DarkGray
}
Clear-Host
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host "         RINGKASAN INFORMASI SISTEM" -ForegroundColor Cyan
Write-Host "=============================================" -ForegroundColor Cyan
# --- Informasi dasar OS ---
Show-Line
Write-Host "[ SISTEM OPERASI ]" -ForegroundColor Yellow
Show-Line
$os = Get-CimInstance Win32_OperatingSystem
Write-Host ("Nama OS           : {0}" -f $os.Caption)
Write-Host ("Versi             : {0}" -f $os.Version)
Write-Host ("Build Number      : {0}" -f $os.BuildNumber)
Write-Host ("Arsitektur        : {0}" -f $os.OSArchitecture)
Write-Host ("Tanggal Instalasi : {0}" -f $os.InstallDate.ToLocalTime())
# --- Informasi komputer & hardware ---
Show-Line
Write-Host "[ PERANGKAT KERAS ]" -ForegroundColor Yellow
Show-Line
$cs = Get-CimInstance Win32_ComputerSystem
$bios = Get-CimInstance Win32_BIOS
$cpu = Get-CimInstance Win32_Processor
Write-Host ("Nama Komputer     : {0}" -f $cs.Name)
Write-Host ("Pabrikan          : {0}" -f $cs.Manufacturer)
Write-Host ("Model             : {0}" -f $cs.Model)
Write-Host ("BIOS Version      : {0}" -f $bios.SMBIOSBIOSVersion)
Write-Host ("Prosesor          : {0}" -f $cpu.Name)
Write-Host ("Jumlah Core       : {0}" -f $cpu.NumberOfCores)
Write-Host ("Jumlah Thread     : {0}" -f $cpu.NumberOfLogicalProcessors)
Write-Host ("RAM Terpasang     : {0:N2} GB" -f ($cs.TotalPhysicalMemory / 1GB))
# --- Suhu CPU (jika tersedia) ---
try {
    $temp = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root\WMI" -ErrorAction Stop
    if ($temp) {
        foreach ($t in $temp) {
            $celsius = ($t.CurrentTemperature / 10) - 273.15
            Write-Host ("Suhu CPU          : {0:N1} °C" -f $celsius) -ForegroundColor Cyan
        }
    } else {
        Write-Host "Suhu CPU          : Sensor tidak tersedia" -ForegroundColor DarkGray
    }
}
catch {
    Write-Host "Suhu CPU          : Tidak dapat diakses" -ForegroundColor DarkGray
}
# --- Informasi storage ---
Show-Line
Write-Host "[ PENYIMPANAN ]" -ForegroundColor Yellow
Show-Line
Get-CimInstance Win32_LogicalDisk | ForEach-Object {
    $size = "{0:N1}" -f ($_.Size / 1GB)
    $free = "{0:N1}" -f ($_.FreeSpace / 1GB)
    Write-Host ("Drive {0}  {1} GB total, {2} GB kosong,  {3}" -f $_.DeviceID, $size, $free, $_.FileSystem)
}
# --- Informasi jaringan ---
Show-Line
Write-Host "[ JARINGAN ]" -ForegroundColor Yellow
Show-Line
# --- Ambil IP Lokal ---
$ip_local = Get-NetIPAddress -AddressFamily IPv4 |
    Where-Object {
        $_.InterfaceAlias -notmatch "Loopback|vEthernet" -and
        $_.IPAddress -notmatch "^169\.254\."
    } |
    Select-Object -ExpandProperty IPAddress -ErrorAction SilentlyContinue
if ($ip_local) {
    foreach ($ip in $ip_local) {
        Write-Host ("IP Lokal  : {0}" -f $ip) -ForegroundColor Green
    }
} else {
    Write-Host "IP Lokal  : Tidak terdeteksi" -ForegroundColor Red
}
# --- Ambil IP Publik dari ipinfo.io ---
try {
    $pubinfo = Invoke-RestMethod -Uri "https://ipinfo.io" -ErrorAction Stop
    $ip_public = $pubinfo.ip
    $city      = $pubinfo.city
    $region    = $pubinfo.region
    $country   = $pubinfo.country
    $org       = $pubinfo.org
    Write-Host ("IP Publik : {0}" -f $ip_public) -ForegroundColor Green
    Write-Host ("Lokasi    : {0}, {1}, {2}" -f $city, $region, $country)
    Write-Host ("Provider  : {0}" -f $org)
}
catch {
    Write-Host "Gagal mendapatkan IP publik (offline / koneksi bermasalah)" -ForegroundColor Red
}
# --- Akhiran ---
Show-Line
Write-Host "[ SELESAI ]" -ForegroundColor Yellow
Show-Line
Write-Host "Tekan Enter untuk keluar..." -ForegroundColor DarkGray
Read-Host | Out-Null


2. Script Informasi Jaringan

# C:\budi\netinfo.ps1
# Script menampilkan informasi jaringan utama + status koneksi
# Kompatibel untuk PowerShell 5.x dan 7.x+
# Versi ini menyembunyikan adapter virtual (VirtualBox, VMware, Hyper-V, Loopback)

$startTime = Get-Date

Write-Host ""
Write-Host "     === NETWORK INFORMATION ===" -ForegroundColor Cyan

# Hostname
$hostname = $env:COMPUTERNAME
Write-Host "     Hostname           : $hostname"

# Interface aktif (hanya adapter fisik/non-virtual)
$netAdapters = Get-WmiObject Win32_NetworkAdapterConfiguration |
    Where-Object { $_.IPEnabled -eq $true -and $_.Description -notmatch "Virtual|VMware|Hyper|Loopback" }

foreach ($adapter in $netAdapters) {
    Write-Host "     Adapter Name       : $($adapter.Description)"
    Write-Host "     MAC Address        : $($adapter.MACAddress)"
    Write-Host "     Local IP Address   : $($adapter.IPAddress -join ', ')" -ForegroundColor Green
    Write-Host "     Default Gateway    : $($adapter.DefaultIPGateway -join ', ')"
    Write-Host "     DNS Server         : $($adapter.DNSServerSearchOrder -join ', ')"

    # Ping ke gateway
    if ($adapter.DefaultIPGateway) {
        $gateway = $adapter.DefaultIPGateway[0]

        try {
            $pingObj = Test-Connection -ComputerName $gateway -Count 1 -ErrorAction Stop

            # Deteksi versi PowerShell
            if ($PSVersionTable.PSVersion.Major -ge 6) {
                # PowerShell 6/7+
                $pingTime = $pingObj.Latency
            } else {
                # PowerShell 5.x
                $pingTime = $pingObj.ResponseTime
            }

            Write-Host "     Ping ke Gateway    : Success ($pingTime ms)"
        }
        catch {
            Write-Host "     Ping ke Gateway    : Failed" -ForegroundColor Red
        }
    } else {
        Write-Host "     Gateway Tidak Ditemukan"
    }

    Write-Host "     --------------------------------------"
}

# IP Publik dan info ASN/Negara via ipinfo.io
Write-Host "`n     Getting Public IP Information..." -ForegroundColor Yellow
try {
    $ipinfo = Invoke-WebRequest -Uri "https://ipinfo.io/json" -UseBasicParsing | ConvertFrom-Json
    Write-Host "`n     === PUBLIC IP INFORMATION ===" -ForegroundColor Cyan
    Write-Host "     Public IP          : $($ipinfo.ip)" -ForegroundColor Green
    Write-Host "     ASN Provider       : $($ipinfo.org)"
    Write-Host "     Country            : $($ipinfo.country)"
    Write-Host "     City               : $($ipinfo.city)"
    Write-Host "     Coordinate         : $($ipinfo.loc)"
    Write-Host "     ISP(Hostname)      : $($ipinfo.hostname)"
    Write-Host "     --------------------------------------"
}
catch {
    Write-Host "     Gagal mendapatkan info publik IP." -ForegroundColor Red
}

# Ping test ke google.com
Write-Host "`n     Ping Test to google.com..." -ForegroundColor Yellow
try {
    $pingObj = Test-Connection -ComputerName "google.com" -Count 1 -ErrorAction Stop

    if ($PSVersionTable.PSVersion.Major -ge 6) {
        $pingTime = $pingObj.Latency
    } else {
        $pingTime = $pingObj.ResponseTime
    }

    Write-Host "     Status (Latency)    : Online ($pingTime ms)" -ForegroundColor Green
}
catch {
    Write-Host "     Status (Latency)    : Offline" -ForegroundColor Red
}

# Execution time
$endTime = Get-Date
$duration = [Math]::Round(($endTime - $startTime).TotalSeconds, 2)
Write-Host ""
Write-Host "     Execution Time     : $duration Seconds"
Write-Host "     Done." -ForegroundColor Green
Write-Host ""

Kemampuan AI (ChatGPT)

Halaman

Diberdayakan oleh Blogger.

JSON Variables

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.

Recent Posts

{getWidget} $results={4} $label={recent}

Blogroll

Pages

About

Facebook

Comments

{getWidget} $results={3} $label={comments}

Advertisement

Subscribe Us