I have a question i wrote a powershell script so i have name.ps1, but i have troubles for executing it, i mean i could debut it with windows powershell (ISE), by just adding the code to it and run … but how do i execute it different?
When i open ordinary windows powershell (so NOT ISE) and i type there script.ps1 file.csv
i get this kind of error:

This is the code that i have, maybe im not proper initiating the script in my code i dont know:
param ([string]$Csv)
function GetHelp() {
$HelpText = @"
DESCRIPTION:
NAME: Add-STUser
Adds Users from the User Csv File
PARAMETERS:
-Csv The Csv file Used by the script (Required)
-help Prints the HelpFile (Optional)
The Csv File is built up in the following way:
Firstname, Surname, Email
"@
$HelpText
}
function Get-Csv ([string]$Csv) {
$CsvFile = Import-Csv $Csv
$CsvFile | ForEach {
Add-User -Firstname $_.Firstname -Surname $_.Surname -Email $_.Email
}
}
function Add-User ([string]$Firstname, [string]$Surname, [string]$Email) {
# Set up AD Connectionstring
# Get A Unique Password
[string]$Password = Generate-Password
$username=$Firstname.substring(0,1).toLower() + $Surname.toLower()
# Create User in AD
$container =[ADSI] $Connection
$User = $container.Create("User", "cn="+$username)
$User.Put("sAMAccountName", $username)
$User.Put("givenName", $Firstname)
$User.Put("sn", $Surname)
$User.Put("mail", $Email)
$User.Put("displayName", $Firstname + " "+$Surname)
$User.SetInfo()
# Set Random Pwd and Enable Account
$User.PsBase.Invoke("SetPassword", $Password)
$User.PsBase.InvokeSet("AccountDisabled", $false)
$User.pwdLastSet = 0
$User.SetInfo()
# Write Pwd to File
$FileName = "PasswordList " + (get-date -uformat "%Y-%m-%d") + ".txt"
"$Firstname, $Surname, $username, $email, $Password" | Add-Content $FileName
Write-Host "Added User: $username" -ForegroundColor Green
# Set Check Variable to False
$Password = $Null
#$Script:sAMAccountNameDoesntExist = $False
#$Script:distinguishedNameDoesntExist = $False
}
if ($help) {
GetHelp
} elseif ($Domain -AND $Csv) {
Get-Csv -Csv $Csv
} else {
GetHelp
}
So with other words i need to execute that script with only 1 param (path to csv file)
Thanks in advance
In Powershell, unlike cmd, current directory (.) is not in PATH.
So to run scripts or executables in the current directory, you have to prefix with
./So you will have to do
If you look carefully at the error message, at the bottom, Powershell is giving a suggestion that you have to do so.