Automatic creation of PointSharp ID users.

vertical-logo-blue-square-512

Created a short script that creates new Point Sharp ID users automaticaly.
You can set that to create a user in PointSharp ID the user need to be a member of a specific group.
When user is added to that AD group, the user is automaticaly created in PointSharp ID and password information is sent by email.


#PointSharp stores PointSharp ID users as a sub OU under the PointSharp OU. We get all these users, so we can compare them later down in the script.
$PSIDUsers = Get-ADOrganizationalUnit -SearchBase 'OU=PointSharp,DC=contoso,DC=no' -Filter * -SearchScope OneLevel | Select-Object City,Name

#People that need access to Skype for Business trough PointSharp is added to a Skype for Business AD group.
$SkypeGroups = 'SkypeUsers_Norway','SkypeUsers_England'

#Now we check to see if there are any members in the Skype for Business AD groups that does not have a PointSharp ID user.
#If we find someone, then the PointSharp ID user is automaticaly created and the user is sent a password email.
#If the name of the Skype for Business groups is the same as the userstorages in PointSharp, you can use the script as it is.
#If userstoragename is difrent then from the Skype for Business groups names, you would need to write a way to extract the
#name from the subfolders in the PointSharp OU.
$SkypeUsers = @()
foreach($SkypeGroup in $SkypeGroups)
{

    $users = Get-ADGroupMember -Identity $SkypeGroup
    foreach($user in $users)
    {

        $Object = [PSCustomObject]@{

        SamAccountName = $user.SamAccountName
        Userstoragename = $SkypeGroup

        }
        $SkypeUsers+=$Object

    }

}

foreach($SkypeUser in $SkypeUsers){

    $SUser = $SkypeUser.SamAccountName
    If($PSIDUsers.City -notcontains $SUser){

         $info=get-aduser -Identity $SUser -Properties mobile,mail
         $mail = $info.mail
         $mobile = $info.mobile
         $UserStorageName = $SkypeUser.Userstoragename

         $Create = @{

         username = "$SUser"
         userstoragename = "$UserStorageName"
         mail = "$mail"
         mobile = "$mobile"

         }
         $Create
         $JsonCreate = $create | ConvertTo-Json
         $ResponseCreate = Invoke-RestMethod 'http://localhost/api/user' -Method Post -Body $JsonCreate -ContentType 'application/json'

         $SendPassword = @{

         username = "$SUser"
         userstoragename = "$UserStorageName"
         actionflags = '2'

         }
         $SendPassword
         $JsonPassword = $SendPassword | ConvertTo-Json
         $ResponsePassword = Invoke-RestMethod 'http://localhost/api/password/send' -Method Post -Body $JsonPassword -ContentType 'application/json'

    }

}

<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s