I wrote a script based on the guidelines given to me, however I am getting some errors. This is the script I have:
$aryText = Get-Content -Path "C:\Users\Administrator\Documents\stepbystep.txt"
foreach ($aryElement in $aryText)
{
$strClass = "organizationalUnit"
$strOUName = $aryElement
$objADSI = [ADSI]"LDAP://dc=nwtraders,dc=msft"
$objOU = $objADSI.Create($strCLass, $strOUName)
$objOU.SetInfo()
}
The error I get are "The Following exception occurred while retrieving member "Create": "A referral was returned from the server." This happens at the $objOU = $objADSI.Create($strCLass, $strOUName) line
I also get a second error, probably because of the first error stating "You cannot call a method on a null-valued expression". And this happens at $objOU.SetInfo(). Any help on how to fix these errors or what steps I should take next would be greatly appreciated.