Modifying AD Attibutes having Extended Schema

by aubrytj at 2012-10-14 16:37:05

Stuck on how to modify an extended schema attribute(s).
Would appreciate any help - I’m still new with PowerShell - yet have learned a lot each time I venture.

Would like to loop through each Windows XP workstation and update a selective field(s) that is now part of an extended schema?

I am able to update the fields manually using ADSI Attribute Editor…yet this would be a bit cumbersome since their are many workstations…and to possibly run on scheduled task for each new workstation that gets created.

The extended schema fields in question needs a defined contant value:
dcloc-xssip = 'USB’
dcloc-location = 'WesternState’

Currently have the following that does give the results for only “Windows XP” workstations - since I did not want to include servers when executed.

Get-QADComputer -IncludeAllProperties -ComputerRole Member -SizeLimit 0 -OSName ‘Windows XP*’ | Format-Table -Property computername, osname, osversion, description, dcloc-xssip, dcloc-location

Could it be something like:
Get-QADComputer -IncludeAllProperties -ComputerRole Member -SizeLimit 0 -OSName ‘Windows XP*’ | Format-Table -Property computername, osname, osversion, description, dcloc-xssip, dcloc-location | set-qadcomputer -dcloc-xssip ‘USB’, -dcloc-location ‘WesternState’

Don’t believe this would work since a positional parameter cannot be found that accepts argument for ‘USB’.

Any idea’s would again be most appreciated…

Thanks,

Ted
by Klaas at 2012-10-15 01:47:38
Have you tried without the ‘Format-Table’?
This cmdlet writes output to the screen so there are no objects left to pipe to set-qadcomputer.
I think it will work if you pipe the results from ‘Get-QADComputer’ directly to ‘Set-QADComputer’.
by aubrytj at 2012-10-15 17:05:48
Thanks Klaas - this is what I replaced it with - am I doing something incorrect here - looks like the "dcloc-xssip’ is not found?
Do I have to declare something…

Get-QADComputer -IncludeAllProperties -ComputerRole Member -SizeLimit 0 -OSName ‘Windows XP*’ | Set-QADComputer -dcloc-xssip ‘USB’ | Format-Table -Property computername, osname, osversion, description, dcloc-xssip


Set-QADComputer : A parameter cannot be found that matches parameter name ‘dcloc-xssip’.
At C:\Scripts\List Selective OS with dcloc Value.ps1:12 char:125
+ Get-QADComputer -IncludeAllProperties -ComputerRole Member -SizeLimit 0 -OSName ‘Windows XP*’ | Set-QADComputer -dcloc
-xssip <<<< ‘USB’
+ CategoryInfo : InvalidArgument: (:slight_smile: [Set-QADComputer], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.SetComput
erCmdlet
by Klaas at 2012-10-16 00:40:54
As the message says: there is no parameter with that name, only for some properties there’s a parameter. For all the others you can use the -objectattributes parameter, with @{dcloc-xssip='USB}.
Please do Get-Help Set-QADComputer -full | more for a full explanation of the cmdlet.
I think there won’t be anything left in the pipe to Format-Table. If you want output to the screen you can work with -passthru or Tee-object or use another Get-QADComputer.
by aubrytj at 2012-10-17 21:46:32
Thanks you Klass - will try it…looks simple…yet I’m still new at this - so will be test this out in our test domain… :slight_smile:
by aubrytj at 2012-11-11 18:58:40
#Beginning of Request
# -------------------------------------------------------------------------------
# Request to populate the dcloc-xssip field on all workstations
# Update - WIN XP/WIN7 workstations only
# Change field $dcloc-xssip for variable desired to populate field
#--------------------------------------------------------------------------------
Set-ExecutionPolicy remotesigned
Clear-Host
# Add Quest Snapin
Add-PSSnapin Quest.ActiveRoles.ADManagement
& ‘C:\Program Files\Quest Software\Management Shell for AD\qsft.ps1’

# Set dcloc-xssip constant variable
$dcloc-xssip=“USB”
# Run against selected OS’s -
Get-QADComputer -IncludeAllProperties -SizeLimit 0 -OSName ‘windows xp’,‘windows 7’ | Set-QADComputer -oa @{‘dclocxssip’=$dcloc-xssip}
#End of Request

Thou I get the “Operation is not valid due to the current state of the object. At :line:0 char:0” - it works - did some searching and this seems to be a glitch with PS v2 --> mentioned by Kirk Munro
"http]

So will have to just check out PS v3…

Performance is an issue yet it does work - any thoughts for improvement is appreciated!!! - yet this is "SOLVED"

Thanks! Klass and Kirk…
by dsf3g at 2012-11-12 05:50:34
This is very easy to do with Quest. Here’s a one liner:


Set-QADUser -Identity “MyUser” -ObjectAttributes @{“MyCustomAttribute” = “Value”}