Active Roles Workflow Issues

I have been attempting to use a workflow to deprovision/remove inactive licenses. I am fairly new to Active roles and have this script to declare a function.

This will export the results of a search I am utilizing, but whenever I add the lines regarding the password last set date and last logon date it errors out. Am I missing something glaring?

function ExportFoundUsersTest($Request)
{

#Workflow search name
$SearchName = [string]$PolicyEntry.Parameter("Define workflow action name")
$Filename = [string]$PolicyEntry.Parameter("Filename")

#$PolicyEntry.Parameter("Filename") | Out-File "C:\temp\policyname2.txt"

$Filepathprefix = "C:\temp\"
$Filepathsuffix = ".csv"
$currentDate = Get-Date -Format "yyyy-MM-dd"
$Filepath = $Filepathprefix + [string]$PolicyEntry.Parameter("FileName") + " - " + $Currentdate + $Filepathsuffix
$Currentdate | Out-File "C:\temp\filedate.csv"

$Usersam = $workflow.FoundObject($SearchName).get("samaccountname", "pwdLastSet", "LastLogon")
$UserLPD = $workflow.FoundObject($SearchName).get("pwdLastSet")
$UserLLD = $workflow.FoundObject($SearchName).get("LastLogon")

# Write the user DN to a file
Add-Content -Path $filepath -Value $Usersam, $UserLPD, $UserLLD

}

Parents
  • I am suspicious of this line:

    $Usersam = $workflow.FoundObject($SearchName).get("samaccountname", "pwdLastSet", "LastLogon")

    I don't believe you can request more than one attribute at a time.

    I think it should be like this:

    $Usersam = $workflow.FoundObject($SearchName).get("samaccountname")

    The other two lines should be fine.

    Also, is your workflow's Search Activity really called "Define workflow action name"???  

Reply
  • I am suspicious of this line:

    $Usersam = $workflow.FoundObject($SearchName).get("samaccountname", "pwdLastSet", "LastLogon")

    I don't believe you can request more than one attribute at a time.

    I think it should be like this:

    $Usersam = $workflow.FoundObject($SearchName).get("samaccountname")

    The other two lines should be fine.

    Also, is your workflow's Search Activity really called "Define workflow action name"???  

Children
No Data