Hi Guys,
I've cobbled together a workflow using Powershell that looks at membership of the local Administrators group and that output is emailed to me. That's gone without issue but I want to refine it and that's where I'm struggling.
So I know that in our case, every machine's local admin group has some membership, i.e. the local admin account and our domain admins group. I want to filter these machines out and have email results for only those where there's anything more than those "defaults".
Get-LocalGroupMember -Group 'Administrators' | Where-Object {$_.PrincipalSource -ne 'Local' -and $_.Name -ne 'MyDomain\Administrator' -and $_.Name -ne 'MyDomain\Domain Admins'} | Select-Object -Property 'Name','PrincipalSource'
This code works locally and using Pulseway's remote Powershell function. What I was hoping to do was to basically skip a system if the output of the code was blank or null. For systems where I haven't received any output back when using Pulseway's Powershell, I guess I don't know if the output is actually completely empty or not. I also don't know if using Pulseway's variable function is considered separately to the Powershell environment the code gets run in, if that makes sense? When I try to run the workflow on a single machine I always get emailed the results, even when the return from the Powershell is blank.
I'm not brilliant with Powershell so have been searching around for alternatives. I was wondering about return codes perhaps but could I also put these into a Pulseway workflow?