Script: Connect to iDRAC and collect Service Tag

A current use case I have is to gather all the Service Tags for my Dell Server environment, which is in the hundreds. Collecting them manually will be a nightmare. This is where scripts make the world so much easier.

There are two types of interfaces to the iDRAC we can use. Redfish or WS-MAN.

Check if Redfish is active

Redfish is a modern, standardized API that helps manage and interact with hardware systems like servers, storage, and networking devices. Within the Dell iDRAC (Integrated Dell Remote Access Controller) context, Redfish acts as a RESTful interface, offering a simpler and more efficient way to remotely manage server hardware.

Redfish is built on a RESTful architecture that uses HTTP commands, simplifying integration with modern web tools and applications. It transmits data in JSON format, a lightweight and widely adopted standard among programming languages. With secure communication enabled through HTTPS, Redfish ensures robust authentication and data protection. Designed for scalability, it is ideal for managing large-scale environments with multiple servers and devices. As an industry standard, Redfish guarantees interoperability and compatibility across various vendors’ hardware and software systems. Additionally, its simple API design makes automation tasks more straightforward and efficient.

Invoke-RestMethod -Uri "https://<iDRAC-IP>/redfish/v1" -SkipCertificateCheck

Or from Linux/macOS/Windows:

curl -k https://<iDRAC-IP>/redfish/v1

✅ If you get JSON output, it’s enabled. ❌ If the connection fails or is refused, it may be disabled or blocked.

Use Redfish to get the information

# This script connects with iDRAC over "Redfish"
# Gathers this information:
# Hostname
# Model
# Service Tag
# CPU Model
# CPU Count
# RAM
# Disk
# BIOS Version
# iDRAC Firmware version
#  
# Exports it all to a csv
# 
# This Script is created by Leif Hegdal 
# Published at https://vminfrastructure.com 
#

# Set file paths
$inputPath = "$env:USERPROFILE\Desktop\idrac_list.txt"
$outputPath = "$env:USERPROFILE\Desktop\iDRAC_Redfish_Info.csv"

# Load IPs
if (-Not (Test-Path $inputPath)) {
    Write-Error "Input file not found: $inputPath"
    exit
}

$idracIPs = Get-Content -Path $inputPath | Where-Object { $_ -match '\d+\.\d+\.\d+\.\d+' }

if ($idracIPs.Count -eq 0) {
    Write-Warning "No valid IPs found in file. Exiting..."
    exit
}

# Get credentials
$cred = Get-Credential -Message "Enter iDRAC Redfish credentials"

# Trust all SSL certs (not recommended for production)
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

# Output collection
$results = @()

foreach ($ip in $idracIPs) {
    Write-Host "Connecting to iDRAC at $ip via Redfish ..." -ForegroundColor Cyan
    try {
        $baseUri = "https://$ip/redfish/v1"

        $authHeader = @{
            Authorization = "Basic " + [Convert]::ToBase64String(
                [Text.Encoding]::ASCII.GetBytes("$($cred.UserName):$($cred.GetNetworkCredential().Password)"))
        }

        # Get system info
        $systemUri = "$baseUri/Systems/System.Embedded.1"
        $system = Invoke-RestMethod -Uri $systemUri -Headers $authHeader -Method Get -UseBasicParsing

        # Memory & CPU
        $memoryGB = ($system.MemorySummary.TotalSystemMemoryGiB -as [int])
        $cpuModel = $system.ProcessorSummary.Model
        $cpuCount = $system.ProcessorSummary.Count

        # Disk info
        $diskTotalGB = 0
        $storageUri = "$baseUri/Systems/System.Embedded.1/Storage"
        $storageResp = Invoke-RestMethod -Uri $storageUri -Headers $authHeader -Method Get -UseBasicParsing
        foreach ($storage in $storageResp.Members) {
            $storeDetail = Invoke-RestMethod -Uri $storage['@odata.id'] -Headers $authHeader -Method Get -UseBasicParsing
            foreach ($drive in $storeDetail.Drives) {
                $driveDetail = Invoke-RestMethod -Uri $drive['@odata.id'] -Headers $authHeader -Method Get -UseBasicParsing
                $diskTotalGB += [math]::Round($driveDetail.CapacityBytes / 1GB, 0)
            }
        }

        # Get BIOS version
        $biosUri = "$baseUri/Systems/System.Embedded.1/Bios"
        $bios = Invoke-RestMethod -Uri $biosUri -Headers $authHeader -Method Get -UseBasicParsing
        $biosVersion = $bios.BiosVersion

        # Get iDRAC Firmware Version
        $managersUri = "$baseUri/Managers/iDRAC.Embedded.1"
        $manager = Invoke-RestMethod -Uri $managersUri -Headers $authHeader -Method Get -UseBasicParsing
        $firmwareVersion = $manager.FirmwareVersion

        # Add results
        $results += [PSCustomObject]@{
            iDRAC_IP       = $ip
            Hostname       = $system.HostName
            Model          = $system.Model
            ServiceTag     = $system.SerialNumber
            CPU_Model      = $cpuModel
            CPU_Count      = $cpuCount
            RAM_TotalGB    = $memoryGB
            Disk_TotalGB   = $diskTotalGB
            BIOS_Version   = $biosVersion
            iDRAC_Firmware = $firmwareVersion
        }

    } catch {
        Write-Warning "Failed to query $ip: $($_.Exception.Message)"
        $results += [PSCustomObject]@{
            iDRAC_IP       = $ip
            Hostname       = "Unavailable"
            Model          = "Unavailable"
            ServiceTag     = "Unavailable"
            CPU_Model      = "Unavailable"
            CPU_Count      = "Unavailable"
            RAM_TotalGB    = "Unavailable"
            Disk_TotalGB   = "Unavailable"
            BIOS_Version   = "Unavailable"
            iDRAC_Firmware = "Unavailable"
        }
    }
}

