if (-not ([System.Management.Automation.PSTypeName]'MyClass').Type) { Add-Type -TypeDefinition 'public class MyClass { }' }