Dynamic Input Handling for PowerShell Script

Hi All,

Currently, there is a PowerShell script (.ps1) that takes input from a .csv file.
We need to update the script to accept input dynamically. For Example, when a user Submitted data through Quick Link Form, then data should be taken from the Form and used as input for the PowerShell script(.ps1) file.

Can anyone help/provide suggestion regarding the above use case.

Thanks,

Akash

How you are currently passing the csv file to script?

Hi @shirbhatea ,

Thank you,
Currently we are taking CSV file from some specified location in.ps1 file
For Example:
$FileName = “\\abcd\efg\testing\qwe\ert”+ “.csv”
By using $FileName retrieving all the data available in .csv file.

Thanks,

Akash

oks, I am not sure how is the input params handle in your script. it would be good if you share some snippet from the file.

You can simply execute the power shell script with .\MyScript.ps1 “input1” “Input2”

Regards
Ankush

@AkashRaavi131 - How are you calling the powershell script from Sailpoint IIQ?

HI Amit Kumar,
Thank you,

We are trying to call the powershell script as provided below example.

Could you please correct me if i am wrong.

Example:
try {
#3 Exchange : Enable user mail box
$exchange = “C:\SailPoint\Exchange_onprem.ps1” “input1” “Input2”
$command3 = -join ($exchange, " -samAccountName ‘$samAccountName’ -mailPfx ‘$mailPfx’ -mail ‘$mail’")
$exchange_result = Invoke-Expression $command3
} catch {
$ErrorMessage = $.Exception.Message
$ErrorItem = $
.Exception.ItemName
LogToFile(“Mailbox Error: Item = $ErrorItem → Message = $ErrorMessage”)
}

Thanks,
Akash

HI @shirbhatea ,
Providing the path where CSV file is located in .ps1 file.

Thanks,

Akash