Closed M4CR0S closed 2 years ago
Judging by the error, it's as though SMLets isn't even installed despite that being part of the startup of the script. So I'm only guessing the workflow server is airgapped?
From an elevated PowerShell prompt on the workflow server run:
Install-Module SMLets
If the machine is airgapped, you'll need to install SMLets manually by downloading it from some internet connected machine here, copy it over, and install.
Management Server is not airgapped. Trying execute "Get-SCSMClass" I get a list of possible Classes using my Admin Account, also using Workflow Account.
import-module smlets; get-module smlets
SMLets Version: 4.1.1.5
IT's new installation from the scratch, no upgrades. SCSM 2022 and yes, I cannot get it running. Will try to execute PS-Script from console.
I've try it execute manually from console, and it works. All test emails were pulled from inbox to scsm.
HRMMMMM
Well, I am definitely going to be thinking about this given what you've laid out here because something doesn't add up:
🤔
Have you tried any of the solutions provided in this thread?
On Wed, Nov 16, 2022 at 8:55 AM Adam @.***> wrote:
Well, I am definitely going to be thinking about this given what you've laid out here because something doesn't add up:
- It will not run as the workflow account through SCSM workflows but it will run if you execute it manually in the console as the workflow account
- The error cites it can't find the cmdlet (e.g. it believes SMLets isn't installed) and yet you can find the commands/SMLets no problem in the above screenshots + you're on the latest/stable release of SMLets (e.g. v1)
🤔
— Reply to this email directly, view it on GitHub https://github.com/AdhocAdam/smletsexchangeconnector/issues/421#issuecomment-1317150530, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHC6WXG6HJ4OAQIIYUAQHLWITYWFANCNFSM6AAAAAASA5PAMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- MURAD AKRAM
*630-414-6731 - Cell708-316-8723 - Google @. @.>*
@AdhocAdam strange thing, I see Workflow tries do query directory for file names "Get-SCSMClass"
@muradakram thanks, unfortunately, here is not clear where I have to install "Orchestrator IP" and where is "PS Script Execution". SMLets seams to be already on the lates version. At the moment, I do not have orchestrator installed in my environment, yet.
But that is...interesting. I'll use the same approach and see what I can get.
@AdhocAdam ;) thanks
Alright so I didn't see anything out of the ordinary in Procmon. In fact, my Procmon begins identically to what you have above. And after a significant amount of scrolling, I begin to see:
Which makes me think this is perhaps a red herring as eventually the process/script/workflow runs successfully for me and logs the event in the SMLets Exchange Connector log accordingly. But as I've thought about this, I need to correct a point I made earlier/above:
The first part isn't technically true because the workflow does run, the workflow does kick off the PowerShell, but it's within the PowerShell it fails and you get an event logged to the Operations Manager event log which would happen because I don't have error handling for this case as you've originally outlined. So all things considered, SCSM is doing everything it should be doing but the script portion is failing. I'm also assuming this is PowerShell 5.1 which would automatically know how to import any module as it's only looking in a handful of directories but for the sake of argument, can you open up smletsexchangeconnector.ps1 and place
Import-Module smlets -ErrorVariable moduleSMLets
"custom smexco event $($(Get-Date).ToLongTimeString())" | out-file c:\temp\result.txt
$moduleSMLets | Out-File c:\temp\result.txt -Append
on the very first three lines and see if you get the same result? Of course, check out the result.txt file created here for any errors importing the module.
@AdhocAdam Yes, Yes, Yes Work as expected !!! One thing is, path, to customer event powershell script, should not have spaces otherwise it must be quoted.
Just to be clear, it now successfully imports the module, does not log any errors, and runs successfully?
Second, the path to the custom events script should be dot sourced in the Settings UI.
@AdhocAdam Yes, No Errors more. E-Mails will be pulled from inbox successfully. Sure, path to custom ps is doted but either quoted or use path without spaces.
@AdhocAdam Thanks For Your Quick Response And Support.
Thanks for using the connector. If you can spare a star for the repo it would be much appreciated 😄
sure
Describe the bug Execution error due run SMLets Connector. _Exception Message: The term 'Get-SCSMClass' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again._
Help us reproduce the bug Version of the connector you are using: SMLetsExchangeConnector 4.1.1.5 Features/variables you have enabled (i.e. $enableAzureCognitiveServicesForNewWI): No additional features are enabled
Expected behavior A clear and concise description of what you expected to happen.
Location and Environment Where are you running this from? Task Scheduler? SMA? Workflow server?: We execute it via imported Management Pack. What SCSM version are you running? 2022 10.22.1068.0
Additional context Here is exactly error message from event log:
A Windows Workflow Foundation workflow failed during execution.
Workflow Type: SMLets.Exchange.Connector.Resources.RunScript
Workflow Identifier: 7bdb4c11-31b8-bf66-e2ef-54de5d109462
Exception Type: System.Management.Automation.CommandNotFoundException
Exception Message: The term 'Get-SCSMClass' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Exception Stack: at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at SMLets.Exchange.Connector.Resources.RunScript.Execute(ActivityExecutionContext SMEXCOContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()