I am starting a new thread on this since the last one had too many posts and was getting confusing.
$Inactive_Computer_OU = "OU=InactiveComputers,DC=Acme,DC=com"
$TargetOU = "Acme.com/FirmComputers/_L7/DAL"
$machine = get-content "C:\Reports\AD\machines.txt"
$OUs = "ALB", "ANC", "ATL", "BIR", "BOS", "CHA", "CHI", "CLE", "CMB", "COL", "DAL"
Foreach ($line in $machine)
{
{
If ($line -like "DAL*") {Write-Host "$line is your computer and your OU is $TargetOU"}
# This works. $line has my computer name and $TargetOU has the correct path
If ($line -like "DAL*") {Move-QADObject -Identity $line -NewParentContainer $TargetOU}
# this fails with this error. Move-QADObject : Ambiguous identity: DALWDJJAMES7.
}}
So I saw that Move-QADObject won't work since I need to specify the "FROM" location in AD. So I tried this:
If ($line -like "DAL*") {Move-QADObject -Identity $Inactive_Computer_OU/$line -NewParentContainer $TargetOU}
This does not work since when I join 2 $_variables they turn from RED to PURPLE.
So I tried using a + sign in-between my 2 variables like this.
If ($line -like "DAL*") {Move-QADObject -Identity $Inactive_Computer_OU + $line -NewParentContainer $TargetOU}
# which gave me this error. Move-QADObject : A positional parameter cannot be found that accepts argument '+'.
So how do you concatenate two variables in PowerShell?