I have script step1.ps1 & it contains the code:
echo "Starting with Step 3: Configuring the OS..."
echo "$args[0] and $args[1]"
step3.ps1 $args[0] $args[1]
I execute this script
powershell.exe install.ps1 <ip-address> <hostname>
Now when step1.ps1 is executed it calls script step3.ps1 & it contains the code:
echo "checking step3"
echo $args[0] and $args[1]
ac -Encoding UTF8 "$($env:windir)\system32\Drivers\etc\hosts" $args[0] $args[1]
echo "HANA DB Host file entry maintained"
It gives me an error:
powershell.exe : Add-Content : A positional parameter cannot be found that accepts argument '<hostname>'.
At line:1 char:1
+ powershell.exe install.ps1 <ip-address> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Add-Content : A...
'vue2dvdbhs5'.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
At step3.ps1:3 char:1
+ Add-Content -Value $args[0] $args[1] -Path "$($env:windir)\system32\D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Content],
ParameterBindingException
+ FullyQualifiedErrorId :
PositionalParameterNotFound,Microsoft.PowerShell.Commands.AddContentCommand
$argsarray when you can use named parameters?