I am trying to pass a variable from PHP to a powershell script.
My PHP code is :
shell_exec("powershell.exe -ExecutionPolicy Bypass -NoProfile -InputFormat none -file test.ps1 '$txt' < NUL ");
And I am trying to capture it in powershell using :
param (
[string]$txt
)
Add-Content "test.txt" $txt
The $txt is a string variable as I can write it in a txt file from PHP. I do not know exactly where I am wrong as the powershell is executed.
test.txtnot getting created?-InputFormatparameter supports 'Text' or 'XML'. You give it 'none'. Try changing that toText. And shouldn't< NULbe> $null??