# === PHYSICAL ===
# Get BIOS Serial Number
$BIOSSerialNumber = (gwmi Win32_BIOS).SerialNumber
# Get Computer System Product Name and Version
$SystemProductName = (gwmi Win32_ComputerSystemProduct).Name
$SystemProductVersion = (gwmi Win32_ComputerSystemProduct).Version
# Get Network Adapter Information
$NetworkAdapter = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } | Select-Object -First 1
$MACAddress = $NetworkAdapter.MacAddress


# === RESOURCES ===
#CPU name
$CPU = Get-CimInstance Win32_Processor | Select-Object Name
# Get RAM information

# Retrieve RAM information
# Retrieve memory module information
$memoryModules = Get-WmiObject Win32_PhysicalMemory | Select-Object Capacity

# Count the number of memory modules
$numberOfModules = $memoryModules.Count

# Calculate the total installed RAM in GB
$totalRAM = ($memoryModules | Measure-Object -Property Capacity -Sum).Sum / 1GB

# Check the configuration of RAM modules
$moduleSizes = @{}
foreach ($module in $memoryModules) {
    $sizeGB = $module.Capacity / 1GB
    if ($moduleSizes.ContainsKey($sizeGB)) {
        $moduleSizes[$sizeGB]++
    } else {
        $moduleSizes[$sizeGB] = 1
    }
}

if ($moduleSizes.Keys.Count -eq 1) {
    $moduleSize = $moduleSizes.Keys[0]
    $moduleCount = $moduleSizes[$moduleSize]
}
else {
    $moduleCount = "Mixed"
    $moduleCount = "Unknown"
}

# Get disk information
$Disks = Get-CimInstance -ClassName Win32_DiskDrive
$DiskInfo = foreach ($Disk in $Disks) {
    $DiskSize = [math]::Round($Disk.Size / 1GB, 2)
    "$($Disk.Caption): Size: ${DiskSize}GB"
}

#=== OS ===
# OS version
$OS = Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version
$LocalUsers = Get-LocalUser
$DisplayName = (Get-LocalUser | sort LastLogon)[-1].fullname

#=== NETWORK ===
# Get IP Address
$IPAddress = Get-NetIPAddress | Where-Object {$_.AddressFamily -eq "IPv4" -and $_.InterfaceAlias -eq "Ethernet"} | ForEach-Object { $_.IPAddress + " - " + $_.PrefixOrigin }
# Get Hostname
$Hostname = hostname
#Get DNS
$DNS = (Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses
$Shares = Get-SmbMapping

#=== USERS ===
# Get Local Users

#########

# Display the information in a list
$OutputList = @(
    " "
    "=== PHYSICAL ==="
    "BIOS Serial Number: $BIOSSerialNumber",
    "System Product Name: $SystemProductName",
    "System Product Version: $SystemProductVersion",
    "Network Adapter MAC Address: $MACAddress",
    " "
    "=== RESOURCES ===",
    "CPU: $CPU"
    "Total RAM: $totalRAM GB"
    "RAM modules: $numberOfModules"
    "RAM configuration: $moduleCount x ${moduleSize}GB",
    "Drives: $DiskInfo",
    " "
    "=== OS ===",
    "OS: $OS",
    "Local Users: $LocalUsers"
    "Display Name: $DisplayName"
    " "
    "=== NETWORK ==="
    "IP Address: $IPAddress",
    "Hostname: $Hostname",
    "DNS: $DNS"
    "Shares: $Shares"
    " "

)

# Output the list
$OutputList