У нас роль CMDB в организации выполняет GLPI, и для облегчения инвентаризации необходимо распространить агента на все компьютеры сети.
1) Закидываем установочные файлы(с маской имени fusioninventory-agent_windows-%ARCH%_2.6mod.exe) в общую шару:
2) Создаем Файл со своими настройками сервера GLPI – FusionInventory.cmd(с содержимым как в примере ниже) и закидываем на какую нибудь шару
SET INSTALLSERVER=\\ADDRESS-SHARE\FusionInventory\Install
SET LOGSERVER=\\ADDRESS-SHARE\FusionInventory\log
IF %PROCESSOR_ARCHITECTURE%==x86 SET ARCH=x86
IF %PROCESSOR_ARCHITECTURE%==AMD64 SET ARCH=x64
%INSTALLSERVER%\fusioninventory-agent_windows-%ARCH%_2.6mod.exe /S /server='http://AddressGLPI/collect.php' /acceptlicense /execmode=service /no-start-menu /installtasks=Collect,Deploy,Inventory /no-p2p /no-httpd /no-ssl-check /runnow /verysilent
:END
:: завершение cmd-файла
3) Создаем политику автозагрузки созданного CMD-файла, выбираем в фильтрах безопасности нужные компы и ждем
This script install FusionInventory Agent by GPO if there is not installed or if the executable is in a newer version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::.SYNOPSIS: | |
:: Deploy FusionInventory Agent by GPO. | |
:: | |
::.DESCRIPTION: | |
:: This script install FusionInventory Agent by GPO if there is not installed or if the executable is in a newer version. | |
:: He also detect if it’s a x86 or x64 computer to install the good executable. | |
:: First, you have to download the latest executables of FusionInventory Agent (x86 and x64) and link them to this script. | |
:: Don’t forget to set your LimitDate, change your GLPI server adresse and change TAG. | |
:: LimitDate is the date that the script stop running. | |
:: You can create multiple GPOs with multiple scripts and differents TAG to organize them on FusionInventory. | |
:: | |
::.EXEMPLE: | |
:: .\Deploy_FusionInventoryAgent.bat | |
if exist %ProgramFiles%\FusionInventory-Agent\Uninstall.exe ( | |
FOR %%? IN («%ProgramFiles%\FusionInventory-Agent\Uninstall.exe«) DO (set installdate=%%~t?) | |
set /a InstallationDate=%installdate:~6,4%%installdate:~3,2%%installdate:~0,2% | |
:: Here you can set the limit date at format YYYYMMDD | |
set /a LimitDate=YYYYMMDD | |
if %LimitDate% GEQ %InstallationDate% ( | |
Taskkill /IM perl.exe /F | |
Taskkill /IM fusioninventory-agent.exe /F | |
«%ProgramFiles%\FusionInventory-Agent\Uninstall.exe« /S | |
rmdir «%ProgramFiles%\FusionInventory-Agent« /S /Q | |
) | |
) | |
cd «%ProgramFiles%« | |
for /f «tokens=*« %%a in (‘powershell «(gi \\Path\fusioninventory-agent-windows-x64.exe).versioninfo.Fileversion«‘) DO SET NEWVERSION=%%a | |
for /f «tokens=*« %%a in (‘powershell «(gi .\FusionInventory-Agent\Uninstall.exe).versioninfo.Fileversion«‘) DO SET VERSION=%%a | |
IF %PROCESSOR_ARCHITECTURE%==x86 (goto x86) | |
IF %PROCESSOR_ARCHITECTURE%==AMD64 (goto x64) | |
:x64 | |
IF NOT EXIST «%ProgramFiles%\FusionInventory-Agent\var« ( | |
:: Path to x64 executable and don’t forget to set server and tag parameters | |
\\Path\fusioninventory-agent-windows-x64.exe /S /acceptlicense /installtasks=full /add-firewall-exception /execmode=Service /server=«http://server/glpi/plugins/fusioninventory/« /runnow /tag=«YourTag« | |
goto end | |
) | |
IF EXIST «%ProgramFiles%\FusionInventory-Agent\var« ( | |
IF %NEWVERSION% gtr %VERSION% ( | |
:: Path to x64 executable and don’t forget to set server and tag parameters | |
\\Path\fusioninventory-agent-windows-x64.exe /S /acceptlicense /installtasks=full /add-firewall-exception /execmode=Service /server=«http://server/glpi/plugins/fusioninventory/« /runnow /tag=«YourTag« | |
) | |
goto end | |
) | |
:x86 | |
IF NOT EXIST «%ProgramFiles%\FusionInventory-Agent\var« ( | |
:: Path to x86 executable and don’t forget to set server and tag parameters | |
\\Path\fusioninventory-agent-windows-x86.exe /S /acceptlicense /installtasks=full /add-firewall-exception /execmode=Service /server=«http://server/glpi/plugins/fusioninventory/« /runnow /tag=«YourTag« | |
goto end | |
) | |
IF EXIST «%ProgramFiles%\FusionInventory-Agent\var« ( | |
IF %NEWVERSION% gtr %VERSION% ( | |
:: Path to x86 executable and don’t forget to set server and tag parameters | |
\\Path\fusioninventory-agent-windows-x86.exe /S /acceptlicense /installtasks=full /add-firewall-exception /execmode=Service /server=«http://server/glpi/plugins/fusioninventory/« /runnow /tag=«YourTag« | |
) | |
goto end | |
) | |
:end | |
end |
Как использовать OAuth2 со Spring Security в Java
Javaican 14.05.2025
Протокол OAuth2 часто путают с механизмами аутентификации, хотя по сути это протокол авторизации. Представьте, что вместо передачи ключей от всего дома вашему другу, который пришёл полить цветы, вы. . .
Анализ текста на Python с NLTK и Spacy
AI_Generated 14.05.2025
NLTK, старожил в мире обработки естественного языка на Python, содержит богатейшую коллекцию алгоритмов и готовых моделей. Эта библиотека отлично подходит для образовательных целей и. . .
Реализация DI в PHP
Jason-Webb 13.05.2025
Когда я начинал писать свой первый крупный PHP-проект, моя архитектура напоминала запутаный клубок спагетти. Классы создавали другие классы внутри себя, зависимости жостко прописывались в коде, а о. . .
Обработка изображений в реальном времени на C# с OpenCV
stackOverflow 13.05.2025
Объединение библиотеки компьютерного зрения OpenCV с современным языком программирования C# создаёт симбиоз, который открывает доступ к впечатляющему набору возможностей. Ключевое преимущество этого. . .
POCO, ACE, Loki и другие продвинутые C++ библиотеки
NullReferenced 13.05.2025
В C++ разработки существует такое обилие библиотек, что порой кажется, будто ты заблудился в дремучем лесу. И среди этого многообразия POCO (Portable Components) – как маяк для тех, кто ищет. . .
Паттерны проектирования GoF на C#
UnmanagedCoder 13.05.2025
Вы наверняка сталкивались с ситуациями, когда код разрастается до неприличных размеров, а его поддержка становится настоящим испытанием. Именно в такие моменты на помощь приходят паттерны Gang of. . .
Создаем CLI приложение на Python с Prompt Toolkit
py-thonny 13.05.2025
Современные командные интерфейсы давно перестали быть черно-белыми текстовыми программами, которые многие помнят по старым операционным системам. CLI сегодня – это мощные, интуитивные и даже. . .
Конвейеры ETL с Apache Airflow и Python
AI_Generated 13.05.2025
ETL-конвейеры – это набор процессов, отвечающих за извлечение данных из различных источников (Extract), их преобразование в нужный формат (Transform) и загрузку в целевое хранилище (Load). . . .
Выполнение асинхронных задач в Python с asyncio
py-thonny 12.05.2025
Современный мир программирования похож на оживлённый мегаполис – тысячи процессов одновременно требуют внимания, ресурсов и времени. В этих джунглях операций возникают ситуации, когда программа. . .
Работа с gRPC сервисами на C#
UnmanagedCoder 12.05.2025
gRPC (Google Remote Procedure Call) — открытый высокопроизводительный RPC-фреймворк, изначально разработанный компанией Google. Он отличается от традиционых REST-сервисов как минимум тем, что. . .
Прочитано: 7 908
В рамках данной заметки, я покажу и предоставлю небольшой скрипт для ручной установки агента fusioninvetory на Windows системы используемые у меня на рабочем месте. Заметка опирается на ту где я рассмотрел в виде пошаговой заметки как развернуть сервис GLPI.
Скрипт представляет из себя обычный bat-файл и ресурс в сети на котором расшарен специализированный каталог (Может быть развернут как на Windows системах так и с использованием сервиса SAMBA на Ubuntu системах, как сделано у меня) с исполняемыми файлами агента (где взять файлы агента смотрите основную заметку на которую опирается эта, там приводятся ссылки, здесь у меня исполняемые файлы уже переименованы для моего удобства) и подготовленным под мой сервер glpi файлом реестра для импортирования настроек в систему.
На заметку: скрипт нужно запускать с правами локального Администратора или Администратора Домена на рабочих станциях где нужно установить агент.
И так содержимое reg файла:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent]
"backend-collect-timeout"="180"
"ca-cert-dir"=""
"ca-cert-file"=""
"debug"="2"
"delaytime"="300"
"html"="0"
"httpd-ip"=""
"httpd-port"="62354"
"httpd-trust"=""
"local"=""
"logfile"="C:\\Program Files\\FusionInventory-Agent\\fusioninventory-agent.log"
"logfile-maxsize"="16"
"logger"="File"
"no-category"=""
"no-httpd"="1"
"no-p2p"="0"
"no-ssl-check"="0"
"no-task"=""
"password"="glpi"
"proxy"=""
"server"="http://10.7.8.154/glpi/plugins/fusioninventory/"
"scan-homedirs"="0"
"scan-profiles"="0"
"tag"=""
"timeout"="180"
"user"="glpi"
и собственно содержимое скрипта:
@echo off
ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto W7
ver | find "5.1" > nul
if %ERRORLEVEL% == 0 goto XP
:XP
rem help po install C:\666>agentx86.exe ?
rem uninstall "C:\Program Files\FusionInventory-Agent\Uninstall.exe" /S
sc query | findstr /i "FusionInventory-Agent"
rem если вывод не равен 0 тогда устанавливаем агент
if %ERRORLEVEL% == 0 goto (wxp) else (goto END)
:wxp
mkdir c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\agentx86.exe c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\winxpagent.reg c:\666
c:\666\agentx86.exe /acceptlicense /add-firewall-exception /execmode=Service /installtasks=Full /runnow /no-start-menu /S
regedit /S c:\666\winxpagent.reg
net stop FusionInventory-Agent
net start FusionInventory-Agent
rmdir /S /Q c:\666
:END
rmdir /S /Q c:\666
exit
:W7
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
:64BIT
rem help po install C:\666>agentx86.exe ?
rem uninstall "C:\Program Files\FusionInventory-Agent\Uninstall.exe" /S
sc query | findstr /i "FusionInventory-Agent"
rem если вывод не равен 0 тогда устанавливаем агент
if %ERRORLEVEL% == 0 goto (W7X64) else (goto END)
:W7X64
mkdir c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\agentx64.exe c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\winxpagent.reg c:\666
c:\666\agentx64.exe /acceptlicense /add-firewall-exception /execmode=Service /installtasks=Full /runnow /no-start-menu /S
regedit /S c:\666\winxpagent.reg
net stop FusionInventory-Agent
net start FusionInventory-Agent
rmdir /S /Q c:\666
:END
rmdir /S /Q c:\666
exit
:32BIT
rem help po install C:\666>agentx86.exe ?
rem uninstall "C:\Program Files\FusionInventory-Agent\Uninstall.exe" /S
sc query | findstr /i "FusionInventory-Agent"
rem если вывод не равен 0 тогда устанавливаем агент
if %ERRORLEVEL% == 0 goto (w7x86) else (goto END)
:w7x86
mkdir c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\agentx86.exe c:\666
xcopy /Y /Z /R \\10.9.9.1\file\glpi\winxpagent.reg c:\666
c:\666\agentx86.exe /acceptlicense /add-firewall-exception /execmode=Service /installtasks=Full /runnow /no-start-menu /S
regedit /S c:\666\winxpagent.reg
net stop FusionInventory-Agent
net start FusionInventory-Agent
rmdir /S /Q c:\666
:END
rmdir /S /Q c:\666
exit
Я специально не выкладываю скрипт как уже подготовленный в режиме просто взял и скачал, это уже на ваше усмотрение Вы сами под себя сделаете и конечно же дополните.
Вот собственно и все, чем я хотел поделиться с читателями моего блога. До встречи, с уважением автор блога – ekzorchik. Автоматизация установки агента fusioninventory на Windows системы
Всем доброго времени суток и с пятницей!
Есть у меня на файл шаре (доступ к папке есть у всех) fusion inventory agent, там же положил VBS скрипт для его установки. Вот сам скрипт
Option Explicit
Dim versionverification, fusionarguments, uninstallocsagent, fusionsetupURL
''''' USER SETTINGS '''''
versionverification = "2.6"
fusionarguments = "/S /server=http://glpi.local/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
' Depending on your needs, you can use either HTTP or Windows share
fusionsetupURL = "\\server\AD Share\PROGRAM\FIAgent\fusioninventory-agent_windows-x64_" & versionverification & ".exe"
uninstallocsagent = "yes"
''''' DO NOT EDIT BELOW '''''
Function baseName (strng)
Dim regEx, ret
Set regEx = New RegExp
regEx.Global = true
regEx.IgnoreCase = True
regEx.Pattern = ".*[/\\]([^/\\]+)$"
baseName = regEx.Replace(strng,"$1")
End Function
Function isHttp (strng)
Dim regEx, matches
Set regEx = New RegExp
regEx.Global = true
regEx.IgnoreCase = True
regEx.Pattern = "^(http(s?)).*"
If regEx.Execute(strng).count > 0 Then
isHttp = True
Else
isHttp = False
End If
Exit Function
End Function
' http://www.ericphelps.com/scripting/samples/wget/index.html
Function SaveWebBinary(strUrl) 'As Boolean
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const ForWriting = 2
Dim web, varByteArray, strData, strBuffer, lngCounter, ado
' On Error Resume Next
'Download the file with any available object
Err.Clear
Set web = Nothing
Set web = CreateObject("WinHttp.WinHttpRequest.5.1")
If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "GET", strURL, False
web.Send
If Err.Number <> 0 Then
SaveWebBinary = False
Set web = Nothing
Exit Function
End If
If web.Status <> "200" Then
SaveWebBinary = False
Set web = Nothing
Exit Function
End If
varByteArray = web.ResponseBody
Set web = Nothing
'Now save the file with any available method
On Error Resume Next
Set ado = Nothing
Set ado = CreateObject("ADODB.Stream")
If ado Is Nothing Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(baseName(strUrl), ForWriting, True)
strData = ""
strBuffer = ""
For lngCounter = 0 to UBound(varByteArray)
ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
Next
ts.Close
Else
ado.Type = adTypeBinary
ado.Open
ado.Write varByteArray
ado.SaveToFile CreateObject("WScript.Shell").ExpandEnvironmentStrings("%Temp%") & "\fusioninventory.exe", adSaveCreateOverWrite
ado.Close
End If
SaveWebBinary = True
End Function
Function removeOCS()
On error resume next
Dim OCS
' Uninstall agent ocs if is installed
' Verification on OS 32 Bits
On error resume next
OCS = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
End If
' Verification on OS 64 Bits
On error resume next
OCS = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\OCS Inventory Agent\UninstallString")
If err.number = 0 then
WshShell.Run "CMD.EXE /C net stop ""OCS INVENTORY SERVICE""",0,True
WshShell.Run "CMD.EXE /C """ & OCS & """ /S /NOSPLASH",0,True
WshShell.Run "CMD.EXE /C rmdir ""%ProgramFiles(x86)%\OCS Inventory Agent"" /S /Q",0,True
WshShell.Run "CMD.EXE /C rmdir ""%SystemDrive%\ocs-ng"" /S /Q",0,True
End If
End Function
Function needFusionInstall ()
Dim Fusion
' install fusion if version is different or if not installed
needFusionInstall = False
On error resume next
Fusion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion")
If err.number = 0 Then
' Verification on OS 32 Bits
If Fusion <> versionverification Then
needFusionInstall = True
Else
needFusionInstall = False
Return
End If
Else
' Verification on OS 64 Bits
On error resume next
Fusion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion")
If err.number = 0 Then
If Fusion <> versionverification Then
needFusionInstall = True
End if
Else
needFusionInstall = True
End If
End If
End Function
''' MAIN
Dim WshShell
Set WshShell = Wscript.CreateObject("Wscript.shell")
If uninstallocsagent = "yes" Then
removeOCS()
End If
If needFusionInstall() Then
If (isHttp(fusionsetupURL)) Then
SaveWebBinary(fusionsetupURL)
WshShell.Run "CMD.EXE /C %TEMP%\fusioninventory.exe " & fusionarguments,0,True
Else
WshShell.Run "CMD.EXE /C """ & fusionsetupURL & """ " & fusionarguments,0,True
End If
End If
Скрипт выдаёт сообщение: Command line error: The value ‘http:’ is not allowed for /server= option
Может кто подскажет где ошибка!