Import-LMLogicModuleFromFile
Syntax
Section titled “Syntax”FilePath
Section titled “FilePath”Import-LMLogicModuleFromFile -FilePath <String> [-Type <String>] [-Format <String>] [-FieldsToPreserve <String>] [-HandleConflict <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]Import-LMLogicModuleFromFile -File <Object> [-Type <String>] [-Format <String>] [-FieldsToPreserve <String>] [-HandleConflict <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]Description
Section titled “Description”The Import-LMLogicModuleFromFile function imports a LogicModule from a file path or file data using the new XML and JSON import endpoints. Supports various module types including datasources, configsources, eventsources, batchjobs, logsources, oids, topologysources, functions, and diagnosticsources.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”#Import a datasource module from XMLImport-LMLogicModuleFromFile -FilePath "C:\LogicModules\datasource.xml" -Type "datasources" -Format "xml"Example 2
Section titled “Example 2”#Import a logsource module from JSON with conflict handlingImport-LMLogicModuleFromFile -FilePath "C:\LogicModules\logsource.json" -Type "logsources" -Format "json" -HandleConflict "FORCE_OVERWRITE"Example 3
Section titled “Example 3”#Import an eventsource from file data (read file content first with -Raw parameter)$fileData = Get-Content -Path "C:\LogicModules\eventsource.xml" -RawImport-LMLogicModuleFromFile -File $fileData -Type "eventsources" -Format "xml"Example 4
Section titled “Example 4”#Import with fields to preserveImport-LMLogicModuleFromFile -FilePath "C:\LogicModules\datasource.json" -Type "datasources" -Format "json" -FieldsToPreserve "description,appliesTo"Parameters
Section titled “Parameters”-FilePath
Section titled “-FilePath”The path to the file containing the LogicModule to import. The function will read the file content automatically.
Type: StringParameter Sets: FilePathAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe raw file content of the LogicModule to import as a string. Use Get-Content with -Raw parameter to read file content properly (e.g., Get-Content ‘file.json’ -Raw).
Type: ObjectParameter Sets: FileAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe type of LogicModule. Valid values are “datasources”, “configsources”, “eventsources”, “batchjobs”, “logsources”, “oids”, “topologysources”, “functions”, “diagnosticsources”. Defaults to “datasources”.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: DatasourcesAccept pipeline input: FalseAccept wildcard characters: False-Format
Section titled “-Format”The format of the LogicModule file. Valid values are “xml” or “json”. Defaults to “json”.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: JsonAccept pipeline input: FalseAccept wildcard characters: False-FieldsToPreserve
Section titled “-FieldsToPreserve”Optional. Comma-separated list of fields to preserve during import. Only applies to JSON imports. Defaults to preserving none of the fields. Valid values are “NAME”, “APPLIES_TO_SCRIPT”, “COLLECTION_INTERVAL”, “ACTIVE_DISCOVERY_INTERVAL”, “ACTIVE_DISCOVERY_FILTERS”, “MODULE_GROUP”, “DISPLAY_NAME”, “USE_WILD_VALUE_AS_UUID”, “DATAPOINT_ALERT_THRESHOLDS”, “TAGS”. “NAME” will preserve the name of the LogicModule. “APPLIES_TO_SCRIPT” will preserve the appliesToScript of the LogicModule. “COLLECTION_INTERVAL” will preserve the collectionInterval of the LogicModule. “ACTIVE_DISCOVERY_INTERVAL” will preserve the activeDiscoveryInterval of the LogicModule. “ACTIVE_DISCOVERY_FILTERS” will preserve the activeDiscoveryFilters of the LogicModule. “MODULE_GROUP” will preserve the moduleGroup of the LogicModule. “DISPLAY_NAME” will preserve the displayName of the LogicModule. “USE_WILD_VALUE_AS_UUID” will preserve the useWildValueAsUuid of the LogicModule. “DATAPOINT_ALERT_THRESHOLDS” will preserve the datapointAlertThresholds of the LogicModule. “TAGS” will preserve the tags of the LogicModule.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-HandleConflict
Section titled “-HandleConflict”Optional. Specifies how to handle conflicts during import. Only applies to JSON imports. Defaults to “FORCE_OVERWRITE”. Valid values are “FORCE_OVERWRITE” or “ERROR”. “FORCE_OVERWRITE” will overwrite the existing LogicModule with the same name. “ERROR” will throw an error if a conflict is found.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: FORCE_OVERWRITEAccept pipeline input: FalseAccept wildcard characters: False-ProgressAction
Section titled “-ProgressAction”Fill ProgressAction Description
Type: ActionPreferenceParameter Sets: (All)Aliases: proga
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseCommonParameters
Section titled “CommonParameters”This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
Section titled “Inputs”None. You cannot pipe objects to this command.
Section titled “None. You cannot pipe objects to this command.”Outputs
Section titled “Outputs”Returns a success message if the import is successful.
Section titled “Returns a success message if the import is successful.”You must run Connect-LMAccount before running this command. Requires PowerShell version 6.1 or higher.
Note: Some module types only support specific formats:
- logsources, oids, functions, diagnosticsources: JSON only
- Other types: Both XML and JSON supported