PowerShell Logo Small

Set-ADObject



This is the built-in help made by Microsoft for the command 'Set-ADObject', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Modifies an Active Directory object.

SYNTAX


Set-ADObject [-Identity] <ADObject> [-Add <Hashtable>] [-AuthType {Negotiate | Basic}] [-Clear <String[]>] [-Credential <PSCredential>] [-Description <String>] [-DisplayName
<String>] [-Partition <String>] [-PassThru] [-ProtectedFromAccidentalDeletion <Boolean>] [-Remove <Hashtable>] [-Replace <Hashtable>] [-Server <String>] [-Confirm] [-WhatIf]
[<CommonParameters>]
Set-ADObject [-AuthType {Negotiate | Basic}] [-Credential <PSCredential>] [-PassThru] [-Server <String>] -Instance <ADObject> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ADObject cmdlet modifies the properties of an Active Directory object. You can modify commonly used property values by using the cmdlet parameters. Property values
that are not associated with cmdlet parameters can be modified by using the Add, Replace, Clear and Remove parameters.


The Identity parameter specifies the Active Directory object to modify. You can identify an object by its distinguished name (DN) or GUID. You can also set the Identity
parameter to an object variable such as $<localObject>, or you can pass an object through the pipeline to the Identity parameter. For example, you can use the Get-ADObject
cmdlet to retrieve an object and then pass the object through the pipeline to the Set-ADObject cmdlet.


The Instance parameter provides a way to update an object by applying the changes made to a copy of the object. When you set the Instance parameter to a copy of an Active
Directory object that has been modified, the Set-ADObject cmdlet makes the same changes to the original object. To get a copy of the object to modify, use the Get-ADObject
object. The Identity parameter is not allowed when you use the Instance parameter. For more information about the Instance parameter, see the Instance parameter description.
For more information about how the Instance concept is used in Active Directory cmdlets, type Get-Help about_ActiveDirectory_Instance.


For AD LDS environments, the Partition parameter must be specified except in the following two conditions:

-- The cmdlet is run from an Active Directory provider drive.
-- A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment, set the
msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=291122
Get-ADObject
New-ADObject
Remove-ADObject

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Set-ADObject -Identity 'CN=AntonioAl Direct Reports,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM' -Description 'Distribution List of Antonio Alwan Direct Reports'



This command sets the Description property on the object with DistinguishedName CN=AntonioAl Direct Reports,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM.




-------------------------- EXAMPLE 2 --------------------------

PS C:\>Set-ADObject -Identity 'CN=DEFAULTIPSITELINK,CN=IP,CN=Inter-Site Transports,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM' -Add
@{siteList='CN=BO3,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM'} -Partition 'CN=Configuration,DC=FABRIKAM,DC=COM'



This command adds the site CN=BO3,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM to the property siteList on the object with DistinguishedName
CN=DEFAULTIPSITELINK,CN=IP,CN=Inter-Site Transports,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM.




-------------------------- EXAMPLE 3 --------------------------

PS C:\>$urlValues = @()
PS C:\> $urlValues += "www.contoso.com"
PS C:\> $urlValues += "www.fabrikam.com"
PS C:\>Set-ADObject -Identity "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Add @{url=$urlValues}



This command adds two new urls to the property urlValues in the object with objectGuid cdadd380-d3a8-4fd1-9d30-5cf72d94a056.




-------------------------- EXAMPLE 4 --------------------------

PS C:\>$urlValues = @()
PS C:\> $urlValues += "www.contoso.com"
PS C:\> $urlValues += "www.fabrikam.com"
PS C:\> Set-ADObject -Identity "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Replace @{url=$urlValues;description="Antonio Alwan"}



This command replaces the old values of the multi-valued attribute url with the new values and sets the value of the attribute description.




-------------------------- EXAMPLE 5 --------------------------

PS C:\>Set-ADObject -Identity "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Remove @{url="www.contoso.com"} -Replace @{description="Antonio Alwan (European Manager)"}



This command removes the specified value from the attribute url and sets the value of the attribute description.




-------------------------- EXAMPLE 6 --------------------------

PS C:\>$myComp = Get-ADObject -Identity "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Properties "userAccountControl","description"
PS C:\> $myComp.userAccountControl = $myComp.userAccountControl -bor 50
PS C:\> $myComp.description = "Setting a new UAC on the object"
PS C:\> Set-ADObject -Instance $myComp



This command sets a new UAC bit on an object by updating the attribute userAccountControl and setting the value of the attribute description.




-------------------------- EXAMPLE 7 --------------------------

PS C:\>Set-ADObject -Identity "CN=InternalApps,DC=AppNC" -protectedFromAccidentalDeletion $True -Server "FABRIKAM-SRV1:60000"



This command sets container CN=InternalApps,DC=AppNC in an LDS instance to be protected from accidental deletion.




-------------------------- EXAMPLE 8 --------------------------

PS C:\>Get-ADObject -Identity "SecurityLevel2AccessGroup" | Set-ADObject -DisplayName "Security Level 2"



This command modifies the DisplayName property for the SecurityLevel2AccessGroup object. The command uses the Get-ADObject cmdlet to get the object, and then passes the
object to the current cmdlet by using the pipeline operator.