So, I'm using the Get-ADComputer cmdlet to retrieve computers from a list of computer names, then attempting to use Remove-ADComputer to delete these, as they should no longer be in our AD.
When I do so, I get the error below. Anyone know why this doesn't work, as Get-ADComputer should return an ADComputer object?
Remove-ADComputer : Cannot bind parameter 'Identity'. Cannot convert value "" to type "Microsoft.ActiveDirectory.Management.ADComputer". Error: "Cannot convert the "" value of
type "Deserialized.Microsoft.ActiveDirectory.Management.ADComputer" to type "Microsoft.ActiveDirectory.Management.ADComputer"."
And then I figured it out; I had to convert the ADComputer to a string. Not sure why the documentation says it needs to be an ADComputer for Remove-ADComputer, when it's looking for the string that is the FQDN instead.
I pulled the names from a csv file that contains several pieces of information I needed for different parts of the script. To get the name, I just used a ForEach, and grabbed the name from the data ($Comps.ComputerName).