PowerShell / Community-Blog

Submissions for posts to the PowerShell Community Blog -https://devblogs.microsoft.com/powershell-community
MIT License
108 stars 47 forks source link

Get Services that are Running as a User or Service Account #142

Closed David-Knapp closed 10 months ago

David-Knapp commented 10 months ago

PR Summary

One get-service.md file.

PR Checklist

David-Knapp commented 10 months ago

@microsoft-github-policy-service agree

sdwheeler commented 10 months ago

Hi @David-Knapp, thanks for the submission. This script can be simplified to two lines:

$accounts = 'localsystem', 'NT AUTHORITY\LocalService', 'NT AUTHORITY\NetworkService', ''
Get-Service | Where-Object UserName -NotIn $accounts | Select-Object UserName, Name, DisplayName

However, I don't think there is enough here for a blog post. Is this a script that you have used to solve a problem? If you could add more context, it might be a more useful post.

David-Knapp commented 10 months ago

Hi Sean,

Thank you for the email. How are you? Happy new year.

That particular snippet is from a larger overall Pester describe block that is used to validate desired state after updating or performing maintenance on a stack.

I thought providing the Pester code might be too much, so I chopped it down and modified it to see how the pr went.

David


From: Sean Wheeler @.> Sent: Tuesday, January 9, 2024 7:29 AM To: PowerShell/Community-Blog @.> Cc: David-Knapp @.>; Mention @.> Subject: Re: [PowerShell/Community-Blog] Get Services that are Running as a User or Service Account (PR #142)

Hi @David-Knapphttps://github.com/David-Knapp, thanks for the submission. This script can be simplified to two lines:

$accounts = 'localsystem', 'NT AUTHORITY\LocalService', 'NT AUTHORITY\NetworkService', '' Get-Service | Where-Object UserName -NotIn $accounts | Select-Object UserName, Name, DisplayName

However, I don't think there is enough here for a blog post. Is this a script that you have used to solve a problem? If you could add more context, it might be a more useful post.

— Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/Community-Blog/pull/142#issuecomment-1883266843, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFEQITNJUS42RZPC6KBT4ELYNVO55AVCNFSM6AAAAABBPLX5IGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBTGI3DMOBUGM. You are receiving this because you were mentioned.Message ID: @.***>

sdwheeler commented 10 months ago

@David-Knapp We could use some Pester content. Especially if you explain the context of why and how to use it.

Think about how you would teach someone to create their first Pester test. I would welcome a post like that.

David-Knapp commented 9 months ago

Ok.

Cool.

Let me see what I can do. Feel free to kick it back with any changes, etc …. I would love to contribute to the code base and am just feeling out how to do it best.

I agree. The more folks that use Pester, the more folks whose jobs became that much easier … and systems are more reliable too of course.

David

On Jan 11, 2024, at 10:16 AM, Sean Wheeler @.***> wrote:



@David-Knapphttps://github.com/David-Knapp We could use some Pester content. Especially if you explain the context of why and how to use it.

Think about how you would teach someone to create their first Pester test. I would welcome a post like that.

— Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/Community-Blog/pull/142#issuecomment-1887711441, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFEQITP6QR5NELBITNBGHL3YOAUAFAVCNFSM6AAAAABBPLX5IGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBXG4YTCNBUGE. You are receiving this because you were mentioned.Message ID: @.***>