This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Get-QADComputer_Array error

Hi Team,

I am new to the quest powershell and I am using Quest One ActiveRoles Management Shell for Active Directory for querying the active directory.  When i try to query whether a server is present in AD or not it throws an error message: Get-QADComputer : Index was outside the bounds of the array.

Here is my code. please help me in finding out where i am going wrong.

param(
[Parameter(Mandatory=$true)]
[string]$hostnames,
[Parameter(Mandatory=$true)]
[string]$AD_SA_id,
[Parameter(Mandatory=$true)]
$ADpswd
)

$Password = ConvertTo-SecureString -String $ADpswd -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PsCredential("$AD_SA_id",$password)
 
$test = Get-QADComputer -Identity $hostnames -Credential $Cred
if($test -ne $null)
{
"$hostnames found in AD"
}
else
{
"$hostnames not found in AD"
}

Thanks in advance!

  • The only thing that I notice that seems a bit off is that in your param block you don't have the '[string]' declaration beside $ADpswd.

    The other thing I would caution you about is that the way you have this implemented currently, you cannot provide more than one host name to your "Get" call (I only mention this because your variable is "$hostnames").