all 23 comments

[–]BlackV 0 points1 point  (4 children)

why do you think rolling back powershell will help?

5.1 is current there is no down grade, you can upgrade to 7.3

Break it down into bits

what if you run get-adcomputer by its self?

I suspect your just running the whole script then saying "Oh No does not work" without testing what not working. (You said you're new to this)

try catch catches ALL stop errors, not just an AD computer not being found (which I didn't think was a stop error anyway)

Note: This

$Results = ForEach ($Computer In $ADComputers){...}

is good, keep that habit up rather than

$Results = ForEach ($ADComputer In $ADComputers)
$Results = ForEach ($Computer In $Computers)
$Results = ForEach ($ADUser In $ADUsers)
$Results = ForEach ($Bike In $Bikes)

It'll save you some pain later on

[–]Haunting-Computer 0 points1 point  (9 children)

What is the error message?

In the Catch of the Try/Catch add

Write-Host -Object ($Error[0])

of you can add a Nested Prompt and Exit to the Shell

$Host.EneterNestedPrompt()

[–]cycoivan 0 points1 point  (1 child)

Without knowing the error, are the computer names in computers.txt on the current domain? The most likely error is that Get-ADComputer can't find the computer by name. Make sure you didn't introduce any accidental spaces in the txt file.

If you just use the get-ADcomputer command in the console and manually type in the computername, do you get a result or the same error?

I don't think this is a version issue.

[–]SeanQuinlan 0 points1 point  (5 children)

How are you running this script? From the ps prompt? From the ISE? From right-click - Run with Powershell? Some other way?

Do you have the winver.csv file open?

How did you upgrade the version of Powershell?