Skip to main content

Posts

How to handle attributes with hyphens in PowerShell

Some attributes that you can pull from Active Directory may have a hyphen in them.  That makes them a bit difficult to work with in PowerShell.  When PowerShell sees the hyphen, it assumes that you just put a cmdlet in the wrong place.  To handle a hyphenated attribute, you need to rename that property.  For this example, I am going to use the msDS-ResultantPSO.  Take a look at the code below. $UserList = Get-AdUser -filter * -property msDS-ResultantPSO | Select name , @ { Name = "ResultantPSO" ;Expression = { $_ . "msDS-ResultantPSO" }} The @ symbol tells us we are about to rename a property.  In the first section inside double quotes, we declare the new name of the property.  In the Expression portion, we tell PowerShell what attribute we want to rename.  Notice we use the $_. to tell PowerShell to look at the current object passed to it for this attribute.  From here on out, this property is now referred to as msDsResultantPSO...

Commands for Server Core

Below is a list of commands that I picked up from TechNet Magazine.  Remember that SCONFIG now replaces some of these in Server Core 2008 R2. Here are links to more information on SCONFIG How to open the firewall How to add a users to the Local Administrators group How to move a Server Core 2008 R2 from a domain to a workgroup Add Server Core to a domain Setting IP Addresses Change Windows Update settings Rename Server Core Enable Remote Desktop on Server Core     Control desk.cpl - View or set display settings. Control intl.cpl - View or set regional and language options, including formats and the keyboard layout. Control sysdm.cpl - View or set system properties. Control timedate.cpl - View or set the date, time, and time zone. Cscript slmgr.vbs –ato - Activate the operating system. DiskRaid.exe - Configure software RAID. ipconfig /all - List information about the computer’s IP address configuration. NetDom RenameComputer - Set the server’s name and ...

What happens to the FSMO roles on a DC if it is demoted to a member server?

To test this out, I used NETDOM QUERY FSMO to make sure that all the FSMO roles were on the server that I was about to demote to a member server. When DCPromo was executed, the FSMO roles were transferred to another DC.

How to prioritize which Domain Controller clients attempt to bind to first.

When a client boots on your network, it needs to bind to a domain controller for authentication and to receive Group Policy.  It is always a best practice to have at least DCs per AD site.  Both DCs will allow for a client to bind to them.  If you want one DC to be preferred over the other, you simply need to change one property in DNS.   On one of your DCs, open the DNS console. Expand Forward Lookup Zones Expand <Domain name> .  In this case Contoso.com Expand _Sites Expand <Site name .  In this case Default-First-Site-Name . Expand _TCP Double click the resource record of the server that you do not want as the primary domain controller for this site.   Change the priority to something other than zero.  Zero is the highest priority.  This will tell clients to attempt to bind to the other DC before attempting to bind to this one.  

Determine what is stored in the Global Catalog with DSQuery

It is rare these days that I use a DS command, but in this case it worked out well.  Use the command below do return the attributes that are currently stored on in the Global Catalog in your domain.  This command was executed with administrative level permissions on a Domain Controller.  Replace YourDomain with the correct LDAP information. dsquery * "cn=Schema,cn=Configuration,dc=YourDomain,dc=com" -filter "(&(objectCategory=AttributeSchema)(IsMemberOfPartialAttributeSet=TRUE))" -attr LDAPDisplayName -limit 0   The resulting list are the attributes in Active Directory that are also in the Global Catalog.

List the PSO associated with a user account with PowerShell

    PSO’s (Password Setting Objects) is another name for Fine Grain Password Policy.  A PSO allows an organization to have different password policies based on a security group.  That means that unlike in an Windows 2003 domain where all password meet the same rules, in a 2008 domain you can have multiple rules for your passwords.   The code below allows you two obtain a list of all user accounts that have a PSO assigned to and that PSO is.  It is designed to be used as a function or dot sourced into PowerShell.   <# . SYNOPSIS Returns a list of user names and there PSO . . DESCRIPTION Returns a list of user names and the Resultant PSO that is currently in effect on that user . . EXAMPLE Get - PSOUsers Returns a list to the pipeline of the username and the PSO currently in effect on the user account . . EXAMPLE Get - PSOUsers | Sort - Object PSO Returns a list...

How to create a new VM from a snapshot

In Hyper-V R1, we had the option to export out a VM and then later import it back in again.  For many in testing environments, this created large export files when only the VM with a specific snapshot was needed.  With Hyper-V R2 we can now create a new VM from a snapshot of another one.  This is advantageous because now you can create an entire new VM without all the extra files from other snapshots that you may not want.  Take a look at my screen shot below of my snapshot tree. Let’s say that I want to create a new VM from this one. Apply the snapshot that you want to use as the base for the new VM. Right click the VM and select Export.  Give it a location and click Export . One thing that I do not like about this process is that you will not see any progress bars or other indicators to let you know when the export is finished.  Your VMs will not be able to start until the export is completed.  If you look in the destination that you specified, ...