I am fairly new to PowerShell scripting. I have created a very simple script that pipes a couple of commands and displays on screen with different colors for different results. I want to take the on screen data and put all of it into a txt file, which eventually I'll use for Zabbix alerts.
The script executes and creates the txt file, yet the txt file is empty. Any assistance would be great!
Code:
Get-MailboxServer | Get-mailboxDatabaseCopyStatus | ForEach {
If ($_.Status.ToString() -notmatch "Mounted" -or $_.ContentIndexState.ToString() -notmatch "Healthy")
{
Write-Host "$($_.Name) - $($_.Status) - $($_.ContentIndexState) - OK" -ForegroundColor Green
}
Else
{
Write-Host "$($_.Name) - $($_.Status) - $($_.ContentIndexState) - FAILED" -ForegroundColor Red
}
} | set-content | out-file c:\scripts\exchangedb.log
Aucun commentaire:
Enregistrer un commentaire