Move-ADObject - input object cannot be found to any parameters for the command - error

后端 未结 2 1853
再見小時候
再見小時候 2021-01-28 21:07

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

相关标签:
2条回答
  • 2021-01-28 21:51

    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")
    {
    
    0 讨论(0)
  • 2021-01-28 21:53

    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"
    
    0 讨论(0)
提交回复
热议问题