Hi,
I'm trying to write a script that will write an event to the application log when a script is run that finds an account for which delegation has been configured. The code I've been trying to get working is this:
$result=Get-ADGroupMember -Identity "Domain Admins" | ForEach-Object {Get-ADUser -Identity $_ -Properties AccountNotDelegated | Where-Object {$_.AccountNotDelegated -eq $false} | Format-Table DistinguishedName,AccountNotDelegated -AutoSize}
If ($result -ne $null) {
Write-EventLog -Logname Application -Source "My Test" -EntryType Warning -EventID 1 -Message $result}
When I run this, I get the error:
"Write-EventLog : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Message'.
Specified method is not supported."
Does anyone know how I might change this so I can get the output I'm after, without having to first write the data to a text file on the file system?