|
14 | 14 | # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
15 | 15 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
16 | 16 | # |
17 | | -# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Cameron Granger |
| 17 | +# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Evan Shewchuk |
18 | 18 |
|
19 | 19 |
|
20 | 20 | # The Huntress installer needs an Account Key and an Organization Key (a user specified name or description) which is used to affiliate an Agent with a |
@@ -104,7 +104,7 @@ $estimatedSpaceNeeded = 200111222 |
104 | 104 | ############################################################################## |
105 | 105 |
|
106 | 106 | # These are used by the Huntress support team when troubleshooting. |
107 | | -$ScriptVersion = "Version 2, major revision 8, 2025 Nov 19" |
| 107 | +$ScriptVersion = "Version 2, major revision 8, 2025 Nov 20" |
108 | 108 | $ScriptType = "PowerShell (Datto)" |
109 | 109 |
|
110 | 110 | # variables used throughout this script |
@@ -726,7 +726,7 @@ function uninstallHuntress { |
726 | 726 | # if Huntress services still exist, then delete |
727 | 727 | $services = @("HuntressRio", "HuntressAgent", "HuntressUpdater", "Huntmon") |
728 | 728 | foreach ($service in $services) { |
729 | | - if ( $service ) { |
| 729 | + if ( Get-Service -name $service -erroraction SilentlyContinue ) { |
730 | 730 | LogMessage "Service $($service) detected post uninstall, attempting to remove" |
731 | 731 | c:\Windows\System32\sc.exe STOP $service |
732 | 732 | c:\Windows\System32\sc.exe DELETE $service |
@@ -801,23 +801,21 @@ function testNetworkConnectivity { |
801 | 801 |
|
802 | 802 | foreach ($URL in $URLs) { |
803 | 803 | $StatusCode = 0 |
804 | | - try |
805 | | - { |
| 804 | + try { |
806 | 805 | $Response = Invoke-WebRequest -Uri $URL -TimeoutSec 5 -ErrorAction Stop -ContentType "text/plain" -UseBasicParsing |
807 | 806 | # This will only execute if the Invoke-WebRequest is successful. |
808 | 807 | $StatusCode = $Response.StatusCode |
809 | 808 |
|
810 | 809 | # Convert from bytes, if necessary |
811 | 810 | if ($Response.Content.GetType() -eq [System.Byte[]]) { |
812 | 811 | $StrContent = [System.Text.Encoding]::UTF8.GetString($Response.Content) |
813 | | - }else { |
| 812 | + } else { |
814 | 813 | $StrContent = $Response.Content.ToString().Trim() |
815 | 814 | } |
816 | 815 |
|
817 | 816 | # Remove all newlines from the content |
818 | 817 | $StrContent = [string]::join("",($StrContent.Split("`n"))) |
819 | 818 |
|
820 | | - |
821 | 819 | $ContentMatch = $StrContent -eq "96bca0cef10f45a8f7cf68c4485f23a4" |
822 | 820 | } catch { |
823 | 821 | LogMessage "Error: $($_.Exception.Message)" |
@@ -870,7 +868,8 @@ function logInfo { |
870 | 868 | LogMessage $(systeminfo) |
871 | 869 |
|
872 | 870 | #LogMessage "Host name: '$env:computerName'" |
873 | | - try { $os = (get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption.Trim() |
| 871 | + try { |
| 872 | + $os = (Get-CimInstance -computername $env:computername -Class win32_operatingSystem).caption.Trim() |
874 | 873 | } catch { |
875 | 874 | LogMessage "WMI issues discovered (computer name query), attempting to fix the repository" |
876 | 875 | winmgmt -verifyrepository |
|
0 commit comments