Net Accounts

Welcome Forums General PowerShell Q&A Net Accounts

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 5 months ago.

  • Author
  • #80969

    Points: 67
    Rank: Member

    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

    Points: 1
    Rank: Member

    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

      Points: 67
      Rank: Member

      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 🙂

The topic ‘Net Accounts’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort