I know that invoke-expression is a cmdlet I try my best to stay away from. This is the only way though that I can seem to create an object that I need to create dynamically during execution. Is there a better way?
$newObject = (Invoke-Expression "[$name]::New()")
If I'm running code and I find while I'm running that I need to create a type called [somedevelopers.class] once I've imported their dot net class.. I'd need to do
$test = [somedevelopers.class]::new()
I want to be able to detect that class name and then dynamically create the class. if you try to create a class with
[$variableNameThatContainsTheDevClass] then you'll get an error from powershell.
So the only way I can create that class dynamically is to do what I've shown above. Was curious if anyone else had a better or different way of doing the same thing.