Click here to Skip to main content
15,896,338 members

Not able to acheive Multilevel calling of Powerscript files using Batch file

Madhusudan Nagaraja asked:

Open original thread
Hi,

I have listed below sample code through which am trying to acheive Multilevel calling of Powescript files Batch file.
SingleLevel.ps1
function SingleLevel{
Write "This function is called directly from the batch file"
MultiLevel
}
MultiLevel.ps1
fucntion MultiLevel{
Write "This function is called from within SingleLevel function"
}

TestCall.ps1
SingleLevel

Scenario 1 : I have 3 files SingleLevel.ps1 and MultiLevel.ps1 and TestCall.ps1 all of which are placed in same folder and the same is set as environment path.
When i run the TestCall.ps1 file through Powershell Command Window we get the following output:
O/p
This function is called directly from the batch file
This function is called from within SingleLevel function
Scenario 2 : I have a batch file as coded below which calls SingleLevel,ps1
TestBatch.bat
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -file X drive:\X Folder\SingleLevel.ps1

Expected : SingleLevel.ps1 should have called MultiLevel.ps1.
Actual issue : MultiLevel.ps1 file is not called ..
I really appreciate any help regarding this :)

Regards,
Madhusudan
Note : I have set the environment variable "path" to appropriate path to enable it to fetch requied custom library functions.
Tags: PowerShell

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900