0

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 [Run script (F5)[1] 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 ?

1
  • 1
    Load the class using the '.' operation first . .\folder\class.ps1 Commented Nov 22, 2019 at 8:50

1 Answer 1

3

Loading a file in Powershell is done with the . operator.

. .\folder\class.ps1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.