I am novice to power shell and I am not able to figure this very simple code out and have a question:
I have a basic script c:\Folder\abc.ps1:
function abc
{
Param(
[parameter(Mandatory=$false]
$Env
}
Write-Output "The parameter is: $Env"
}
abc $Env
Now calling this script from command line:
C:\Dev> . "c:\Folder\abc.ps1" "Dev"
The parameter is:
C:\Dev> . "c:\Folder\abc.ps1" "Dev"
The parameter is:
Now if I initialize the Env then that works;
C:\Dev> $Env = "Dev"
C:\Dev> . "c:\Folder\abc.ps1"
C:\Dev> The parameter is: Dev
I would love to make this in one line like above from any location rather than the folder where it is placed. I am using the Power shell from the Power shell prompt in Windows Environment
Your help is appreciated
$envas that is the same name as the environment variable.