r/MicrosoftFlow•
KvothePha

Why does the same path definition work for one script but not for the other

Desktop

I am new to Power Automate, it is driving me crazy why in my workflow, when the first PowerShell script runs, it can find the path correctly:

^($outputFolder = "%OutputFolder.FullName%")
^($inputFolder = "%InputFolder.FullName%")
^($scriptPath = "C:\path\to\scripts\process_invoices.py")

^(Write-Output) ^("=== Variable Values ===")
^(Write-Output) ^("OutputFolder: $outputFolder")
^(Write-Output) ^("InputFolder: $inputFolder")
^(Write-Output) ^("========================")

^(# Verify folders exist)
^(Write-Output) ^("Output folder exists: $(Test-Path $outputFolder)")
^(Write-Output) ^("Input folder exists: $(Test-Path $inputFolder)")

^(# Run Python script)
^(& python "$scriptPath" "$outputFolder" "$inputFolder" 2>&1)

^(Write-Output) ^("Exit code: $LASTEXITCODE")

The PowerShell Output is:
^(=== Variable Values ===)

^(OutputFolder: C:\path\to\Output)

^(InputFolder: C:\path\to\Input)

^(========================)

^(Output folder exists: True)

^(Input folder exists: True)

But exactly the next PowerShell script that is executed:

^($outputFolder = "%OutputFolder.FullName%")
^($scriptPath = "C:\path\to\scripts\check_invoices.py")

^(Write-Output) ^("=== Variable Values ===")
^(Write-Output) ^("OutputFolder: $outputFolder")
^(Write-Output) ^("========================")

^(# Verify folders exist)
^(Write-Output) ^("Output folder exists: $(Test-Path $outputFolder)")

^(# Run Python script)
^(& python "$scriptPath" "$outputFolder" 2>&1)

^(Write-Output) ^("Exit code: $LASTEXITCODE")

The PowerShell Output 2 is:
^(=== Variable Values ===)

^(OutputFolder: %OutputFolder.FullName%)

^(========================)

^(Output folder exists: False)

^(Error: Excel file not found: %OutputFolder.FullName%\nise_numbers.xlsx)

^(Exit code: 1)

Posted Apr 1, 2026, 5:58 AM UTC

10
Loading comments…