diff --git a/content/manuals/enterprise/enterprise-deployment/faq.md b/content/manuals/enterprise/enterprise-deployment/faq.md index 4a7f96c1df34..20cb9faea5da 100644 --- a/content/manuals/enterprise/enterprise-deployment/faq.md +++ b/content/manuals/enterprise/enterprise-deployment/faq.md @@ -73,11 +73,15 @@ Here's an example script that creates the `docker-users` group and adds the curr $Group = "docker-users" $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -# Create the group -New-LocalGroup -Name $Group - -# Add the user to the group -Add-LocalGroupMember -Group $Group -Member $CurrentUser +# Create the group only if it doesn't already exist +if (-not (Get-LocalGroup -Name $Group -ErrorAction SilentlyContinue)) { + New-LocalGroup -Name $Group +} + +# Add the user to the group only if they aren't already a member +if (-not (Get-LocalGroupMember -Group $Group -Member $CurrentUser -ErrorAction SilentlyContinue)) { + Add-LocalGroupMember -Group $Group -Member $CurrentUser +} ``` > [!NOTE]