Not exactly sure why I am getting this error - input object cannot be bound to any parameters for the command either because the commmand does not take pipeline input an
Have you tried getting the object explicitly?
$Session = New-PSSession -ComputerName DC01 -Credential $Cred
Import-Module ActiveDirectory -PSSession $Session
$comp = $env:COMPUTERNAME
if($comp.substring(5,3) -imatch "Sys")
{
$adObject = Get-ADObject -Filter {Name -eq $comp}
Move-ADObject -Identity $adObject -Targetpath "ou=System Servers,ou=PRD,ou=Servers,dc=com,dc=myCompany,dc=net"
}
elseif($comp.substring(5,3) -imatch "App")
{
You are both piping in the output of Get-ADComputer
and also defining the -Identity
property which are conflicting. Chose one way or the other.
Get-ADComputer $comp | Move-ADObject -Targetpath "ou=Database, dc=com,dc=company,dc=net"
or
$ADComputer = Get-ADComputer $comp
Move-ADObject -Identity $ADComputer -Targetpath "ou=Database, dc=com,dc=company,dc=net"