locked
SMlets wont load when running script created in authoring tool RRS feed

  • Question

  • I have created several PowerShell scripts to be run as workflows in SCSM 2012.

    If I run the script on the server, it seems to run fine.

    When I package it into a workflow, I get the following error in the SCSM console > workflow status area...

    The module loads file from the Shell, not sure why its not loading....

    System.Exception: The specified snap-in 'Smlets' failed to load with below exception
    
     System.Management.Automation.PSArgumentException: No snap-ins have been registered for Windows PowerShell version 2.
       at System.Management.Automation.PSSnapInReader.GetMshSnapinRootKey(RegistryKey versionRootKey, String psVersion)
       at System.Management.Automation.PSSnapInReader.Read(String psVersion, String mshsnapinId)
       at System.Management.Automation.Runspaces.MshConsoleInfo.AddPSSnapIn(String mshSnapInID)
       at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.DoAddPSSnapIn(String name, PSSnapInException& warning)
       at Microsoft.EnterpriseManagement.Modules.PowerShell.RunspaceConfigurationContainer.GetRunspaceConfiguration()
    
    
    Script Name:	DoWork.ps1
    
    
    One or more workflows were affected by this. 
    
    
    Workflow name: SendkNOCUpdateNotification.WindowsPowerShellScript.06fd4eec_26d7_4324_8b68_45ad531f4670
    
    Instance name: ServerName
    
    Instance ID: {33621AD1-1E38-D516-BD3D-B11910848594}
    
    Management group: KforceSM
    
       at Microsoft.ServiceManager.WorkflowAuthoring.ActivityLibrary.WindowsPowerShellScript.Activity_Closed(Object sender, ActivityExecutionStatusChangedEventArgs e)
       at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()


    Joshua Fuente

    Thursday, December 27, 2012 6:50 PM

Answers

  • I was able to "fix" this by calling the SMlets module from the literal path to the psd1 file.

     $a = (get-module|%{$_.name}) -join " "
     if(!$a.Contains("SMLets")){Import-Module 'C:\Program Files\Common Files\SMLets\SMLets.psd1' -ErrorVariable err -Force}


    Joshua Fuente

    Friday, December 28, 2012 1:29 AM