Hi Guys,
I’m trying to convert any non-AD computer object input feed into my custom cmdlet into an Ad computer object. i.e. if you pass me an AD object (from get-adcomputer etc) along the pipeline, I just process it, however if you pass a string I will get it as a AD object, then process it.
So far I have tried this…
if ($ComputerName.GetType() -isnot [Microsoft.ActiveDirectory.Management.ADAccount])
{
$computername = Get-adcomputer $computername
}
However if I do pipe “get-adcomputer servername” to my cmdlet I get the below error
You cannot call a method on a null-valued expression.
At line:68 char:13
-
if ($ComputerName.GetType() -isnot [Microsoft.ActiveDirectory.Management ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (
, RuntimeException - FullyQualifiedErrorId : InvokeMethodOnNull
- CategoryInfo : InvalidOperation: (
Can anyone see what i’m doing wrong?