Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment