0

How to pass the value of a variable from batch to powershell?

I'm trying to use the command from this link:
https://stackoverflow.com/questions/6359618/pass-parameter-from-a-batch-file-to-a-powershell-script

A string is passed in the link, but can a variable also be passed?

Command used in the batch file:

powershell.exe -executionpolicy remotesigned -File "C:\Users\%username%\Desktop\Normalize_LUFS\LUFS.ps1 %vLUF%"

Setting parameters at start of Powershell script:

$sw = $args[0]

$logMatches = Select-String -Path "C:\Users\$env:username\Desktop\Logs_LUFS\*.log" -Pattern '(?<I>^ +I:) +(?<LUFS>.+)|
(?<I>^Input Integrated:) +(?<LUFS>.+)' -List Out-File "C:\Users\$env:username\Desktop\Logs_LUFS\List.txt"

Is the $sw variable that will receive the value from the vLUF variable of the batch file?

1 Answer 1

0

This is how it works:

In the batch file:

powershell.exe -executionpolicy remotesigned -File C:\Users\%username%\Desktop\Normaliza_LUFS\ArqsVolAbaixo_LUFS_informado.ps1 %vLUF%

Setting arguments at start of Powershell script:

Param(
     [decimal]$env:vLUF
)

[decimal]$vLUFps = $env:vLUF

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .