Hello all,
Having a problem returning values from a function. Could realy use some help cause i cant manage to get this working.
Function Process-ADObj($owner)
{
$ADObj = 0
$aclType = $ACL_TYPE_LOCAL
$Domain,$owner = $owner -split "\\",2
$SamAccountName = Get-ADUser -identity $owner -Properties SamAccountName |select SamAccountName -ExpandProperty SamAccountname
$UserPrincipalName = get-ADUser -identity $owner -Properties UserPrincipalName |select UserPrincipalName -ExpandProperty UserPrincipalName
$DistinguishedName = get-ADUser -identity $owner -Properties DistinguishedName |select DistinguishedName -ExpandProperty DistinguishedName
$sqlCmd = $sqlConn.CreateCommand()
$sqlCmd.Parameters.AddWithValue("@login" ,$samAccountname)
$sqlCmd.Parameters.AddWithValue("@domain" ,$GLOBALDOMAIN)
$sqlCmd.Parameters.AddWithValue("@name" ,$DistinguishedName)
$sqlCmd.Parameters.AddWithValue("@update" ,$date)
$sqlCmd.Parameters.AddWithValue("@pincipal",$UserPrincipalName)
$sqlCmd.CommandText = "INSERT INTO [USERINFO] ([LOGIN],[DOMAIN],[NAME],[UPDATE],[PINCIPAL]) VALUES (@user,@domain,@distin,@update,@pincipal)";
$sqlCmd.ExecuteNonQuery();
$ADObj = SqlSelectInteger "SELECT USER_ID FROM USERINFO where USER_LOGIN ='$owner'";
#write-host $ADObj (IT writes the Id Correclty)
return $aclType, $ADObj
}
$Ownerreturn = Process-ADObj($Owner)
$folderOwner = $Ownerreturn[1]
But instead of returning the ID stored in $ADObj it returns object information