Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

powershell script is not working in flow designer

Not applicable

Hi Team, 

 

This script is not working in the custom application:

 

We are giving the user name.

 

 

Import-Module ActiveDirectory -WarningAction SilentlyContinue

# Try to get the username from the environment variable
if (Test-Path env:\SNC_userName) {
$username = $env:SNC_userName
} else {
Write-Host "Environment variable 'SNC_userName' not found. Please provide a username."
exit
}

# Clean up the username if needed
$username = $username -replace "%27", "'"

# Validate the username
if ([string]::IsNullOrWhiteSpace($username)) {
Write-Host "Username is empty or invalid."
exit
}

# Get the user object
$userObj = Get-ADUser -Identity $username -Properties MemberOf

if ($null -eq $userObj) {
Write-Host "User '$username' not found in Active Directory."
exit
}

# Loop through each group and remove the user
foreach ($group in $userObj.MemberOf) {
Remove-ADGroupMember -Identity $group -Members $userObj -Confirm:$false
Write-Host "Removed $username from group $group"
}

 

Can you advise how to correct it?

 

Thanks and regards,

Chandan 

 

 

 

13 REPLIES 13

Hi @Community Alums ,

It's difficult to find the issue in flow.

Please open ECC Queue record for your execution and find the exact error there.

 

Regards,

Vishal

Not applicable

Is it possible to zoom link because in the ECC queue, I am not able find the error .

 

 

Thanks and Regards,

Chandan 

Not applicable

Hi @Vishal_Jaiswal ,

 

Is it possible to connect zoom call to discuss because i am not error in ECC queue.

 

 

Thanks,

Chandan 

Not applicable

Hi @Vishal_Jaiswal :

 

error is :Encountered error executing instruction: OpInstruction{id=4, opClass=com.snc.process_flow.operation.script.ScriptOperation, io=ReadOnlyDefaultOutputsIo{input={mid_selection=StringValue{fValue='auto_select'}, capabilities=StringValue{fValue=''}, responseBody=FlowReference{value=s2o.output}, mid_server=StringValue{fValue=''}, mid_cluster=StringValue{fValue=''}, user_name=FlowReference{value=s1o.user...

 

another error is :

{
    "Action Status": {
        "code": 1,
        "message": "Error:  E,Detail: Unexpected token: E"
    }
}

Please help me Resolution. 

 

 

Thanks and Regards,

Chandan  

Not applicable

@Vishal_Jaiswal : Could you please help me on this .

 

 

Thanks, and regards,

Chandan