by bigtwenty at 2012-12-26 15:19:16
I have a csv file formatted with two columns, one is titled name and the second is proxyaddress. This is my script so far:by Klaas at 2012-12-27 00:27:04
Import-Module ActiveDirectory
Import-Csv ajaytest.csv | Foreach {
Get-ADUser $.Name | Set-ADUser -Add @{proxyAddresses = ($.proxy -split ";")}
}
The output I get tells me:
Get-aduser: cannot find an object with identity: "john smith" under "DC=company,DC=com".
at c:\users\testuser\desktop\importadusersproxy.ps1:3 char:12
+ Get-ADUser <<<<< $.Name | Set-ADUser -Add @{proxyAddresses = ($.proxy -split ";")}
+ CategoryInfo : ObjectNotFound: (John Smith :ADUser) [Get-Aduser], ADIdentityNotFoundException
+ FullyQualifiedErroID : Cannot Find an object with the identity: "john smith" under: "DC=Company,DC=Com".,Micro
soft.ActiveDirectory.Management.Commands.GetADUser
Could someone help me out here? The user exists but it isnt in that container, it is listed for example in DC=Users,DC=SubCompany,DC= Company,DC=Com
I believe the script should be checking the entire domain but doesn’t seem to be finding the user. In the spread sheet, the Name column is filled with: John Smith
I also tried smith, John
Thanks
Although the Description in the help says you can pass any of the following properties:by bigtwenty at 2012-12-27 08:39:08
[quote]The Identity parameter specifies the Active Directory user to get. You can identify a user by its distinguished name (DN), GUID, security identifier (SID), Security Accounts Manager (SAM) account name or name.[/quote], when you read further about the ‘-identity’ property it says it accepts DN, GUID, SID or SAMaccountname, not Name.
You could use the name in the -filter parameter, something like: Get-ADuser -Filter ‘Name -Like $.name’ or you could make a .csv with SAMaccountname.
Thanks for your help, now this is what i get: (I also do a set-location to map to the share this script and csv are locate on, then I run the ps1 file.by bigtwenty at 2012-12-27 08:57:32
Get-ADUser : Error parsing query: ‘Name -Like @{Name=ajay patel; ProxyAddress=smtp:jsmith@company.com;smtp:test@yourma
ma.com}.Name’ Error Message: ‘syntax error’ at position: ‘12’.
At \server\group\share\Scripts\Exchange\365\CSV\importadusersproxy.ps1:3 char:12
+ Get-ADUser <<<< -filter "Name -Like $.Name" | Set-ADUser -Add @{proxyAddresses = ($.proxy -split ";")}
+ CategoryInfo : ParserError: ( [Get-ADUser], ADFilterParsingException
+ FullyQualifiedErrorId : Error parsing query: ‘Name -Like @{Name=john smithl; ProxyAddress=smtp:jsmith@company.co
m;smtp:test@yourmama.com}.Name’ Error Message: ‘syntax error’ at position: ‘12’.,Microsoft.ActiveDirectory.Managem
ent.Commands.GetADUser
So i have adjusted my script to below:by bigtwenty at 2012-12-27 10:41:34
Import-Module ActiveDirectory
Import-Csv ajaytest.csv | Foreach {
Get-ADUser -Filter "Name -Like '$.Name’" | Set-ADUser -Add @{proxyAddresses = ($.proxy -split ";")}
}
And now i get no error, but the proxy addresses were not added. Anyway to turn on verbose logging?
Ok, im a beginner at this sort of stuff but i figured it out. I was following this thread at
http://social.technet.microsoft.com/For … d507875de8
It appears that my csv file proxy column was not labeled correctly. It was labeled proxyaddresses and not simply proxy. So for all you beginners out there, the csv file should have two columns, the first in block A1 should read Name and B1 should read proxy. Then A2 should have the samaccount name like jsmith and B2 should have smtp:jsmith@company.com;johns@company2.com
and the script should read
Import-Module ActiveDirectory
Import-Csv ajaytest.csv | Foreach {
Get-ADUser $.Name | Set-ADUser -Add @{proxyAddresses = ($_.proxy -split ";")}
}
Thanks for everyones help again