'Add-LocalGroupMember' is not recognized...
Windows 10 1709 client is running a script that looks up who the computer belongs to in a database and then adds that person as the local administrator using the Add-LocalGroupMember cmdlet.
The script is working fine embedded in our image and launched from setupcomplete.cmd and run as Local System. However, when I wrap the same .ps1 in a .bat shell script and set it in to run as Local System in Dell/Quest KACE the script errors saying that the Add-LocalGroupMember cmdlet is not recognized. If I launch an interactive PS session as Local System and run it, it runs fine.
I added "Get-Module -ListAvailable" to the script and turned on transcription to log everything and the Microsoft.PowerShell.LocalAccounts module is noticeably missing, but only when this script is instantiated via a KACE script, and the KACE script is really just a simple .bat which runs the .ps1: "powershell C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\886\addadminRunNow.ps1" I've tried a literal path to both x64 and x86 powershell executables and that has had no effect.
I ran the script from an interactive PS session running as Local System and, again, it ran find, and listed the module as available.
Does anyone have any idea what is going on?
There are no answers at this time