This error message - File skipped because it was already present from Microsoft.PowerShell - can appear when a workflow is run that is loading the Service Manager modules that are provided out of the box. Something similar to this used to happen when loading the SMLets module in a workflow. We fixed the SMLets issue in SMLets Beta 3, but now we are getting reports that this is also happening with the Service Manager module provided out of the box. Here is an example:
The symptom of this problem is that the first time the workflow runs it will do what it is supposed to do, but subsequent runs of the PowerShell in the workflow will fail because of this error. The problem is that the workflow engine has already loaded the module into the PowerShell runspace. When the script tells it to import the module again it fails.
To resolve this issue, Manoj Parvathaneni, one of our Senior Support Escalation Engineers, provides these instructions:
1. Comment out the following lines in the file Microsoft.EnterpriseManagement.Core.Cmdlets.psd1. The file can be found on the drive where SM is installed and under the following path Program Files\Microsoft System Center 2012\Service Manager\Powershell\Microsoft.EnterpriseManagement.Core.Cmdlets
# The type files (.ps1xml) loaded by this module.
TypesToProcess = 'Microsoft.EnterpriseManagement.Core.Cmdlets.Types.ps1xml'
# The format files (.ps1xml) loaded by this module.
FormatsToProcess = 'Microsoft.EnterpriseManagement.Core.Cmdlets.Format.ps1xml'
Basically add the # character at the beginning of the two code lines above. After the change it would look like the following:
#TypesToProcess = 'Microsoft.EnterpriseManagement.Core.Cmdlets.Types.ps1xml'
#FormatsToProcess = 'Microsoft.EnterpriseManagement.Core.Cmdlets.Format.ps1xml'
2. Comment the following lines in the file Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.psd1. The file can be found on the drive where SM is installed and under the following path Program Files\Microsoft System Center 2012\Service Manager\Powershell\Microsoft.EnterpriseManagement.ServiceManager.Cmdlets
TypesToProcess = 'Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Types.ps1xml'
FormatsToProcess = 'Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Format.ps1xml'
#TypesToProcess = 'Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Types.ps1xml'
#FormatsToProcess = 'Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Format.ps1xml'
3. Add the following entries to the end of the module file System.Center.Service.Manager.psm1. The file can be found on the drive where SM is installed and under the following path Program Files\Microsoft System Center 2012\Service Manager\Powershell.
$SMDIR = (Get-ItemProperty 'hklm:/software/microsoft/System Center/2010/Service Manager/Setup').InstallDirectory
Update-TypeData $SMPowerShell\Microsoft.EnterpriseManagement.Core.Cmdlets\Microsoft.EnterpriseManagement.Core.Cmdlets.Types.ps1xml,$SMPowerShell\Microsoft.EnterpriseManagement.ServiceManager.Cmdlets\Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Types.ps1xml -ErrorAction SilentlyContinue
Update-FormatData $SMPowerShell\Microsoft.EnterpriseManagement.Core.Cmdlets\Microsoft.EnterpriseManagement.Core.Cmdlets.Format.ps1xml,$SMPowerShell\Microsoft.EnterpriseManagement.ServiceManager.Cmdlets\Microsoft.EnterpriseManagement.ServiceManager.Cmdlets.Format.ps1xml -ErrorAction SilentlyContinue
Thanks Manoj for providing this information!!
Still facing problem.
Import-Module : The following error occurred while loading the extended type da
\SMLets.Types.ps1xml : File skipped because it was already present from "Micros