Net Accounts

This topic contains 2 replies, has 2 voices, and was last updated by  Bill Kindle 2 weeks, 2 days ago.

  • Author
    Posts
  • #80969

    Bill Kindle
    Participant

    I'm trying to figure out the best way to be able to extract info from 'net accounts' so that I can parse the info contained in order to validate the values for a remediation task in SCCM. This is what I have so far:

    It's ugly but I think it turns the output into objects that I should be able to work with. I would prefer to turn this output into 8 individual scripts to better control the SCCM remediation tasks.

    Am I reinventing the wheel here? Is there a better way to go about extracting this info?

  • #81050

    Curtis Smith
    Participant

    Hey Bill,
    You could use ConvertFrom-String

    $accountSettings = net.exe accounts | ForEach-Object {ConvertFrom-String -InputObject $_ -Delimiter ": +" -PropertyNames Setting, Value}
    
    Write-host '$accountSettings | Out-Host' -ForegroundColor Cyan
    $accountSettings | Out-Host
    
    Write-host '$accountSettings | Where-Object {$_.Setting -eq "Maximum password age (days)"} | Out-Host' -ForegroundColor Cyan
    $accountSettings | Where-Object {$_.Setting -eq "Maximum password age (days)"} | Out-Host
    
    Write-host '$accountSettings | Where-Object {$_.Setting -eq "Lockout threshold"} | Out-Host' -ForegroundColor Cyan
    $accountSettings | Where-Object {$_.Setting -eq "Lockout threshold"} | Out-Host
    • #81061

      Bill Kindle
      Participant

      Thanks for the reply Curtis! Actually I had just discovered ConvertFrom-String over the weekend and was working with saving the info as an array but I went a completely different route, using secedit to extract some of this info too. I was then using compare to get a diff of two sets of policies and trying to get some output from that. Starting to think I'm just doing it the hard way 🙂

You must be logged in to reply to this topic.