In this column, we are going to use PowerShell to resolve a couple of issues I’ve seen.
Click here if you’d rather watch a video explaining this.
The first one is an error you may get when running an integration.
The error is:
[The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.]
The background for this error is that when SmartConnect encounters an error, it writes it to the SmartConnect event log. In order to do this, you need to register your event log with Windows but good coding practices means that the developer should first check to see if the event source exists before trying to create it.
This should have happened during the install but for some reason it did not and now the user would get this error.
I talk about this registration process in another blog article I wrote a number of years ago for those readers that are interested in the details.
The second “issue” is more of a “nice to have” feature.
Typically on the SmartConnect install, SmartConnect gets registered to the SmartConnect event log. But sometimes we have seen it get registered to the Windows Application event log.
While this doesn’t cause any harm to the system – SmartConnect will work fine – it does cause a bit of confusion for the end user when you read a Knowledgebase article or talk to support when we ask you to “check the SmartConnect event log for errors” since the machine doesn’t have one.
To resolve both of these issues, I’ve created a PowerShell script that registers the SmartConnect event log sources in the expected locations.
To run the PowerShell script (found here):
Make sure to log into the machine as a user with Administrator rights to the machine.
Download and copy the eOne_RegisterEventSource.ps1 file to a convenient location. Since we will have to manually type in the path to the file, I chose a nice easy path – c:tempLaunch PowerShell on your computer. How you do this depends on your Windows version. On my Windows 8 machine, I just searched for it. Make sure to “run as administrator”
The PowerShell command window will open in “Administrator” mode.
The next thing we need to do is make sure that we can actually execute PowerShell code. By default in Windows, it is disabled.
At the command prompt, type in (one line at a time)
The first line gets the current state of the execution policy for use later. The second line changes the execution policy to run any PowerShell code.
When you run the Set-ExecutionPolicy line, you will get a Security prompt:
Press the Enter key to accept this.
Next, we need to execute the eOne_RegisterEventSource.ps1 script.
This is where copying the file to a short path is convenient – enter the path to the file next and then press Enter to execute the script.
The window should now show that the script executed.
The output of the script should be:
Register: eOneSmartConnect
Register: Smart Connect Service
Done!
If you get any other output – typically in red – that means an error occurred. Most likely the error is either you aren’t admin on the machine and therefore cannot read the event source (the error we are trying to fix in SmartConnect) or else possibly you didn’t run PowerShell using “run as administrator”.
Assuming we made it this far, the last step is optional. We should set the execution policy to what it was previously – most likely Restricted.
Set-ExecutionPolicy $policy
You will get the same Security message as before and again press Enter to accept the change.
If we are creating the new event logs, that will take effect right away – SmartConnect should no longer give the Security logs error message that it did previously. I should note that the powershell script also registers the eConnect event log as well as that event log source is also sometimes not registered properly.
If we are changing the SmartConnect source to use the SmartConnect event log, you will have to reboot your machine for this to take effect.
Do you have a topic you’d like discussed for the next Tech Tuesday? Email us at sales@eonesolutions.com!