/build/static/layout/Breadcrumb_cap_w.png

Odd behaviour of powershell script in K1000

I have an online kscript to check whether the boot loader is uefi or legacy bios. It creates a text file in a shared folder named for the pc and the result - bios or uefi. When I run the script manually, it works properly - my computer has uefi in the name. When I run it in kbox, all computers have bios in the name, including mine. I've tried running as system and with a saved admin credential (same one I used for the manual run), but still get bios for all.

Here's the script.

#Detect Legacy BIOS or UEFI

$PC = $env:COMPUTERNAME
$BL = bcdedit |findstr winload.efi

if (Test-Path "\\FS1\Logins\Computers\BootLoader\*$PC.txt")
{break}
else
{
if ($BL -ne $null)
{$PC | Out-File "\\FS1\BootLoader\uefi-$PC.txt" -append}

else

{$PC| Out-File "\\FS1\BootLoader\bios-$PC.txt" -append}
}

I appreciate any insights. If this is already in inventory somewhere and someone can point me to it, that would be great, too.

Thanks.


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: torstenspitz 9 months ago
Yellow Belt
0

Most likely this is because of the KACE Agent running in 32 bit.

Try starting the script with cd c:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe

Posted by: rileyz 9 months ago
Red Belt
0

Could try this function, since your method is borking in KACE.

https://gallery.technet.microsoft.com/scriptcenter/Determine-UEFI-or-Legacy-7dc79488



Posted by: tpr 9 months ago
2nd Degree Black Belt
0

The sysnative path fixed it. I ran into that 8 or 10 months ago, so I need to tattoo on my forehead.

Thanks to both of you for the responses.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