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.
Answers (3)
Top Answer
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
Could try this function, since your method is borking in KACE.
https://gallery.technet.microsoft.com/scriptcenter/Determine-UEFI-or-Legacy-7dc79488