title: PowerShell Active Directory Objects Writable Properties
body: <p>I'm working on a script to synchronize two Active Directory forests (Production and QA, if you don't understand why, it doesn't matter, I need to do it). The problem I've run into is filtering properties to only writable and only those that are normally writable. From the MMC "Active Directory Users and Computers" I can look at the Attribute Editor tab and filter the attributes to "Show only writable attributes". This displays a completely different list than what I get viewing the same object with a PowerShell command. </p>
  
  <p>I don't want to synchronize or attempt to modify attributes like nTSecurityDescriptor, ObjectClass, ObjectGUID, etc. I also don't want to try developing and maintaining a static list for each object class (OU, User, Group). </p>
  
  <p>Is there a better way to retrieve the properties that are writable for a given AD object?</p>
  
  <p>Here is an example of the problem with an OU object:</p>
  
  <pre><code>PS E:\Powershell&gt; $ou | Get-Member | Where-Object {$_.Definition.Contains("set;")}
  
     TypeName: Microsoft.ActiveDirectory.Management.ADOrganizationalUnit
  
  Name                            MemberType Definition
  ----                            ---------- ----------
  City                            Property   System.String City {get;set;}
  Country                         Property   System.String Country {get;set;}
  Description                     Property   System.String Description {get;set;}
  DisplayName                     Property   System.String DisplayName {get;set;}
  DistinguishedName               Property   System.String DistinguishedName {get;set;}
  l                               Property   System.String l {get;set;}
  ManagedBy                       Property   System.String ManagedBy {get;set;}
  nTSecurityDescriptor            Property   System.DirectoryServices.ActiveDirectorySecurity nTSecurityDescriptor {get...
  ObjectClass                     Property   System.String ObjectClass {get;set;}
  ObjectGUID                      Property   System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral...
  ou                              Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection ou {get;set;}
  PostalCode                      Property   System.String PostalCode {get;set;}
  ProtectedFromAccidentalDeletion Property   System.Boolean ProtectedFromAccidentalDeletion {get;set;}
  PSShowComputerName              Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection PSShowCompu...
  State                           Property   System.String State {get;set;}
  StreetAddress                   Property   System.String StreetAddress {get;set;}
  WriteDebugStream                Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection WriteDebugS...
  WriteErrorStream                Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection WriteErrorS...
  WriteInformationStream          Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection WriteInform...
  WriteVerboseStream              Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection WriteVerbos...
  WriteWarningStream              Property   Microsoft.ActiveDirectory.Management.ADPropertyValueCollection WriteWarnin...
  </code></pre>