Hey all,
Brand new to the Automox Community here, really loving the software so far. However, I’m running into a weird issue. So, we’ve gotta update cURL, and I’m running into a pair of issues.
To start, within Automox, I cannot see it as a listed package. I know it’s installed, and can see it in my Tenable dashboard. This leaves the bulk actions/software patching option out.
So, in lieu of this, I’ve tried to make a worklet to meet the requirements. I’ve found some powershell online that seems to fit what I’d need it to do, but when I run it on my test machine, I get the attached logs, and the issue persists. Could anyone offer some advice?
param (
[string]$SearchBase,
[string]$updatedCurlPath = 'C:\temp\CurlUpdate\curl.exe',
[string]$sourcePath = 'c$\Windows\System32\curl.exe'
)
$computers = Get-AdComputer -filter * -SearchBase $SearchBase
# $computers = @()
# $AdGroup = Get-ADGroupMember -Identity "Group Name"
# Foreach ($one in $AdGroup) {
# $computers += Get-AdComputer -Identity $one.name
# }
$rights = 'FullControl'
$type = 'Allow'
$adminGroup = 'BUILTIN\Administrators'
$adminAccount = [System.Security.Principal.NTAccount]::new($adminGroup)
$adminFullAccessRule = [System.Security.AccessControl.FileSystemAccessRule]::new($adminGroup, $rights, $type)
$success = @()
$failed = @()
$offline = @()Foreach ($computer in $computers) {
if (Test-connection -computername $computer.DNSHostName -count 1 -quiet){
write-host "$($computer.name) is online!" -ForegroundColor Green
$hostname = $computer.DNSHostName
$curlPath = "\\$hostname\$sourcePath"
Try {
Write-Host "Checking ACL for $($computer.name)"
$originalAcl = Get-Acl -Path "$curlPath" -ErrorAction stop
$adminAcl = Get-Acl -Path "$curlPath" -ErrorAction stop
$adminAcl.SetOwner($adminAccount)
$adminAcl.AddAccessRule($adminFullAccessRule)
Invoke-Command -ComputerName $hostname -ScriptBlock {takeown /f "c:\windows\system32\curl.exe"}
(get-item $curlPath).SetAccessControl($adminAcl)
$nextstep = $true
}
Catch {
$failed += [pscustomobject]@{
name = $computer.name
message = $_
}
}
if ($nextstep){
try {
write-host "Copying $updatedCurlPath to $curlPath"
Copy-Item -Path $updatedCurlPath -Destination $curlPath -Force
(get-item $updatedCurlPath).SetAccessControl($originalAcl)
$success += $computer
}
Catch {
$failed += [pscustomobject]@{
name = $computer.name
message = $_
}
}
}
}
Else {
$offline += $computer
}
}Write-host "`nSuccessful:" -ForegroundColor Green
$success | ForEach-Object {Write-host "$($_.name)."}
write-host "`nFailed:" -ForegroundColor Yellow
$failed | ForEach-Object {Write-host "$($_.name) because: $($_.message)"}
write-host "`nOffline:" -ForegroundColor Red
$offline | ForEach-Object{Write-Host "$($_.name) is offline"}
Then Logs
Successful:
Failed:
Offline: