Browsed by
Month: October 2013

PowerShell: Extension Attributes Server 2012

PowerShell: Extension Attributes Server 2012

A few days ago I wrote up a small post on modifying extension attributes for computer objects in Active Directory. I recently set up a lab with Server 2012 and found that extensionattribute1 is now msDS-cloudExtensionAttribute1, and if you just drop in msDS-cloudExtensionAttribute1 without quotes it has issues… This gave me a small headache, after reading this linkĀ I found that simply putting quotes around it, fixed it. The following code should work better in a server 2012 enviornment. import-module activedirectory…

Read More Read More

PowerShell: Import-Module Active Directory Cmdlet

PowerShell: Import-Module Active Directory Cmdlet

For those looking to query or do something within Active Directory in a PowerShell script, one of the most common mishaps I see at work is people forgetting to import the model. Often times everything else is fine, no syntax errors, etc. A simple fix for that is: import-module activedirectory The error generally looks something like this: PS C:\Users\userone> New-ADComputer -Name test The term ‘New-ADComputer’ is not recognized as the name of a cmdlet, function, script file, or operable program….

Read More Read More

PowerShell: Create Computers from Names in a List

PowerShell: Create Computers from Names in a List

Sometimes I find the need to create 10-20 computers for my AD lab at home, to do this in PowerShell you can run the following command: Get-Content computers.txt | ForEach-Object { New-ADComputer -Name $_ } If you want to create the computer objects in an OU other than “Computers”, lets say you want to prestage a number of computer objects for a new department, you could do this: Get-Content computers.txt | ForEach-Object { New-ADComputer -Name $_ -Path “Specify Path”}

PowerShell: Modify Extension Attributes on a List of Hosts

PowerShell: Modify Extension Attributes on a List of Hosts

Some of you may find this useful, I ran into this problem where I needed to set the value of an extension attribute on a number of hosts from a list. The following script should take care of that. At the end, it will let you know that the host is finished, it will output an error if one occurs. import-module activedirectory $machines = Get-Content “C:\PATH TO LIST\feedme.txt” foreach($machinename in $machines) { Set-ADComputer $machinename -add @{extensionattribute10 = “VALUE IN THE…

Read More Read More