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
}