Sccm remediation scritpt always return true

I have a configuration item with a troubleshooting scenario. I know for a fact that my test host does not comply with the rule. But the troubleshooting script always returns true, although if I run the script locally on the host I get false as expected
I know that the file “C:Windowstempbiospwd.txt” doesn’t exist on the host.

discovery:

# File detection script in user profile
$FileToDetect = "C:WindowsTempbiospwd.txt"
if (Test-Path $FileToDetect -PathType leaf) 
#File exists
{ return $True }
else
#File does not exist
{ return $false }

remedation:

# File detection script in user profile
$FileToDetect = "C:WindowsTempbiospwd.txt"
if (Test-Path $FileToDetect -PathType leaf)
#File exists
{ return $True }
else
#File does not exist
{ 
# Generate passhash
$biosserialNumber = (Get-WmiObject Win32_BIOS).SerialNumber
$password = $biosserialNumber + "word2024biospass"
$passwordBytes = [System.Text.Encoding]::UTF8.GetBytes($password)
$shaSHA512 = [System.Security.Cryptography.SHA512]::Create()
$hashBytes = $shaSHA512.ComputeHash($passwordBytes)
$hashString = [System.BitConverter]::ToString($hashBytes) -replace '-'
$hashString = $hashString.Substring(0, 14)
# Get the last boot time of the system
$lastBoottime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime | Get-Date
# Define the path to the index file
$indexFilePath = "C:WindowsTempBiosPasswordIndex.txt"
$biosPassTimeFilePath = "C:WindowsTempBiosPassTime.txt"
# Check if the index file exists and read the index
if (Test-Path $indexFilePath) {
    $i = [int](Get-Content -Path $indexFilePath)
} else {
    $i = 0
}
# Get the last write time of the BiosPassTime.txt file
if (Test-Path $biosPassTimeFilePath) {
    $getfiletime = (Get-Item -Path $biosPassTimeFilePath).LastWriteTime
} else {
    $getfiletime = $null
}
# Check reboot condition and file existence
if (($lastBoottime -gt $getfiletime) -or ($null -eq $getfiletime)) {
    # List of passwords
    $passwords = @(
        "1", "2", "3", 
        "4"
    )
    [string]$MyPassword = $hashString
    $setPw = Get-WmiObject -Class Lenovo_setBiosPassword -Namespace rootwmi
    # Iterate through passwords starting from index $i
    for ($j = $i; ($j -lt $passwords.Length) -and ($j -le ($i + 1)); $j++) {
        $currentPassword = $passwords[$j]
        $return = $setPw.SetBiosPassword("pap,$currentPassword,$MyPassword,ascii,us")
        if ($return.return -like "Success") {
            # Successful password change, create file and exit
            New-Item -Path "C:windowsTemp" -ItemType File -Name "biospwd.txt" -Force -Confirm:$false | Out-Null
            # Remove the index file as the password has been successfully changed
            Remove-Item -Path $indexFilePath -Force | Out-Null
            #write-host $return.return
            return $true
        } else {
            # Failure, update the index and save it to the file
            
            Set-Content -Path $indexFilePath -Value ($j + 1) | Out-Null
           
            #write-host $return.return
        }
    }
    # If all attempts fail, create or update the last write time of the BiosPassTime.txt file
    New-Item -Path $biosPassTimeFilePath -ItemType File -Force | Out-Null
   # write-host $return.return
    return $false
} else {return $false}
}

baseline:

compliance rule:

host report:

I don’t understand why the host report returns true?

if you take out the remediation script and leave only the discovery script. Everything works as it should and I see non-compliant in the report.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật