Created
March 18, 2021 17:57
-
-
Save lukeplausin/4e473c0cd899063d092df7d7523cbad0 to your computer and use it in GitHub Desktop.
This is a powershell script which I wrote to verify that Crowdstrike is installed for deployment with Microsoft Intune (Endpoint Manager)
This file contains 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
# This is a powershell script which I wrote to verify that Crowdstrike is installed | |
# for deployment with Microsoft Intune (Endpoint Manager). | |
# You can use it for any installer which deploys a windows service, just change the $service_name | |
# variable from "csagent" to the name of the service. For example, Dropbox for Windows is "DbxSvc". | |
# Name of the service | |
$service_name = "csagent" | |
# Number of retries | |
$max_attempts = 15 | |
# The service may not be available immediately after install - retry x times | |
$agent = Get-Service -Name $service_name | |
$attempts = 0 | |
while ($agent -eq $null) { | |
$attempts = $attempts + 1 | |
if ($attempts -ge $max_attempts) { | |
Write-Error "Retry limit $max_attempts exceeded, exiting..." | |
# Install failed, exit with error code | |
exit 1 | |
} | |
Write-Host "Service $service_name not installed, retry attempt $attempts in 10 seconds..." | |
sleep 10; | |
$agent = Get-Service -Name $service_name | |
} | |
$agent | |
$agent_name = $agent.Name | |
$agent_status = $agent.Status | |
# Write to both pipe and stdout channel | |
Write-Host "$agent_name - $agent_status" | |
Write-Output "$agent_name - $agent_status" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment