4
votes

I have a problem I cannot solve without help ) I have SCOM in first PC, and I have SCOM agent in second. When my class discoveries in agent PC, it must run PowerShell script. This script contains command:

Import-Module FailoverClusters

but this command fails with exception:

The following error occurred while loading the extended type data file: Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FailoverClusters\FailoverClusters.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".

I dont know what to do.

3

3 Answers

3
votes

As this blog post points out, you can ignore extended type data errors when loading modules. It's telling you that the type is already loaded and it can't load it a second time.

1
votes

WORKAROUND:

I found that with SCOM 2007 R2 (haven't tested this on SCOM 2012), powershell fails to import FailoverClusters module. I tried the suggestion to skip the error. Skipping works the very first time the agent executes the script. After that, subsequent executions of the script fail to have the Get-Cluster cmdlet available. Whenever you restart the agent, it skips the error and the cmdlet is available, but again subsequent executions fail to load the cmdlet. Elevated permissions and unrestricted script execution didn't help the issue.

Restarting the agent regularly is such a sledge hammer. I did not entertain it.

However I did find that if I used a light-weight script that spawns a new powershell instance and executes my main code (file saved on disk or generate the script on disk on the fly), the fresh powershell instance loaded the module successfully every time and the cmdlet was always available.

I know there are concerns that spawning one instance from another (like vbscript spawing powershell) has perf issues. But in my case, I was able to have the agent call my powershell wrapper, generate a 500 line script on the fly (using streamwriter for perf), and then spawn it in a fresh powershell form the wrapper. It all executed in about 6 seconds, which included querying Get-ClusterResources.

I'm guessing this is a bug in the SCOM agent...

0
votes

Powershell Script (GPO_Discovery.ps1) called WriteErrorLine method to output the following data:

 Import-Module : The following error occurred while loading the extended type data file: 

Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveDirectory\ActiveDirectory.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".

As it can be seen, I have the same problem on trying to run :

Import-Module ActiveDirectory
Import-Module GroupPolicy

So I tried:

Import-Module -Name ActiveDirectory -OutVariable $outAD -ErrorAction SilentlyContinue
Import-Module -Name GroupPolicy -OutVariable $outGP -ErrorAction SilentlyContinue

Neither of these have helped. I am about to attempt to remove the Import CMD-Let completely and try again. I will post if that works for me.