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:
- Download and install SMLets on server
- Disable PowerShell script signing check
- Install SCSM assembly to the GAC (Global Assembly Cache)
- 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:
- 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\.
- Drap-and-drop Microsoft.EnterpriseManagement.Core.dll and Microsoft.EnterpriseManagement.ServiceManager.dll files to C:\Windows\Assemblyfolder.
- Check that Microsoft.EnterpriseManagement.Core and Microsoft.EnterpriseManagement.ServiceManager apeared in C:\Windows\Assembly folder:
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
5 Comments
[…] are a couple of How-To´s on the web, especially this one but no actual one for SCSM2012 and SMLets Beta4, which are the current […]
[…] install SMLets on each runbook server and configure SCSM default server name. How to do that I’ve already describe early. That article was wrote for SMLets Beta 3 but can be used for Beta 4 too. The only different is way […]
[…] SMLets on a computer it must have some of the SCSM console DLLs installed. Anton Gritsenko wrote this great article about how to install these without the need to install the SCSM console. However, due to some of […]
[…] Pour cela, vous pouvez suivre cette article d'Anton Gritsenko: http://blog.scsmsolutions.com/2011/08/install-smlets-on-server-without-console/ […]
[…] SMLets on a computer it must have some of the SCSM console DLLs installed. Anton Gritsenko wrote this great article about how to install these without the need to install the SCSM console. However, due to some of […]