Page 1 of 1

[SOLVED] Adding the current user to a local group

Published: May 13, 2022 - 3:21 PM
by ligerotl
Hello,

I would like to add the current user's account to a local group.
I found the correct way to do this with PowerShell: `
run_powershell('Add-LocalGroupMember -Group "OpenVPN Administrators" -Member "&username"')`.
When I run the script, it adds the system user to the group.
Using the command
`username = get_current_user()`
, I get the current user, but I'm stuck on how to pass the variable to my PowerShell line.
Is there a solution for this, or something simpler?

Thank you.

Re: Adding the current user to a local group

Published: May 13, 2022 - 4:11 PM
by sfonteneau
I prefer Python:

Code: Select all

for user in get_loggedinusers():
    add_user_to_group(user,"OpenVPN Administrators")


Re: Adding the current user to a local group

Published: May 23, 2022 - 09:29
by ligerotl
Hello and thank you, I'll try it.
Have a good day