Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snippets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Lindemark
snippets
Commits
865a24a8
Commit
865a24a8
authored
2 months ago
by
Andreas Lindemark
Browse files
Options
Downloads
Patches
Plain Diff
New script CheckAndStartZabbixAgent2.ps1
parent
b4aa9f24
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Windows/ZabbixAgent/CheckAndStartZabbixAgent2.ps1
+34
-0
34 additions, 0 deletions
Windows/ZabbixAgent/CheckAndStartZabbixAgent2.ps1
with
34 additions
and
0 deletions
Windows/ZabbixAgent/CheckAndStartZabbixAgent2.ps1
0 → 100644
+
34
−
0
View file @
865a24a8
# Retrieve the domain name dynamically
$domainName
=
(
Get-CimInstance
-ClassName
Win32_ComputerSystem
)
.
Domain
# Path to the custom configuration file on SYSVOL using the dynamic domain name
$customConfigPath
=
"\\
$domainName
\SYSVOL\
$domainName
\scripts\zabbix_agent2.conf"
# Path to the Zabbix Agent 2 configuration file
$agentConfigPath
=
"C:\Program Files\Zabbix Agent 2\zabbix_agent2.conf"
# Function to check if the Zabbix Agent 2 service is running
function
Check-ZabbixAgent2
{
$service
=
Get-Service
-Name
"Zabbix Agent 2"
-ErrorAction
SilentlyContinue
if
(
$service
-and
$service
.
Status
-eq
'Running'
)
{
Write-Output
"Zabbix Agent 2 is running."
return
$true
}
else
{
Write-Output
"Zabbix Agent 2 is not running."
return
$false
}
}
# Function to copy the custom configuration file and start the service
function
Start-ZabbixAgent2
{
Write-Output
"Copying custom configuration file..."
Copy-Item
-Path
$customConfigPath
-Destination
$agentConfigPath
-Force
Write-Output
"Starting Zabbix Agent 2 service..."
Start-Service
-Name
"Zabbix Agent 2"
}
# Main script logic
if
(
-not
(
Check-ZabbixAgent2
))
{
Start-ZabbixAgent2
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment