Last active
October 20, 2023 18:43
-
-
Save fortran01/e22b155a662de119de80b21ce783b4e0 to your computer and use it in GitHub Desktop.
automate_machinestats_nondomain.ps1
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
# cd to C:\machine_stats\windows | |
Set-Location C:\machine_stats\windows | |
# Prompt for the username of the service account to use to connect to the target hosts | |
$Username = Read-Host "Enter the username of the service account to use to connect to the target hosts" | |
# Create the machine-stats wrapper script C:\machine_stats\windows\run_default.ps1 to run runner.ps1 | |
$Content = "C:\machine_stats\windows\runner.ps1 ``` | |
-UserName $Username ``` | |
-ServersPath `"C:\machine_stats\windows\servers.txt`" ``` | |
-ServerStatsPath `"C:\machine_stats\windows\server_stats.ps1`" ``` | |
-SecurePwdFilePath `"C:\machine_stats\windows\SecuredText.txt`" ``` | |
-CpuUtilizationTimeout 1 ``` | |
-CpuUtilizationOnlyValue ``` | |
-Measurements ``` | |
| tidal request -X POST /api/v1/measurements/import" | |
Set-Content -Path "C:\machine_stats\windows\run_default_nondomain.ps1" -Value $Content | |
# Prompt for the username to use to run the scheduled task (defaults to tidal) | |
$Username = Read-Host "Enter the username to use to run the scheduled task (defaults to tidal)" | |
if ($Username -eq "") { | |
$Username = "tidal" | |
} | |
# Schedule run_default.ps1 to run every 5 minutes with HighestAvailable run level | |
schtasks /create /tn "machine-stats" /tr "powershell.exe -ExecutionPolicy Bypass -File C:\machine_stats\windows\run_default_nondomain.ps1" /sc minute /mo 5 /ru $Username /rl highest /rp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment