'PowerShell registry permission on new computer

I am trying to set up new computers and as it is a new computer it won't allow me to run the PowerShell script as admin. As I can't run it as administrator I can't REG ADD my AutoAdminLogon, DefaultUserName and DefaultPassword. How can I work around this to get my script to allow this and run as admin.

Add-Content -Path "C:\Install Logs\Install.log" -Value "Set up auto login as admin - $(Get-Date)"
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d AdminIT /f
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d Password /f


Solution 1:[1]

Only work around so far that I have found is to make a .bat file and in that force the PowerShell script to run as Admin.

PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PlusIVGY