I'm trying to add the group "Domain Users" to the "administrators" local group in PowerShell using a .ps1 file. The command I'm using is below:
add-localgroupmember -group "Administrators" -Member "DOMAIN\Domain Users"
Strangely, when I run this by itself in a powershell window it works perfectly. However, when it's run via a .ps1 file or a batch file that calls the .ps1 file I get the error below:
There is no such global user or group: DOMAIN\domain.
System error 1388 has occurred.
A new member could not be added to a local group because the member has the wrong account type.
It seems to cut off the "users" part of the group name. I can't seem to find a fix anywhere, hopefully this is a simple one (and sorry if it's a dumb question!)