In our “HOW TO Series” we want to show you, how to use a PowerShell Script to Self Service your IT with au2mator. In this Article, we will demonstrate how easy it is, to use PowerShell and au2mator to “Add an User to a Group”.

Our Service should provide a User Selection and a Group Selection, the PowerShell Script will add the Active Directory User in this AD Group.

PowerShell Script

At the beginning, and very important, the Input Paramaters. beside our “Built in Parameters” we have to add one for the selected User, one for the Group and a Comment.

#region InputParamaters
##Question in au2mator
param (
    [parameter(Mandatory = $true)] 
    [parameter(Mandatory = $true)] 

    [parameter(Mandatory = $false)] 

## au2mator Initialize Data
    [parameter(Mandatory = $true)] 

    [parameter(Mandatory = $true)] 
    [parameter(Mandatory = $true)] 
    [parameter(Mandatory = $true)] 
#endregion  InputParamaters

The Main Part of the Script, see the End of the Post, to download the complete Script

#region Script
Write-au2matorLog -Type INFO -Text "Start Script"
if ($DoImportPSSession) {

    Write-au2matorLog -Type INFO -Text "Import-Pssession"
    $PSSession = New-PSSession -ComputerName $DCServer
    Import-PSSession -Session $PSSession -DisableNameChecking -AllowClobber
else {

Write-au2matorLog -Type INFO -Text "Import AD PS Module"
Import-Module ActiveDirectory

Write-au2matorLog -Type INFO -Text "Try to add User in Group"

if (Get-ADGroupMember -Identity $c_Group | Where-Object -Property DistinguishedName -Value $c_User -EQ)