< Back

Export-ZabbixConfiguration

Sun Jan 19, 2020 6:10 pm

NAME Export-ZabbixConfiguration



SYNOPSIS

Export configuration





SYNTAX

Export-ZabbixConfiguration [[-HostID] <Array>] [[-GroupID] <Array>] [[-TemplateID] <Array>] [[-ScreenID] <Array>]

[[-MapID] <Array>] [[-Format] <String>] [[-jsonrpc] <String>] [[-session] <String>] [[-id] <String>] [[-URL]

<String>] [<CommonParameters>]





DESCRIPTION

Export configuration





PARAMETERS

-HostID <Array>

HostID - (array) IDs of hosts to export



Required? false

Position? 1

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-GroupID <Array>

GroupID: groups - (array) IDs of host groups to export.



Required? false

Position? 2

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-TemplateID <Array>

TemplateID - (array) IDs of templates to export.



Required? false

Position? 3

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-ScreenID <Array>



Required? false

Position? 4

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-MapID <Array>



Required? false

Position? 5

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-Format <String>

Format: XML (default) or JSON.



Required? false

Position? 6

Default value xml

Accept pipeline input? false

Accept wildcard characters? false



-jsonrpc <String>



Required? false

Position? 7

Default value ($global:zabSessionParams.jsonrpc)

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-session <String>



Required? false

Position? 8

Default value ($global:zabSessionParams.session)

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-id <String>



Required? false

Position? 9

Default value ($global:zabSessionParams.id)

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-URL <String>



Required? false

Position? 10

Default value ($global:zabSessionParams.url)

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Export-ZabbixConfig -HostID (Get-ZabbixHost | ? name -match host).hostid



Export hosts configuration









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Export-ZabbixConfig -HostID (Get-ZabbixHost | ? name -match host).hostid | clip



Capture to clipboard exported hosts configuration









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Export-ZabbixConfig -HostID (Get-ZabbixHost | ? name -match host).hostid | Set-Content

c:\\zabbix-hosts-export.xml -Encoding UTF8 -nonewline



Export hosts configuration to xml file









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Export-ZabbixConfig -TemplateID (Get-ZabbixTemplate | ? name -match TemplateName).templateid | Set-Content

c:\\zabbix-templates-export.xml -Encoding UTF8



Export template to xml file









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Export-ZabbixConfig -TemplateID (Get-ZabbixHost | ? name -match windows).templateid | Set-Content

c:\\zabbix-templates-export.xml -Encoding UTF8 -nonewline



Export template configuration linked to certain hosts to xml file, -nonewline saves file in Unix format (no CR)









-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Export-ZabbixConfig -HostID (Get-ZabbixHost | ? name -eq host).hostid | format-xml | Set-Content

C:\\zabbix-host-export-formatted-pretty.xml -Encoding UTF8



Export host template to xml, beautify with Format-Xml (module pscx) and save to xml file









-------------------------- EXAMPLE 7 --------------------------



PS C:\\>Get-ZabbixHost | ? name -match host -pv hst | %{Export-ZabbixConfig -HostID $_.hostid | sc

c:\\ZabbixExport\\export-zabbix-host-$($hst.name).xml -Encoding UTF8}



Export host configuration









-------------------------- EXAMPLE 8 --------------------------



PS C:\\>Get-ZabbixHost | ? name -eq Host | Export-ZabbixConfig | Format-Xml | Set-Content

C:\\zabbix-host-export-formatted-pretty.xml -Encoding UTF8



Export host template to xml, beautify with Format-Xml (module pscx) and save to xml file









-------------------------- EXAMPLE 9 --------------------------



PS C:\\>diff (Get-Content c:\\FirstHost.xml) (Get-content c:\\SecondHost.xml)



Compare hosts by comparing their configuration files









-------------------------- EXAMPLE 10 --------------------------



PS C:\\>Get-ZabbixTemplate | ? name -match templateNames | Export-ZabbixConfig -Format json | sc

C:\\zabbix-templates-export.json



Export templates in JSON format









-------------------------- EXAMPLE 11 --------------------------



PS C:\\>$expHosts=Get-ZabbixHost | ? name -match hosts | Export-ZabbixConfig -Format JSON | ConvertFrom-Json



$expHosts.zabbix_export.hosts

Explore configuration as powershell objects, without retrieving information from the server











RELATED LINKS