MilesLogan
asked on
Powershell - Local accounts information .
Subsun helped me out on the script below and I was wondering if anyone can help or if possible for the script to show if the account is Enabled/Disabled and the Full Name and Description on the local account .
function get-localusers {
param(
[Parameter(Mandatory=$true ,valuefrom pipeline=$ true)]
[string]$strComputer)
begin {}
Process {
$Select = "Name","Class" | %{
Invoke-Expression "@{n='$_';e={ `$_.GetType().InvokeMember ('$_', 'GetProperty', `$Null, `$_, `$Null) }}"
}
If (Test-Connection $strComputer -Count 2 -Quiet){
$computer = [ADSI]("WinNT://" + $strComputer + ",computer")
$Users = $computer.psbase.children | ? {$_.psbase.SchemaClassName -eq "User"}
foreach ($User in $Users) {
$User | Select @{N="ComputerName";E={$str Computer}} ,@{N="User ";E={$_.Na me}},Class
}
}
Else {
"" | Select @{N="ComputerName";E={$str Computer}} ,@{N="User ";E={"Not able to Ping"}},Class
}
}
end {}
}
Get-Content "e:\Projects\servers\Serve rs.txt" | get-localusers | Select ComputerName,User | Export-Csv "e:\Projects\Servers\Local Test_$((ge t-date).to String('MM -dd-yyyy') ).csv" -NTI
function get-localusers {
param(
[Parameter(Mandatory=$true
[string]$strComputer)
begin {}
Process {
$Select = "Name","Class" | %{
Invoke-Expression "@{n='$_';e={ `$_.GetType().InvokeMember
}
If (Test-Connection $strComputer -Count 2 -Quiet){
$computer = [ADSI]("WinNT://" + $strComputer + ",computer")
$Users = $computer.psbase.children | ? {$_.psbase.SchemaClassName
foreach ($User in $Users) {
$User | Select @{N="ComputerName";E={$str
}
}
Else {
"" | Select @{N="ComputerName";E={$str
}
}
end {}
}
Get-Content "e:\Projects\servers\Serve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome!.. :-)
ASKER