if(@(get-pssnapin | where-object {$_.Name -eq “FIMAutomation”} ).count -eq 0) {add-pssnapin FIMAutomation}

#$filter = “/Person[ObjectID=/Set[DisplayName=‘.Moodle - IAF Eligible Users’]/ComputedMember]”
$filter = “/RoleGroup[DisplayName=‘Kumar-SSA-Super Admin’]”
Export-Csv -Path “C:\Report\Roles.csv”

$persons = $null

$persons = export-fimconfig -uri $URI –onlyBaseResources -customconfig $filter

$i = 1;
$msg=“”
foreach($person in $persons)
{

$personsaccountname = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$.AttributeName -eq ‘AccountName’}).Value
$personsdisplayname = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$
.AttributeName -eq ‘DisplayName’}).Value
$prEmail = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$.AttributeName -eq ‘Email’}).Value
$prAEGISEnabled = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$
.AttributeName -eq ‘AEGISEnabled’}).Value
$prFirstName = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$.AttributeName -eq ‘FirstName’}).Value
$prLastName = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$
.AttributeName -eq ‘LastName’}).Value
$prExpirationTime = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$.AttributeName -eq ‘ExpirationTime’}).Value
$prLastLogonTime = ($person.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$
.AttributeName -eq ‘LastLogonTime’}).Value

$i = $i + 1;

If($prExpirationTime -eq $null) {
$prExpirationTime = ‘NA’;
}

If($prLastLogonTime -eq $null) {
$prLastLogonTime = ‘NA’;
}

$msg += $personsaccountname + ‘|’ + $personsdisplayname + ‘|’ + $prEmail + ‘|’ + $prAEGISEnabled + ‘|’ + $prFirstName + ‘|’ + $prLastName + ‘|’ + $prExpirationTime + ‘|’ + $prLastLogonTime;

Write-Host $msg

#Add-Content ‘F:\Kay\UserInfo.txt’ $msg
}
Export-Csv -Path “C:\Report\Roles.csv” -InputObject $msg

this is my script. When I’m try to run my script. I’m getting Invalid Operation Exception. Please help me in fixing

7 Spice ups

Welcome!

If you post code, please use the ‘Insert Code’ button. Please and thank you!

codebutton_small.png

1 Spice up

Post the exact error message (screenshot would be easy). Saves us time to read the entire script.

2 Spice ups

on which line do you get the error?

3 Spice ups