之前记得在其他的代码中我会像下面一样写,但是报错:
Import-Csv -Path C:ToolKitsDomainhostname.csv | ForEach-Object {
Move-ADObject -Identity $_.hostname -TargetPath "ou=computers,ou=is,ou=china,dc=tcsgegdc,dc=com"
}
Google之后发现原来应该这样写:
Import-Csv -Path C:ToolKitsDomainhostname.csv | ForEach-Object {
Get-ADComputer $_.hostname | Move-ADObject -TargetPath "ou=computers,ou=is,ou=china,dc=tcsgegdc,dc=com"
}