disturbedone
Vendor
I'd like to import a CSV with a list of parents and check their password (default is set to a generic one) to see if they've changed it and output the results to another CSV. This is to show me all users who have not changed their password from the default.
I found a script online that I've modified. It works 99% correctly.
This outputs to a CSV and only outputs those where the result is false (ie it is still the default password). But it outputs the username on one line and and the result (False) on another. It has not put a , to make it a CSV. I've also tried the Export-CSV command but it doesn't work properly.
Any ideas how I can get this to work?
I found a script online that I've modified. It works 99% correctly.
Code:
##Required for AD Support
Import-Module activedirectory
$ApplicationPath = "C:\Scripts\"
$CSVFile = $ApplicationPath + "parents.csv"
$LogFile = $ApplicationPath + "ParentPasswordsLog.txt"
$ResultsCSV = $ApplicationPath + "ParentPasswordsResults.csv"
import-csv $CSVFile | foreach {
$UserName = $_.Username
$Password = $_.Password
$Domain = $env:USERDOMAIN
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext $ct,$Domain
$pc.ValidateCredentials($UserName,$Password)
IF ($pc.ValidateCredentials($UserName,$Password) -ne "True")
{ $UserName,$pc.ValidateCredentials($UserName,$Password) | out-file $ResultsCSV }}
This outputs to a CSV and only outputs those where the result is false (ie it is still the default password). But it outputs the username on one line and and the result (False) on another. It has not put a , to make it a CSV. I've also tried the Export-CSV command but it doesn't work properly.
Any ideas how I can get this to work?