Hi,
This is working from running PS1 but not working when running PS1 from batch file:
sprint2.ps1:
-----------
Set-StrictMode -Version Latest
$var1main=""
$var1=""
if ($var1main -eq $var1) {.\script1.ps1}
$var1main=$var1
Write-Host ("Value 1 main: " + $var1main)
sprint1.ps1:
-----------
Set-StrictMode -Version Latest
$global:var1=0
$global:var11=0
if ($var11 -eq 0)
{
$var1=3
}
else
{
$var1=4
}
Write-Host ("Value 1: " + $var1)
$global:var1=$var1
Result of script2.ps1:
---------------------
Value 1 main: 3
test1.bat:
----------
powershell.exe " &""<Scriptpath>\script2.ps1"""
Result of test1.bat: Value 1 main: null
When running script2.ps1 from test1.bat batch file, "Value 1 main" is null but when running script2.ps1, the "Value 1 main" is 3.
Please help. what could be the issue.
This is working from running PS1 but not working when running PS1 from batch file:
sprint2.ps1:
-----------
Set-StrictMode -Version Latest
$var1main=""
$var1=""
if ($var1main -eq $var1) {.\script1.ps1}
$var1main=$var1
Write-Host ("Value 1 main: " + $var1main)
sprint1.ps1:
-----------
Set-StrictMode -Version Latest
$global:var1=0
$global:var11=0
if ($var11 -eq 0)
{
$var1=3
}
else
{
$var1=4
}
Write-Host ("Value 1: " + $var1)
$global:var1=$var1
Result of script2.ps1:
---------------------
Value 1 main: 3
test1.bat:
----------
powershell.exe " &""<Scriptpath>\script2.ps1"""
Result of test1.bat: Value 1 main: null
When running script2.ps1 from test1.bat batch file, "Value 1 main" is null but when running script2.ps1, the "Value 1 main" is 3.
Please help. what could be the issue.