Pass-Argumets-to-Powershell


Scenario 1: Passing arguments to batch to powershell. This is powershell script we are passing 2 agrument from batch file and inside powershell script we will create 2 folder with these agrument name like Myarg1 Myarg2. Batch File

Example

 
    @echo off
    Powershell.exe -File  C:\test\Pass-Arguments-from-batchfile-to-powershell.ps1 Myarg1 Myarg2
    pause
    

Copy and Try it

Powershell File

Example

 
        $MyFirstArg=$args[0]
        $MySecondArg=$args[1]
        MKDIR c:\test\$MyFirstArg
        MKDIR c:\test\$MySecondArg
    

Copy and Try it





Output After double clicking or executing batch file 2 folders should get created with given name like here Myarg1 Myarg2

Scenario 2: Passing arguments to powershell from batch. Comming soon and also we will be adding more common scenarios.