Skip to content

Install SMLets on server without SCSM console

Install SMLets on server without SCSM console published on 5 Comments on Install SMLets on server without SCSM console

SMLets module required to be installed on computer with SCSM console, also you must copy  Microsoft.EnterpriseManagement.Core.dll from SCSM server. But this requirement can be avoided by several simple steps. And this post describe how to do that.

Installing SMLets on separated server can be helpful on several scenarios, like Opalis\Orchestrator server or some server which must communicate with SCSM using PowerShell.

To install SMLets module you must complete 4 simple steps:

  1. Download and install SMLets on server
  2. Disable PowerShell script signing check
  3. Install SCSM assembly to the GAC (Global Assembly Cache)
  4. Edit SMLets file

Install SMLets

Firstly, download the latest version of SMLets and install it. At time of writing that post SMLets distributed as msi package so it can be easily installed on any server, even with UAC enabled. One small note: for production server you can disable Data Gen and test scripts components during install.

Disable PowerShell script signing check

By default PowerShell use Restricted policy for script execution. That mean that any executed script must be signing or execution will be aborted.

To change the policy you must run PowerShell with elevated permission (Run as Administrator) and execute next command:

Set-ExecutionPolicy Unresricted

After that the you must agree with changing the policy by pressing Y button.

Install SCSM’s assembly to the GAC

Now you must install  Microsoft.EnterpriseManagement.Core.dll and Microsoft.EnterpriseManagement.ServiceManager.dll assemblies to the GAC.

Simplest way to do that is:

  1. Open two Explore’s window, one with C:\Windows\Assembly folder, second with \\%SCSM_SERVER_NAME%\c$\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries\.
  2. Drap-and-drop Microsoft.EnterpriseManagement.Core.dll and Microsoft.EnterpriseManagement.ServiceManager.dll files to C:\Windows\Assemblyfolder.
  3. Check that Microsoft.EnterpriseManagement.Core and Microsoft.EnterpriseManagement.ServiceManager apeared in C:\Windows\Assembly folder:
    image

Edit the SMLets.psm1 file

Next step is a editing of the SMLets.psm1 file inside SMLets module. Module located in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SMLets folder. Note: on х64 servers you must use native x64 editor (like Notepad) to edit the SMLets.psm1 file. Also you must run the editor with elevated permission if UAC is enabled.

You must change the SMLets.psm1 file to this: (this is beginning of the file with necessary changes):

#requires -version 2.0
# handy global variables
$GLOBAL:SMADLL   = ([appdomain]::CurrentDomain.getassemblies()|?{$_.location -match "System.Management.Automation.dll"}).location
#$GLOBAL:SMDIR    = (Get-ItemProperty 'hklm:/software/microsoft/System Center/2010/Service Manager/Setup').InstallDirectory
#$GLOBAL:SMSDKDIR = "${SMDIR}\SDK Binaries"
#$GLOBAL:SMDLL    = "${SMSDKDIR}/Microsoft.EnterpriseManagement.Core.dll"
$GLOBAL:EMGTYPE  = "Microsoft.EnterpriseManagement.EnterpriseManagementGroup"
$GLOBAL:DATAGENDIR = "$psScriptRoot\DataGen"

<#
.SYNOPSIS
    Load an assembly into the current process space
.DESCRIPTION
    Provides a quick way of loading an assembly into the current process.
.PARAMETER Dll
    The assemply to load. This can be either a file name or full path
.EXAMPLE
    Import-Assembly "C:\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries\Microsoft.EnterpriseManagement.Core.dll"
.OUTPUTS
    No output
#>
function import-Assembly
{
    [CmdletBinding(SupportsShouldProcess=$true)]

    param (
        [parameter(Mandatory=$true,Position=0)]$dll ,
        [switch]$partial
        )
    end
    {
        $dllpath = (resolve-path $dll).path
        if ( $partial )
        {
            [reflection.assembly]::LoadWithPartialName($dll)
        }
        else
        {
            [reflection.assembly]::LoadFile($dllpath)
        }
    }
}
# load the Service Manager Core assembly
set-alias -scope global load import-assembly
#load $SMDLL | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core.dll")  | out-null

$GLOBAL:smdefaultcomputer = "SCSMSERVERNAME"

You must comment lines 4, 5, 6  and 45. Then you must add code to line 46 (this code load the SCSM assembly) and line  48 (that variable discribded in the prevision post, change this line to your server’s name). Note to GLOBAL prefix: this mean that variable will be accessibly from any context inside current session.

The End

That’s all. Run the PowerShell and execute any SMLets’s cmdlets:

import-module SMLets
Get-SCSMWhoAmI
Get-SCSMIncident

Share

5 Comments

Leave a Reply

Primary Sidebar

%d bloggers like this: