Reputation: 53
I have Powershell class defined in ps1 file.
In main.ps1 i initialized that class
$class = [myClass]::new()
When,in Powershell ISE i open file and click [ for both class.ps1 and main.ps1 all works fine.
When i close PowerShell ISE, and open classic Powershell terminal (As Administrator), and execute
.folder\class.ps1
.\main.ps1
Then i'm getting following error after executing .\main.p1
from terminal
Unable to find type [myClass].
So how, from Powershell terminal, to initialize file with my class, without running Powershell ISE ?
Upvotes: 0
Views: 147
Reputation: 338396
Loading a file in Powershell is done with the .
operator.
. .\folder\class.ps1
Upvotes: 3