function get-service-account-information
{
for($c=0;$c -lt 3;$c++)
{
$d = net user $UserNames[$c] /DOMAIN
Foreach($a in $d)
{
if($a.contains("Account active") -eq $true)
{
$Active = $a.Replace("Account active","")
$Active = $Active.Trim()
if($Active.contains("Yes") -eq $true)
{
$strActive[$c] = "Yes"
}
}
else
{
$strActive[$c[ = "No"
}
if($a.contains("Account expires") -eq $true)
{
$AExpires = $a.Replace("Account expires","")
$AExpires = $AExpires.Trim()
if($AExpires.contains("Never") -eq $false)
{
$AExpires = $a.Replace("Account expires","")
$AExpires = $AExpires.Trim()
$dt = [DateTime]$AExpires
$f = $([DateTime]::Now - $dt)
[System.String]$g = $f.TotalMilliSeconds/86400000
$pos = $g.IndexOf(".")
$g = $g.Substring(0, $pos)
$strAccountExpires[$c] = $g
}
}
if($a.contains("Password expires") -eq $true)
{
$PExpires = $a.Replace("Password expires","")
$PExpires = $PExpires.Trim()
$dt = [DateTime]$PExpires
$strPasswordExpiresDate[$c] = "Password is set to expire on: " + $PExpires
$f = $($dt - [DateTime]::Now)
[System.String]$g = $f.TotalMilliSeconds/86400000
$pos = $g.IndexOf(".")
$g = $g.Substring(0, $pos)
$g = $g.Trim()
$strPasswordExpires[$c] = $g
}
if($a.contains("Password last set") -eq $true)
{
$PLastSet = $a.Replace("Password last set","")
$PLastSet = $PLastSet.Trim()
$dt = [DateTime]$PLastSet
$strPasswordLastSet[$c] = $dt
}
if($a.contains("User may change password") -eq $true)
{
$PChangeable = $a.Replace("User may change password","")
$PChangeable = $PChangeable.Trim()
if($PChangeable.contains("Yes") -eq $true)
{
$strPasswordChangeable[$c] = "true"
}
else
{
$strPasswordChangeable[$c] = "false"
}
}
}
}
}
No comments:
Post a Comment