Powershell within SQL 2012 SP1 can not load any modules

  • I have been attempting to run a Powershell script from a SQL Server agent job on SQL2012. The script runs fine in SQL 2008R2 however, I receive the below error when attempting to import any module in SQL2012.

    I am able to import modules when running PS from Windows (on the SQL2012 Server) however, they can not be loaded when running PS from Management Studio or from the SQL Agent.

    I can replicate this issue on several SQL2012 servers.

    PS SQLSERVER:\SQL\SERVERNAME\DEFAULT> import-module ActiveDirectory

    import-module : The 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveD

    irectory\ActiveDirectory.psd1' module cannot be imported because its manifest c

    ontains one or more members that are not valid. The valid manifest members are

    ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyrigh

    t', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName',

    'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArch

    itecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToP

    rocess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'Functi

    onsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remov

    e the members that are not valid ('HelpInfoUri'), then try to import the module

    again.

    At line:1 char:14

    + import-module <<<< ActiveDirectory

    + CategoryInfo : InvalidData: (C:\Windows\syst...eDirectory.psd1:

    String) [Import-Module], InvalidOperationException

    + FullyQualifiedErrorId : Modules_InvalidManifestMember,Microsoft.PowerShe

    ll.Commands.ImportModuleCommand

    I can view the modules as well:

    PS SQLSERVER:\SQL\SERVERNAME\DEFAULT> get-module -listAvailable

    ModuleType Name ExportedCommands

    ---------- ---- ----------------

    Manifest ActiveDirectory

    Manifest ADCSAdministration

    Manifest ADCSDeployment

    Manifest ADDSDeployment

    Manifest ADFS

    Manifest ADRMS

    Manifest ADRMSAdmin

    Manifest AppLocker

    Manifest Appx

    Manifest BestPractices

    Manifest BitsTransfer

    Manifest BranchCache

    Manifest CimCmdlets

    Manifest DFSN

    Manifest DirectAccessClientComponents

    Manifest Dism

    Manifest DnsClient

    Manifest GroupPolicy

    Manifest International

    Manifest iSCSI

    Manifest IscsiTarget

    Manifest ISE

    Manifest Kds

    Manifest Microsoft.PowerShell.Diagnostics

    Manifest Microsoft.PowerShell.Host

    Manifest Microsoft.PowerShell.Management

    Manifest Microsoft.PowerShell.Security

    Manifest Microsoft.PowerShell.Utility

    Manifest Microsoft.WSMan.Management

    Manifest MMAgent

    Manifest MsDtc

    Manifest NetAdapter

    Manifest NetConnection

    Manifest NetLbfo

    Manifest NetQos

    Manifest NetSecurity

    Manifest NetSwitchTeam

    Manifest NetTCPIP

    Manifest NetworkConnectivityStatus

    Manifest NetworkTransition

    Manifest MSFT_NfsMappedIdentity

    Manifest NFS

    Manifest PKI

    Manifest PrintManagement

    Manifest PSDiagnostics

    Manifest PSScheduledJob

    Manifest PSWorkflow

    Manifest PSWorkflowUtility

    Manifest RemoteDesktop

    Manifest ScheduledTasks

    Manifest SecureBoot

    Manifest ServerCore

    Manifest ServerManager

    Manifest ServerManagerTasks

    Manifest SmbShare

    Manifest SmbWitness

    Manifest Storage

    Manifest TroubleshootingPack

    Manifest TrustedPlatformModule

    Manifest UserAccessLogging

    Manifest VpnClient

    Manifest Wdac

    Manifest WebAdministration

    Manifest Whea

    Manifest WindowsDeveloperLicense

    Manifest WindowsErrorReporting

    Manifest SQLASCMDLETS

    Manifest SQLPS

    Here is my version info:

    PS SQLSERVER:\SQL\ServerName\DEFAULT> $psversiontable

    Name Value

    ---- -----

    CLRVersion 2.0.50727.6413

    BuildVersion 6.1.7600.16385

    PSVersion 2.0

    WSManStackVersion 2.0

    PSCompatibleVersions {1.0, 2.0}

    SerializationVersion 1.1.0.1

    PSRemotingProtocolVersion 2.1

    Any help would be greatly appreciated.

  • This occurs when importing PowerShell 3.0 modules in PowerShell 2.0.

    I don't know if this is your issue but some forum posts talk about passing a "-version 3.0" parameter.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply