Deployment server can only push config to forwarders.
$errorfile = "D:\Splunk\SplunkForwarderInstall.log" # change path accordingly and update here this will be needed for any issues with installation.
Start-Transcript -Path $errorfile - NoClobber
$csvpath = "D:\Splunk\servers.csv"
$files = Import-Csv -path $csvpath |select -ExpandProperty Name
Write-host "Starting to copy SplunkForwarder installer on $file" -ForegroundColor Green
foreach($file in $files){
#defining destination and source directory
$sourcePath = "D:\Splunk<or directory path>"
$destPath = "\\$file\<directory path>"
#creating folder
New-Item -path $destPath -ItemType directory -Force
#copying
Copy-Item -Recurse -Path $sourcePath -Destination $destPath -Force
#running setup for SF
Write-Host "Copying installer on $file complete" -ForegroundColor Green
Write-Host "Starting installation on $file" -ForegroundColor Green
Invoke-Command -ComputerName $file -ScriptBlock { & cmd /c msiexec /i "<location of splunkforwadr.msi>" AGREETOLICENSE=Yes /quiet}
Write-Host "Installation complete on $file" -ForegroundColor Green
Write-Host "Validating install by checking if service is running. Please check the output <path to output directory D:\Splunk_install\.....blah blah>"
$Running = Get-Service -Name "SplunkForwarder" -ComputerName $file -ErrorAction SilentlyContinue
$name="SplunkForwarder"
if($Running.Status -eq "Running"){
Write-host "SplunkForwarder service will be stopped for $file" -ForegroundColor Green
Get-Service -Name $name -ComputerName $file|Set-Service -Status Stopped
Write-host "SplunkForwarder service has been stopped on $file" -ForegroundColor Green
Write-host "Copying deploymentclient.conf to $file" -ForegroundColor Green
$Dest = "\\$file\c$\Program Files\SplunkUniversalForwarder\etc\system\local"
$Source = "D:\Splunk\deployemntclient.conf" # Source directory can be any directory update the path here accordingly
Copy-Item -Recurse -Path $Source -Destination $Dest -Force
Write-Host "Starting SplunkForwarder service on $file" -ForegroundColor Green
Get-Service -Name $name -ComputerName $file |Set-Service -Status Running
Write-Host "SplunkForwarder service has been started on $file" -ForegroundColor Green
}
}
Stop-transcript
try and make changes where needed. like paths etc.
what this basically does is installs forwarders and copies deploymentclient config and restarts splunkforwarder service and it captures logs as well so you can see errors.