Post-installation: add users group to localgroup?

Hello everyone, I am a beginner with this tool. And now I’m stuck on something that seems very simple.

I’m trying to deploy Docker-Desktop but once installed, I need to add an AD group to the local “docker-users” group. So I use the “Post-Installation” section in the script to execute the command:

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command Add-LocalGroupMember -Group `docker-users` -Member `S-1-5-21-2934168699-705377679-1066268797-27038`"; Exit `$LastExitCode }"" -Wait

But without success…Nothing happens. What do you think the problem is?

I’m not sure if Execute-ProcessAsUser will report errors.

In your post, you used back ticks instead of single quotes and only one }

I’ve cleaned it up as best as I can but I can’t test it:

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command Add-LocalGroupMember -Group 'docker-users' -Member 'S-1-5-21-2934168699-705377679-1066268797-27038'; Exit $LastExitCode" -Wait

Is there a reason you are using Execute-ProcessAsUser? Adding a member to a local group requires elevated privileges so your User would need to be a local Administrator on their device for this to (potentially) work. If your goal is simply to add users to the local group then simply use Add-LocalGroupMember directly in your script eg.

Add-LocalGroupMember -Group 'docker-users' -SID 'S-1-5-21-2934168699-705377679-1066268797-27038'

If you have multiple Members to add you could try this:

Add-LocalGroupMember -Group 'docker-users' -Member $Users

One other thing, you don’t have to use the different script sections (pre-installation, installation, post-installation). It makes the log files look a little nicer but they don’t make any practical difference to how your script runs so feel free to put everything in the installation section.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.