Check if AHCI or IDE is turned on in BIOS

I am trying to write a powershell script to find if AHCI or IDE is turned on and still I cannot find any perfect solution. I tried doing something like this:

$success = “NO”
$diskinfo = $null

$filepath = “C:\plik.txt”
<#
File path TBD
try {
$diskinfo = Get-Ciminstance Win32_Systemdriver -filter ‘description like “%AHCI%” and state like “%running%”’ | fl *
$success = “YES”
} catch {}

try {
if ($diskinfo -eq $null) {
$diskinfo = Get-WmiObject Win32_Systemdriver -filter ‘description like “%AHCI%” and state like “%running%”’ | fl *
$success = “YES”
}
} catch {}

try {
if ($diskinfo -eq $null) {
$diskinfo = Get-WmiObject Win32_PnPSignedDriver -filter ‘description like “%AHCI%” and issigned = true’ | fl *
$success = “YES”
}
} catch {}

try {
if ($diskinfo -eq $null) {
$diskinfo = Get-WmiObject Win32_PnPSignedDriver -filter ‘description like “%AHCI%” and issigned = true’ | fl *
$success = “YES”
}
} catch {}

if ($diskinfo -eq $null -and $success -eq “YES”) {
$name = hostname
$write = “YES”
$checkTable = $null
$fileContent = $null
try {
$fileContent = Get-Content -path $filepath
$checkTable = $fileContent.split([System.Environment]::NewLine)
} catch {}

foreach ($element in $checkTable) {
    if ($element -eq $name) {
        "Już jest w pliku"
        $write = "NO"
    }
}
if ($write -eq "YES" -and $fileContent -ne $null) {
    $fileContent + $name | Out-File -FilePath $filepath
}
if ($fileContent -eq $null) {
    $fileContent + $name | Out-File -FilePath $filepath -NoClobber
}

}
else {
if ($success -eq “YES”) {
“AHCI wlaczone”
}
else {
“Nie udało się pobrać informacji”
}
}

I am not sure if it works properly and cannot find anything better in powershell so I thought if someone can help me with creating a similiar script in BIGFIX.

It would help me a lot because it would save time with booting every single device and checking in BIOS if AHCI is on. Thanks in advance.

Checking the BIOS settings directly would probably require a vendor-specific utility such as a WMI provider, but I think you’re on the right path by examining the results of which drivers have loaded for devices.

I’d start off by using the Fixlet Debugger or WebUI Query app to examine active devices on some target machines and learn what strings to expect…

q: (classes of it, descriptions of it) of active devices
A: PrintQueue, Local Print Queue
A: Biometric, Synaptics WBDI
A: HIDClass, HID-compliant system controller
A: System, Intel(R) Software Guard Extensions Device
A: USB, USB xHCI Compliant Host Controller
...
A: Net, Microsoft Wi-Fi Direct Virtual Adapter
A: MEDIA, Realtek High Definition Audio
A: SCSIAdapter, Standard NVM Express Controller
A: System, Thunderbolt(TM) Controller - 15EB

In my case, I have neither AHCI nor IDE, my controller is NVME (under the “SCSIAdapter” class), but if you check some of your results you can find which Class your AHCI/IDE devices show up under. It might be SCSIAdapter as well…for mine, I can then filter to that Class

q: (classes of it, descriptions of it) of active devices whose (class of it = "SCSIAdapter")
A: SCSIAdapter, Microsoft Storage Spaces Controller
A: SCSIAdapter, Standard NVM Express Controller
A: SCSIAdapter, Microsoft VHD Loopback Controller

and then I can produce string results like

q: if exists descriptions whose (it contains "NVM Express") of active devices whose (class of it = "SCSIAdapter") then "NVMe" else "No NVMe" 
A: NVMe

I expect you’d be able to do something like that replacing “NVM Express” with “AHCI” or “IDE”. Also, you may need to account for the possibility of a machine containing both - i.e. one controller in AHCI mode running hard drivers, and a second controller in IDE mode running DVD-ROM or USB converters, etc.

1 Like