OK This is the function for PRIMARYGROUPNAME that returns the full name of primari group (I use a version that involve .ini file, but works like this)
code:
Function GetPrimaryGroup($Computer,$user)

$UserObj = GetObject("WinNT://$Computer/$User,USER")
$PGID=$UserObj.PrimaryGroupID
$UserObj=0
$domain = GetObject("WinNT://$Computer")
$domain.filter = GROUP,""
$GetPrimaryGroup=""
For Each $Group IN $domain
$GroupName=$Group.Name
$AdsiPath="WinNT://$Computer/$GroupName,GROUP"
$gr = GetObject($AdsiPath)
$GRID = GetRID($AdsiPath)
If $GRID=$PGID
$GetPrimaryGroup=$GroupName
Return
EndIf
$Domain=0
EndFunction

Here is an example of use:

? GetPrimarygroup("SOLE","pagan")

MR. Howard Bullock, any update or other ideas to set PrimaryGroupID?