I have written a PowerShell module that contains a function with the following PARAM block.
PARAM(
[parameter(Mandatory = $true)]
[string] $ServerName,
[parameter(Mandatory = $true)]
[string] $SiteName,
[parameter(Mandatory = $true)]
[string] $CertificateName,
[parameter(Mandatory = $true)]
[string] $HostName,
[Microsoft.Web.Administration.SslFlags] $SslFlags
)
Sometimes when I call the function (of course, I import the PowerShell module it is in first) from a PowerShell script, it works fine. Other times it produces this runtime error.
Unable to find type [Microsoft.Web.Administration.SslFlags].
At <path_to_module>:877 char:9
+ [Microsoft.Web.Administration.SslFlags] $SslFlags
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Web.Administration.SslFlags:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
When that error occurs, it is always preceded by this error in the script.
Unable to find type [Microsoft.Web.Administration.SslFlags].
At <path_to_script>:110 char:13
+ $sslFlags = [Microsoft.Web.Administration.SslFlags]::Sni
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Web.Administration.SslFlags:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
What I am doing on line 110 of my script is attempting to set the value of a variable thusly:
$sslFlags = [Microsoft.Web.Administration.SslFlags]::Sni
What am I doing wrong? I've tried Google & Bing searches, but the results never address these errors that I only sometimes get.