Thank you for your suggestions !
I will set “return” as array.
Issue, when I observe this undesired behaviour, usually happens when I run script more than once.
Script is much bigger and involve creating a new user from template or group, enable o365 mailbox etc…. and contains a lot of GUI elements. This specific problematic function is called when user support edit existing user (user got marid etc…) so type of rename operation, and then return new Distinguish name of effected user and proceed with next step (function) mail attribute modification… Issue is ,an I believe it will be solved with array, to return new distinguish name to proceed with next step of the process calling function that manipulate proxy address…
That is just sample of code its not…
function UpdateUserGroupMin {
Param
(
[Parameter(Mandatory = $true)] $SamAccountName_MIN,
[Parameter(Mandatory = $true)] $Name_MIN,
[Parameter(Mandatory = $true)] $GivenName_MIN,
[Parameter(Mandatory = $true)] $Surname_MIN,
[Parameter(Mandatory = $true)] $OtherName_MIN,
[Parameter(Mandatory = $true)] $DisplayName_MIN,
[Parameter(Mandatory = $true)] $Description_MIN,
[Parameter(Mandatory = $true)] $Company_MIN,
[Parameter(Mandatory = $true)] $UPN_MIN,
[Parameter(Mandatory = $true)] $Mail_MIN,
[Parameter(Mandatory = $true)] $DN_MIN,
[Parameter(Mandatory = $true)] $object_MIN,
[Parameter(Mandatory = $false)] $Errorlogpath
)
*
*
if ($object_MIN -eq "User")
{
If (!(([string]::IsNullOrEmpty($GivenName_MIN))))
{
Set-ADUser -Identity $DN_MIN -GivenName $GivenName_MIN
}
*
*
*
}
elseif ($object_MIN -eq "Group")
{
If (!(([string]::IsNullOrEmpty($DisplayName_MIN))))
{
Set-ADGroup -Identity $DN_MIN -DisplayName $DisplayName_MIN
}
*
*
*
}
Return ….