-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
The Issue
I am trying to create a PowerShell-Project with my own custom PowerShell-Classes.
I use explicit type defintion for all attributes of my custom classes. For all integrated .Net-Classes there is now problem, but for other classes (for example external dll) it does not work.
It seems like, that you have to create a Wrapper script which loads the dll / Imports the module and afterwards starts the actual script project (with custom classes) by dotsourcing.
Unfortunately this workaround (Wrapper-Script) does not work out in my scenario --> A automation / orchestration engine only accepts one script...
So is there a way to fix this? The Parser should not throw an error, as you declare (using statement) that you will use classes out of this namespace. If there is something wrong with the class itself.. .this should be a runtime exception, or am I wrong?
Steps to reproduce
using namespace Microsft.ActiveDirectory.Management
#These two do not work, too
#using module ActiveDirectory
#Import-Module ActiveDirectory
class Test
{
[Microsoft.ActiveDirectory.Management.ADDomain] $domain;
}
...Expected behavior
no Error Message
Actual behavior
At line:9 char:6
+ [Microsoft.ActiveDirectory.Management.ADDomain] $domain;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unable to find type [Microsoft.ActiveDirectory.Management.ADDomain].
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TypeNotFoundIn this case with an integrated .NET class it perfectly works.
using namespace System.DirectoryServices.ActiveDirectory
Class Test
{
[Domain] $dom = [Domain]::GetCurrentDomain()
}