Hello,
I’ve managed to get this script to pull the number of files in a folder to a database (influx), I can see the data in there, but the PS script doesn’t end/stop unless I manually cancel it. What do I need to add/change?
Import-Module Influx
$user = 'filecountuser1'
$file = 'C:\test\pwdsmtp.txt'
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, (Get-Content $file | ConvertTo-SecureString)
While ($true){
$Metrics = @{
FolderCount = [int](Get-ChildItem \\server1\temp\Test | Measure-Object).Count
}
Write-Influx -Measure filecount -Tags @{host="server1"} -Metrics $Metrics -Database "filecountDB" -Server http://10.10.12.65:8086 -Credential $credentials
Start-Sleep -Seconds 30
}
Thanks