หาก PowerShell แจ้ง Error – File cannot be loaded because running scripts is disabled on this system ต้อง Enable Script Running บน Windows 11/10 สาเหตุคือ User Account ไม่มี Permission พอที่จะรัน Script ไม่ได้แปลว่าต้องเป็น Admin แต่หมายถึงต้องเป็น Unrestricted สำหรับ PowerShell Scripts หรือ Cmdlets

PowerShell cannot be loaded because running scripts is disabled on this system
มีวิธีเดียว ตั้ง Execution Policy เป็น Unrestricted
ก่อนอื่น เช็ค Policy ที่ตั้งไว้สำหรับ User Groups ต่างๆ บนเครื่อง
เริ่มด้วยการกด WINKEY + X หรือคลิกขวา Start เลือก Windows PowerShell (Admin) หรือค้นหา PowerShell คลิกขวา Run as Administrator คลิก Yes สำหรับ UAC PowerShell Window จะเปิด พิมพ์คำสั่งเพื่อดู Execution Policy ทุก Scope:
Get-ExecutionPolicy -List

จะแสดงรายการ User Groups และ Execution Policy Status
ใต้คอลัมน์ Scope ต้องดู LocalMachine
หาก Execution Policy เป็น Undefined หรือ Restricted พบสาเหตุแล้ว
ต่อไป ตั้ง Execution Policy เป็น Unrestricted
พิมพ์คำสั่งใน PowerShell Session เดียวกัน:
Set-ExecutionPolicy Unrestricted

จะขอ Permission ตอบ Y ทีละข้อความ หรือกด A เพื่อ Yes ทั้งหมด
หากคำสั่ง Error บังคับเปลี่ยนได้ด้วย:
Set-ExecutionPolicy Unrestricted -Force
จะตั้ง Execution Policy สำหรับ PowerShell Scripts/Cmdlets เป็น Unrestricted แล้ว
ตอนนี้ Error File cannot be loaded because running scripts is disabled on this system ควรหายไป
ช่วยได้ไหม?
