Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Scripting Games 2008 Sudden Death Challenge Event 8

Event 8 was a Quiz again, asking for AD property names, to check this I simply made the user in AD Users and Computers and checked the properties that where set after  from PowerShell.

But I had a problem with the Country / Region as USA as given in the example can not be set using the interface.

Changing this Listbox changes 2 properties C ( the ISO 2 letter country code ) and CO (Country region as in the AD U&C interface )

Below the output in PowerShell for the test-Ken I did create : 

PS C:\scripts> $s = ([adsisearcher][adsi]'')
PS C:\scripts> $s.Filter = 'CN=Kenneth J. Myer'
PS C:\scripts> $s.findOne().properties

Name                           Value
----                           -----
st                             {WA}
distinguishedname              {CN=Kenneth J. Myer,OU=MowOU,DC=PoshWorks,DC=com}
countrycode                    {840}
cn                             {Kenneth J. Myer}
lastlogoff                     {0}
dscorepropagationdata          {1/1/1601 12:00:00 AM}
usncreated                     {16948}
objectguid                     {201 204 87 3 233 241 208 70 134 73 100 218 82 130 217 69}
postalcode                     {98052}
whenchanged                    {2/28/2008 12:18:53 PM}
accountexpires                 {9223372036854775807}
displayname                    {Kenneth J. Myer}
primarygroupid                 {513}
streetaddress                  {712 NE 40th way}
badpwdcount                    {0}
objectclass                    {top, person, organizationalPerson, user}
objectcategory                 {CN=Person,CN=Schema,CN=Configuration,DC=PoshWorks,DC=com}
instancetype                   {4}
initials                       {J}
samaccounttype                 {805306368}
whencreated                    {2/28/2008 10:30:32 AM}
lastlogon                      {0}
l                              {Redmond}
useraccountcontrol             {512}
co                             {United States}
c                              {US}
samaccountname                 {kmyer}
givenname                      {Kenneth}
adspath                        {LDAP://CN=Kenneth J. Myer,OU=MowOU,DC=PoshWorks,DC=com}
pwdlastset                     {0}
logoncount                     {0}
codepage                       {0}
name                           {Kenneth J. Myer}
usnchanged                     {16965}
userprincipalname              {kmyer@PoshWorks.com}
badpasswordtime                {0}
objectsid                      {1 5 0 0 0 0 0 5 21 0 0 0 166 115 207 252 31 151 69 72 190 66 176 192 85 4 0 0}
sn                             {Myer}
telephonenumber                {1-425-555-1234}
 

So lets look what we can do by script :

$s = ([adsisearcher][adsi]'')
$s.Filter = 'CN=Kenneth J. Myer'
$s.findOne().properties
$u = $s.findOne().getdirectoryentry()
$u.c = 'USA'
$u.setinfo()
$u.co = 'USA'
$u.setinfo()
$u | fl c*

The output looks like this now :

PS I:\Users\Administrator> $u | fl c*

cn          : {Kenneth J. Myer}
c           : {USA}
co          : {USA}
codePage    : {0}
countryCode : {840}
Children    : {}
Container   :

So from script we can set both to USA, still no answer.

# after setting back with interface :
 
PS I:\Users\Administrator> $u = $s.findOne().getdirectoryentry()
PS I:\Users\Administrator> $u | fl c*

cn          : {Kenneth J. Myer}
c           : {US}
co          : {United States}
codePage    : {0}
countryCode : {840}
Children    : {}

 

From the solution posted I conclude they where looking for C and just did type an A to much ;-)

For the rest my answers will not be a suprise I think ;-)


 Kenneth                        givenname
 J                                   initials
 Myer                             sn
 712 NE 40th Way          streetaddress
 Redmond                      l
 WA                              st
 98052                           postalcode
 USA                             C or CO
 1-425-555-1234              telephonenumber
 kmyer@fabrikam.com    mail

Enjoy,

Greetings /\/\o\/\/

 

Published Thursday, February 28, 2008 6:50 PM by MoW
Attachment(s): ken.png

Comments

# Scripting Games: Sudden Death Challenge - Events 8 & 9 « PowerShell ?? ???????????? ??????????????

# useraccountcontrol

Thursday, June 19, 2008 8:53 AM by useraccountcontrol
Anonymous comments are disabled