Invoke Powershell Activity stays in Running state

I am using this script below to imitate a flexible save file scenario and the code works fine in PowerShell console, but when I am trying to run it through invoke PowerShell activity it keeps on running without any output or error.

Script:
Add-Type -AssemblyName System.Windows.Forms

$saveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
$saveFileDialog.Filter = “All Files (.)|.
$saveFileDialog.FileName = “defaultFileName.txt”
$saveFileDialog.InitialDirectory = “C:\Path\To\Your\Default\Directory”

$result = $saveFileDialog.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
$selectedFilePath = $saveFileDialog.FileName
$selectedFilePath
} else {
“Dialog was canceled or closed without saving.”
}

Hi @Tusharkanta_Panda ,
This similar topic has solution
you can see

regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.