New-ADObject

New-ADObject is accessible with the help of addsadministration module. To install addsadministration on your system please refer to this link.

Synopsis

Creates an Active Directory object.

Description

The New-ADObject cmdlet creates a new Active Directory object such as a new organizational unit or new user account. You can use this cmdlet to create any type of Active Directory object. Many object properties are defined by setting cmdlet parameters. Properties that are not set by cmdlet parameters can be set by using the OtherAttributes parameter.

You must set the Name and Type parameters to create a new Active Directory object. The Name specifies the name of the new object. The Type parameter specifies the LDAP display name of the Active Directory Schema Class that represents the type of object you want to create. Examples of Type values include computer, group, organizational unit, and user.

The Path parameter specifies the container where the object will be created.. When you do not specify the Path parameter, the cmdlet creates an object in the default naming context container for Active Directory objects in the domain.

The following methods explain different ways to create an object by using this cmdlet.

Method 1: Use the New-ADObject cmdlet, specify the required parameters, and set any additional property values by using the cmdlet parameters.

Method 2: Use a template to create the new object. To do this, create a new Active Directory object or retrieve a copy of an existing Active Directory object and set the Instance parameter to this object. The object provided to the Instance parameter is used as a template for the new object. You can override property values from the template by setting cmdlet parameters. For examples and more information, see the Instance parameter description for this cmdlet. For information about Active Directory cmdlets use the Instance parameter, see about_ActiveDirectory_Instance.

Method 3: Use the Import-CSV cmdlet with the New-ADObject cmdlet to create multiple Active Directory objects. To do this, use the Import-CSV cmdlet to create the custom objects from a comma-separated value (CSV) file that contains a list of object properties. Then pass these objects through the pipeline to the New-ADObject cmdlet to create the Active Directory objects.

Parameters

 -AuthType 
         Specifies the authentication method to use. Possible values for this parameter include:

   Required?                    false
    Position?                    named
    Default value                Microsoft.ActiveDirectory.Management.AuthType.Negotiate
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Credential <PSCredential>
    Specifies the user account credentials to use to perform this task. The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory PowerShell provider drive. If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Description <String>
    Specifies a description of the object. This parameter sets the value of the Description property for the object. The LDAP Display Name (ldapDisplayName) for this property is "description".

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-DisplayName <String>
    Specifies the display name of the object. This parameter sets the DisplayName property of the object. The LDAP Display Name (ldapDisplayName) for this property is "displayName".

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-Instance <ADObject>
    Specifies an instance of an Active Directory object to use as a template for a new Active Directory object.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Name <String>
    Specifies the name of the object. This parameter sets the Name property of the Active Directory object. The LDAP Display Name (ldapDisplayName) of this property is "name".

    Required?                    true
    Position?                    2
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-OtherAttributes <Hashtable>
    Specifies object attribute values for attributes that are not represented by cmdlet parameters. You can set one or more parameters at the same time with this parameter. If an attribute takes more than one value, you can assign multiple values. To identify an attribute, specify the LDAPDisplayName (ldapDisplayName) defined for it in the Active Directory schema.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-PassThru <SwitchParameter>
    Returns the new or modified object. By default (i.e. if -PassThru is not specified), this cmdlet does not generate any output.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Path <String>
    Specifies the X.500 path of the Organizational Unit (OU) or container where the new object is created.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-ProtectedFromAccidentalDeletion <Boolean>
    Specifies whether to prevent the object from being deleted. When this property is set to true, you cannot delete the corresponding object without changing the value of the property. Possible values for this parameter include:

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-Server <String>
    Specifies the Active Directory Domain Services instance to connect to, by providing one of the following values for a corresponding domain name or directory server. The service may be any of the following:  Active Directory Lightweight Domain Services, Active Directory Domain Services or Active Directory Snapshot instance.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Type <String>
    Specifies the type of object to create. Set the Type parameter to the LDAP display name of the Active Directory Schema Class that represents the type of object that you want to create. Examples of type values include user, computer, and group.

    Required?                    true
    Position?                    3
    Default value                
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

-Confirm <SwitchParameter>
    Prompts you for confirmation before running the cmdlet.

    Required?                    false
    Position?                    named
    Default value                false
    Accept pipeline input?       false
    Accept wildcard characters?  false

-WhatIf <SwitchParameter>
    Shows what would happen if the cmdlet runs. The cmdlet is not run.

    Required?                    false
    Position?                    named
    Default value                false
    Accept pipeline input?       false
    Accept wildcard characters?  false

Syntax

New-ADObject [-WhatIf] [-Confirm] [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-Description <String>] [-DisplayName <String>] [-Instance <ADObject>] [-Name] <String> [-OtherAttributes <Hashtable>] [-PassThru] [-Path <String>] [-ProtectedFromAccidentalDeletion <Boolean>] [-Server <String>] [-Type] <String> [<CommonParameters>]

Notes
This cmdlet does not work with an Active Directory Snapshot.

————————– EXAMPLE 1 ————————–
C:\PS>New-ADObject -Name ‘10.1.1.0/26’ -Type subnet -Description ‘10.1.1.0/255.255.255.192’ -OtherAttributes @{location=”Building A”;siteObject=”CN=HQ,CN=Sites,CN=Configuration,DC=TOSSolution,DC=COM”} -Path “CN=Subnets,CN=Sites,CN=Configuration,DC=TOSSolution,DC=COM”
Creates a subnet object in the HQ site with the described attributes.

————————– EXAMPLE 2 ————————–
C:\PS>$subnetTemplate = get-adobject -Identity “CN=10.1.1.0/26,CN=Subnets,CN=Sites,CN=Configuration,DC=TOSSolution,DC=com” -properties description,location; new-adobject -instance $subnetTemplate -name “10.1.1.0/28” -type subnet -path “CN=Subnets,CN=Sites,CN=Configuration,DC=TOSSolution,DC=COM”
Creates a new subnet object, using a different subnet object as a template

————————– EXAMPLE 3 ————————–
C:\PS>New-ADObject -name SaraDavisContact -type contact -ProtectedFromAccidentalDeletion $true -OtherAttributes @{‘msDS-SourceObjectDN’=”CN=DelhiContacts,DC=TOSSolution,DC=COM”}
Creates a new contact object, sets the msDS-SourceObjectDN property and protects the object from accidental deletion

————————– EXAMPLE 4 ————————–
C:\PS>new-adobject -name Apps -type container -path “DC=AppNC” -server “TOSSolution-SRV1:60000”
Creates a new container object named ‘Apps’ in an LDS instance.

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command New-ADObject

Get-Command New-ADObject powershell script command cmdlet

You can also read about
. Get-ADObject
. Move-ADObject
. Remove-ADObject
. Rename-ADObject
. Restore-ADObject
. Set-ADObject

To know more PowerShell cmdlets(Commands) on addsadministration (Active Directory) click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Leave a Reply

Your email address will not be published. Required fields are marked *