# Export to CSV
$results | Export-Csv -Path $outputPath -NoTypeInformation -Encoding UTF8
Write-Host "Redfish report exported to: $outputPath" -ForegroundColor Green

Check if ws-man is active

WS-MAN is the acronym for Web Services Management, a standard protocol that helps manage systems, devices, and applications. Dell’s iDRAC (Integrated Dell Remote Access Controller) incorporates WS-MAN as part of its remote management features.

WS-MAN is built on SOAP (Simple Object Access Protocol) and enables communication between management software and managed devices. Within the Dell iDRAC context, WS-MAN lets administrators carry out tasks like monitoring hardware health, configuring system settings, and performing remote operations using standardized web service commands.


# Replace with your iDRAC IP
$ip = "192.168.1.100"

# Optional credentials for secure test
$cred = Get-Credential

# Try to create a CIM session over WSMan (iDRAC uses HTTPS and Basic auth)
$opt = New-CimSessionOption -UseSsl -SkipCACheck -SkipCNCheck -SkipRevocationCheck

$cim = New-CimSession -Authentication Basic -Credential $cred -ComputerName $ip -Port 443 -SessionOption $opt

# Test the session
Get-CimInstance -CimSession $cim -Namespace root/dcim/sysman -ClassName DCIM_SystemView

# Close session
Remove-CimSession $cim

If this works, WS-Man is active. ❌ If it errors, WS-Man is likely disabled or blocked.

# This Script will log into the iDRAC interface over WS-MAN
# The script will gather
# Hostname
# Model
# Service Tag
# CPU Model
# CPU Count
# RAM
# Disk
# BIOS Version
# iDRAC Firmware version
#  
# Exports it all to a csv
# 
# This Script is created by Leif Hegdal 
# Published at https://vminfrastructure.com 
#

Set paths

$inputPath = "$env:USERPROFILE\Desktop\idrac_list.txt"
$outputPath = "$env:USERPROFILE\Desktop\iDRAC_Server_Info.csv"

Read iDRAC IPs from file

if (-Not (Test-Path $inputPath)) {
Write-Error "Input file not found: $inputPath"
exit
}
$idracIPs = Get-Content -Path $inputPath | Where-Object { $_ -and ($_ -match '\d+.\d+.\d+.\d+') }
if ($idracIPs.Count -eq 0) {
Write-Warning "No valid IPs found in file. Exiting..."
exit
}

Get credentials

$cred = Get-Credential -Message "Enter iDRAC credentials"

Output list

$results = @()
foreach ($ip in $idracIPs) {
Write-Host "Connecting to iDRAC at $ip ..." -ForegroundColor Cyan
try {
$sessionOptions = New-CimSessionOption -UseSsl -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$cimSession = New-CimSession -Authentication Basic -Credential $cred -ComputerName $ip -Port 443 -SessionOption $sessionOptions
    $bios  = Get-CimInstance -CimSession $cimSession -Namespace root/dcim/sysman -ClassName DCIM_SystemView
    $mem   = Get-CimInstance -CimSession $cimSession -Namespace root/dcim/sysman -ClassName DCIM_MemoryView
    $cpu   = Get-CimInstance -CimSession $cimSession -Namespace root/dcim/sysman -ClassName DCIM_ProcessorView
    $disk  = Get-CimInstance -CimSession $cimSession -Namespace root/dcim/sysman -ClassName DCIM_PhysicalDiskView

    $results += [PSCustomObject]@{
        iDRAC_IP     = $ip
        Hostname     = $bios.HostName
        Model        = $bios.Model
        ServiceTag   = $bios.ServiceTag
        CPU_Model    = ($cpu | Select-Object -First 1).ProcessorModel
        CPU_Count    = $cpu.Count
        RAM_TotalGB  = [math]::Round(($mem | Measure-Object -Property Size -Sum).Sum / 1GB, 0)
        Disk_TotalGB = [math]::Round(($disk | Measure-Object -Property SizeInBytes -Sum).Sum / 1GB, 0)
    }

    Remove-CimSession -CimSession $cimSession
} catch {
    Write-Warning "Failed to query $ip: $($_.Exception.Message)"
    $results += [PSCustomObject]@{
        iDRAC_IP     = $ip
        Hostname     = "Unavailable"
        Model        = "Unavailable"
        ServiceTag   = "Unavailable"
        CPU_Model    = "Unavailable"
        CPU_Count    = "Unavailable"
        RAM_TotalGB  = "Unavailable"
        Disk_TotalGB = "Unavailable"
    }
}
}

Export to CSV

$results | Export-Csv -Path $outputPath -NoTypeInformation -Encoding UTF8
Write-Host "Server info exported to: $outputPath" -ForegroundColor Green

Leave a Reply

Your email address will not be published. Required fields are marked *

Share on Social Media