I have a class in the PowerShell module file. (A.psm1)
class A {
[void] printString() {
write-host 111
}
}
And I also have a simple script that uses that class.
Using module C:\temp\A.psm1
$a = [A]::new()
$a.printString() # prints 111
But if I change the method from the class, for example, as shown here (replace 111 on 222)
[void] printString() {
write-host 222
}
and if I relaunch my script it will still print 111. Only if I restart the PowerShell console it will print the new value.
If I worked only in the console, I could use the Import-Module ... -Force command. But it doesn't work in the script.
So is there a way to reload the PowerShell module every time the script is launched without restarting the console itself?
