Hello

I am trying to export data via a script in a Business Rule for multiple users when their password is reset in the Web console, and I am having the following issue:

  • It only returns one row of values, not each row for each user

Code being used:

$csvFilePath = "C:\Scripts\Report.csv" # TODO: modify me
$removeCsvFile = $True # TODO: modify me

$usernames = $Context.TargetObject.GetPropertyValues("Name")

$Data = foreach ($user in $usernames) {

[pscustomobject]@{
    'First Name' = "%givenName%"
    'Last Name' = "%sn%"
    'Email' = "%mail%"
    'P' = "%unicodePwd%"
        }
}

$Data | Export-Csv -Path $csvFilePath -NoTypeInformation
ago by (220 points)

1 Answer

ago by (16.3k points)
0 votes

Hello,

Business rules trigger for each object separately, even if a bulk operation is performed on multiple objects. In your case, the business rule triggers, and the script is executed for each user whose password is reset. If you need to export the property values of all users whose passwords were reset, you can get the values of a single user and append them to the export file in the script. To do so, specify the -Append parameter in the Export-Csv cmdlet.

Related questions

We have some accounts that we would like to prevent from changing their password on login when it is expired. This is because we have saml setup on individual interface pages ... of a loophole for us as we require dual factor and use saml to accomplish this.

asked Oct 26, 2021 by mark.it.admin (2.3k points)
0 votes
1 answer

Hello, I want to give the ability for the Help Desk to add a new IE trusted site. I did a Custom Commands that works well. $scriptBlock = Powershell { Import-Module Adaxes Import ... ( $Zone). The GPO name ($GPOName)will never change. It is possible to do it?

asked May 31, 2016 by tentaal (1.1k points)
0 votes
0 answers

I get this question quite a bit.... Our staff is used to being able to paste a well-formed listing of users into "Active Directory Users and Computers" when they are ... the web interface)? If not, are you considering adding this ability in the future? Thanks!

asked May 22, 2012 by BradG (950 points)
0 votes
1 answer

I'm trying to schedule a report to look in a few specific OUs. Currently "Look in" location only allows for single instance or multiple drop downs. How do I schedule multiple OU locations without creating multiple reports?

asked Jul 2, 2020 by Al (20 points)
0 votes
1 answer

Is it possible to only allow a user to unlock their account from the web interface? We have a group of Mac users who we'd like to be able to unlock their accounts through the web but use a different service for changing their passwords.

asked Jun 30, 2020 by scoutcor (180 points)
0 votes
1 answer