Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Set-ADUser Issues

$
0
0

I am writing a PS script to update the "seeAlso" Active Directory attribute for our users.  I am having issues with the Set-ADUser command.  Here is my code:

Import-Module ActiveDirectory
$Emps = Get-ADUser -Filter {SAMAccountName -Like "username"} -SearchBase "OU=OUName,DC=domain,DC=com" -Properties *

foreach ($Emp in $Emps) {
$SAM = $Emp.SAMAccountName
$URL = "http://sharepoint.domain.com/Employee%20Pictures/$SAM.jpg"
Set-ADUser $SAM -Replace @{seeAlso=$URL}
}


This is the error I get:

Set-ADUser : The name reference is invalid
At line:4 char:11
+ Set-ADUser <<<<  $SAM -Replace @{seeAlso=$URL} 
    + CategoryInfo          : NotSpecified: (nmuleski:ADUser) [Set-ADUser], ADException
    + FullyQualifiedErrorId : The name reference is invalid,Microsoft.ActiveDirectory.Management.Commands.SetADUser

I tried importing the AD module manually and I didn't receive any errors. I also tried running the Set-ADUser command manually but I still got the same error.  I also get this error wither I run the script on my workstation or on my PDC.  Can anybody help me out??


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>