Skip to content

Instantly share code, notes, and snippets.

@billkindle
Last active December 11, 2020 04:55
Show Gist options
  • Save billkindle/3970705468b38c5b2a12363dd54cbf9a to your computer and use it in GitHub Desktop.
Save billkindle/3970705468b38c5b2a12363dd54cbf9a to your computer and use it in GitHub Desktop.
function Get-NetAccountInfo {
#obtain the data and do some minor cleanup
$data = net.exe accounts
$data = $data -replace '^[T].*',''
foreach ($line in $data)
{
#split on double colon character
$line = $line -split '\:\s+'
#define properties
$properties = @{
AccountSetting = $line[0]
Value = $line[1]
}
#output object
New-Object -TypeName psobject -Property $properties
}
}
Get-NetAccountInfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment