Hello anonymous user-0083,
Thank you for posting here.
What does your csv file look like?
Does it look like this?
Sample 1(there is head, there is the first line):
Or does it look like this?
Sample 2 (no head, no the first line):
If it looks like sample 1(there is head, there is the first line), run command below:
$gponame="test1"
$oulist= Import-Csv -Path "c:\oulist1.csv"
foreach ($OU in $oulist) {
New-GPLink -Name $gponame -Domain bb.b.local -Server "dfs1.bb.b.local" -Target $OU.OU
}
If it looks like sample 2 (no head, no the first line), run command below:
$gponame="test1"
$oulist= Import-Csv -Path "c:\oulist1.csv" -Header ABC
foreach ($OU in $oulist) {
New-GPLink -Name $gponame -Domain bb.b.local -Server "dfs1.bb.b.local" -Target $OU.ABC
}
The result is as below:
Tip:
1-Please use Import-Csv instead of Get-Content.
2-test1 is the gpo name in my child domain.
3-LAPS1 is the OU in my parent domain.
4-I have the same error as you in my lab if I use Get-Content.
Best Regards,
Daisy Zhou
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.