Hi All !
SMLets and Powershell are an important part of a flexible Service Manager Environement.
With the ability to fire Powershell scripts remotely, it makes sense to install Powershell on all
management servers and on the Orchestrator Server as well.
There 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 releases.
Here is the Stp-by-step guide how to do this.
Lets assume you want to prepare your DWH Management Server for SMlets
1.) Download SMLets from the link here.
2.) Install the SMLets. The install Location is: C:\Program Files\Common Files\SMLets
3.) Open a Powershell Command Interface as Administrator and set the Execution-Policy to „Unrestricted“
1 Set-ExecutionPolicy -ExecutionPolicy Unrestricted
4.) Copy 2 DLL´s from \\%SCSMMGMTServername%\c$\Program Files\Microsoft System Center 2012\
Service Manager\SDK Binaries to a local folder on the DWH Server i.e c:\transfer
1 Microsoft.EnterpriseManagement.Core.dll
1 Microsoft.EnterpriseManagement.ServiceManager.dll
5.) Open a CMD Command shell with Administrator rights and and enter the following command
1 copy c:\transfer\Microsoft.EnterpriseManagement*.dll c:\windows\assembly
6.) Change the file SMLets.psm1 in c:\Program Files\Common Files\SMLets
(be aware that the 2010 in the reg-Key is no typo !!)
This script shows the beginning of the files with the changes in RED.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 #requires -version 2.0# handy global variables$GLOBAL:SMADLL = ([appdomain]::CurrentDomain.getassemblies()|?{$_.location -match "System.Management.Automation.dll"}).location<span style="color: #ff0000;">#</span>$GLOBAL:SMDIR = (Get-ItemProperty 'hklm:/software/microsoft/System Center/2010/Service Manager/Setup').InstallDirectory<span style="color: #ff0000;">#</span>$GLOBAL:SMSDKDIR = "${SMDIR}\SDK Binaries"<span style="color: #ff0000;">#</span>$GLOBAL:SMDLL = "${SMSDKDIR}/Microsoft.EnterpriseManagement.Core.dll"$GLOBAL:EMGTYPE = "Microsoft.EnterpriseManagement.EnterpriseManagementGroup"$GLOBAL:DATAGENDIR = "$psScriptRoot\DataGen"<#.SYNOPSISLoad an assembly into the current process space.DESCRIPTIONProvides a quick way of loading an assembly into the current process..PARAMETER DllThe assemply to load. This can be either a file name or full path.EXAMPLEImport-Assembly "C:\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries\Microsoft.EnterpriseManagement.Core.dll".OUTPUTSNo output#>function import-Assembly{[CmdletBinding(SupportsShouldProcess=$true)]param ([parameter(Mandatory=$true,Position=0)]$dll ,[switch]$partial)end{$dllpath = (resolve-path $dll).pathif ( $partial ){[reflection.assembly]::LoadWithPartialName($dll)}else{[reflection.assembly]::LoadFile($dllpath)}}}# load the Service Manager Core assemblyset-alias -scope global load import-assembly<span style="color: #ff0000;">#</span>load $SMDLL | out-null<span style="color: #ff0000;">[reflection.assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core.dll") | out-null</span><span style="color: #ff0000;">$GLOBAL:smdefaultcomputer = "SCSMSERVERNAME"</span>
If the scripts fails to execute, add a global variable
1 $GLOBAL:PSScriptroot = "C:\Program Files\Common Files\SMLets"
at the beginning
7.) Now run the script, i.e. in the Powershell ISE Windows
8.) Start getting access to your SCSM Server by trying out:
import-module SMLets Get-SCSMWhoAmI Get-SCSMIncident
Have fun ! Roman