Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

I am trying to add computer to the AD groups but The power shell code not running

crazysanty0
Kilo Explorer

I am trying to add computer to the AD groups
code:

Import-Module ActiveDirectory -WarningAction SilentlyContinue

$username = $userName -replace "%27","'";
$groups = @()
$groups = $groupNames -replace ' "','' -replace '"','' -replace ' ]','' -replace '\[','' -replace '%27','''' -split ","

try
{
$result = Add-ADPrincipalGroupMembership -Identity $username -MemberOf $groups -Credential $cred -Server $computer
$status = "Success"
}
catch
{
$result = $_.Exception.Message
$status = "Error"
}

$response = @{
status = $status
body = $result
} | convertTo-Json

Write-Output $response
error : the action not run it is in inprogress

crazysanty0_0-1762423865331.png

I am assuming the after mid server restart...the flow is not running.. how to fix this

 





0 REPLIES 0