Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've created a central repository for Powershell modules, but I'm having trouble loading one in particular. The NTFSSecurity module is failing to import with the following message.

PS Z:\> Import-Module NTFSSecurity
Add-Type : Could not load file or assembly 'file://\\fs\PowerShellModules\NTFSSecurity\Security2.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At \\fs\PowerShellModules\NTFSSecurity\NTFSSecurity.Init.ps1:141 char:1
+ Add-Type -Path $PSScriptRoot\Security2.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Could not load file or assembly 'file://\\fs\PowerShellModules\NTFSSecurity\PrivilegeControl.dll' or one
of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At \\fs\PowerShellModules\NTFSSecurity\NTFSSecurity.Init.ps1:142 char:1
+ Add-Type -Path $PSScriptRoot\PrivilegeControl.dll -ReferencedAssemblies $PSScrip ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Could not load file or assembly 'file://\\fs\PowerShellModules\NTFSSecurity\ProcessPrivileges.dll' or one
of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At \\fs\PowerShellModules\NTFSSecurity\NTFSSecurity.Init.ps1:143 char:1
+ Add-Type -Path $PSScriptRoot\ProcessPrivileges.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

Types added
NTFSSecurity Module loaded
Import-Module : Unable to find type [Security2.IdentityReference2]: make sure that the assembly containing this type
is loaded.
At line:1 char:1
+ Import-Module NTFSSecurity
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Security2.IdentityReference2:TypeName) [Import-Module], RuntimeExcept
   ion
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

I'm running Windows Managment Foundation 3.0 Beta, which includes PowerShell 3.0. I have a feeling that the new security measures introduced in .NET 4.0 are playing a part in this, but running Powershell.exe with the -version 2.0 switch doesn't fix anything either. I have modified my powershell.exe.config files in both the system32 and SysWOW64 folders to the following.

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
    <runtime>
        <loadfromremotesources enabled="true"/>
    </runtime>
</configuration>

The files are not "blocked", I've checked each one individually (as well as run Unblock-File on the directory). Permissions from the server end are fine, I've verified that I have access to everything. What have I not checked?

share|improve this question
add comment

1 Answer

It might be a corrupt file/bad download.

I was receiving the same error when trying to load the module from one of my scripts. I went and re-downloaded the newer v2.3 and extracted it into my Powershell Modules folder (C:\windows\system32\WindowsPowershell\v1.0\Modules\NTFSSecurity).

This solved my problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.