Tuesday, August 5, 2014

Using activedirectory powershell module with 2003 domain controllers


See the following for step by step how to use active directory powersSell cmdlets against 2003 domain controllers
http://blogs.technet.com/b/ashleymcglone/archive/2011/03/17/step-by-step-how-to-use-active-directory-powershell-cmdlets-against-2003-domain-controllers.aspx

Also, in order to run RSAT on Windows 7, with 2003 or 2008 DC's:
This is still untested, but it looks like the author has figured out how to add the Active Directory PowerShell modules to Windows 7.

Why would you want to do this?

Well, I am writing PowerShell script to document AD, and I would like to be able to run them in an older AD environment, such as an upgrade candidate, etc.

With a Win 7 workstation, I am hoping that I can load it up and run the script against an old 2003 server.

System Requirements:
This information was found on a forum (http://social.technet.microsoft.com/Forums/windowsserver/en-US/094f9dd3-669a-4bea-9f81-f2ea009384d1/powershell-v2-and-active-directory-module)

Also see: http://www.mikepfeiffer.net/2010/01/how-to-install-the-active-directory-module-for-windows-powershell/

I decided to post the content here just in case I loose access to the blog.


In summary:
I found a very Simple and Elegant way to make the AD PowerShell Module Portable.
you will need 3 simple things
1.) the ActiveDirectory Module Directory from a system that has it already installed. 
Standard path on a 64bit windows 7
C:\Windows\System32\WindowsPowerShell\v1.0\Modules
2.)  Global Assembly Cache Utility
Available from the Windows SDK
gacutil.exe
3.) the Microsoft.ActiveDirectory.Management dll assembly
found on a system that already has the RSAT and powershell enabled. Microsoft.ActiveDirectory.Management.dll
Now in order to make this work you need to install the dll using the gacutil program.  commandline is as follows.
GACUTIL.exe -I Microsoft.ActiveDirectory.Management.dll
Once installed you must copy the entire directory from item 1 to the powershell module location.
Once copied you can then use the import command to import it and start using the cmdlets.  below is my batch file I wrote to automate this for deployment during SCCM.
We want our help desk to be able to clone security groups assigned to our computers for application deployment so that when they image a replacement computer the new computer will automatically get the previously assigned applications.  Also see below for that powershell script as well.  Hope this helps the community.
And for the people/MS that say it can not be done,  here to you :)

REM ************************************
REM SET Working Directory
REM ************************************

@setlocal enableextensions
@cd /d "%~dp0"

REM ************************************
REM Copy Module
REM ************************************

if not exist C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory mkdir C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory
xcopy /y /e .\ActiveDirectory\*.* C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory

REM ************************************
REM Install Microsoft Active Directory Assembly
REM ************************************

gacutil.exe -i Microsoft.ActiveDirectory.Management.dll
REM ************************************
REM Set Powershell Execution Policy
REM ************************************

powershell set-executionpolicy remotesigned
REM ************************************
REM Run Computer Membership Clone
REM ************************************

powershell ./ADCompMemberof.ps1
exit

######################################################################
Powershell script to copy group membership of a computer object in AD
  # Create TS Environment COM Object
$TS = New-Object -ComObject Microsoft.SMS.TSEnvironment
$Target=$TS.Value('_SMSTSMachineName')
$Source=$TS.Value('OldComputer')

$array = @()
$groups = Get-AdComputer -Identity $source -property "MemberOf" 

Foreach($group in $groups.memberOf) {
$array +=$group
}

Get-ADComputer -Identity $target | Add-ADPrincipalGroupMembership -MemberOf $array

Wednesday, May 14, 2014

Exchange 2010: Redirecting the Root Web Site to /owa and Forcing SSL

Script: Set-Exchange2010RedirectSSL.ps1 – Redirecting the Root Web Site to /owa and Forcing SSL in Exchange 2010


http://www.ehloworld.com/186

Thursday, May 1, 2014

SMTP MX record SPF Wizard

Use the following site to audit and assist in the creation of a valid SPF record for your email domain:

http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/



Tuesday, April 22, 2014

PowerShell Tips #2 - Working with Multi-Instance or Nested Properties

The objective here is to create reports of objects that contain properties with multiple instances, or nested properties.

Example is Get-DNSServer

Get-DNSServer by itself, with no parameters, produces a very detailed, multiple-heading report with a ton of detail.   The internal code to produce this report will be the subject of another technote.

For this exercise though, see the outout from the command

PS C:\ > Get-DnsServer |gm -MemberType Property

Name                       MemberType Definition
----                       ---------- ----------
PSComputerName             Property   string PSComputerName {get;}
ServerCache                Property   CimInstance#Instance ServerCache {get;set;}
ServerDiagnostics          Property   CimInstance#Instance ServerDiagnostics {get;set;}
ServerDsSetting            Property   CimInstance#Instance ServerDsSetting {get;set;}
ServerEdns                 Property   CimInstance#Instance ServerEdns {get;set;}
ServerForwarder            Property   CimInstance#Instance ServerForwarder {get;set;}
ServerGlobalNameZone       Property   CimInstance#Instance ServerGlobalNameZone {get;set;}
ServerGlobalQueryBlockList Property   CimInstance#Instance ServerGlobalQueryBlockList {get;set;}
ServerRecursion            Property   CimInstance#Instance ServerRecursion {get;set;}
ServerRootHint             Property   CimInstance#InstanceArray ServerRootHint {get;set;}
ServerScavenging           Property   CimInstance#Instance ServerScavenging {get;set;}
ServerSetting              Property   CimInstance#Instance ServerSetting {get;set;}
ServerZone                 Property   CimInstance#InstanceArray ServerZone {get;set;}
ServerZoneAging            Property   CimInstance#InstanceArray ServerZoneAging {get;set;}
ServerZoneScope            Property   CimInstance#InstanceArray ServerZoneScope {get;set;}


What I am interested in reporting is the IP Addresses of the Forwarders, which is contained in the "ServerForwarder" property.


So, we now type "(get-dnsserver).ServerForwarder" and get the following:

UseRootHint        : True
Timeout(s)         : 3
EnableReordering   : True
IPAddress          : {10.1.1.4, 10.2.1.20}
ReorderedIPAddress : {10.1.1.4, 10.2.1.20}


Now type:
PS C:\ > (get-dnsserver).ServerForwarder | GM

Name                      MemberType     Definition
----                      ----------     ----------
EnableReordering          Property       bool EnableReordering {get;set;}
PSComputerName            Property       string PSComputerName {get;}
Timeout                   Property       uint32 Timeout {get;set;}
UseRootHint               Property       bool UseRootHint {get;set;}
IPAddress                 ScriptProperty System.Net.IPAddress[] IPAddress {get=[OutputType([Syste...
ReorderedIPAddress        ScriptProperty System.Net.IPAddress[] ReorderedIPAddress {get=[Outpu...


Notice that a "Property" of the ServerForwarder property is not a Property at all, but rather a ScriptProperty.  It contains multiple values as a sudo-property. 

So lets keep going.   
PS C:\> ((get-dnsserver).ServerForwarder).IPAddress
 

Address            : 67174666
AddressFamily      : InterNetwork
ScopeId            :
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : 10.1.1.4

Address            : 335610378
AddressFamily      : InterNetwork
ScopeId            :
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : 10.2.1.20


So how do we query the DNS Server and spit out this magical list of IP Addresses?
Method 1) 
PS C:\ > (((get-dnsserver).ServerForwarder).IPAddress).IPAddressToString
10.1.1.4
10.2.1.20


Method 2)


PS C:\ > Get-DnsServer |%{$_.ServerForwarder | %{($_.IPAddress).IPAddressToString}}

10.1.1.4
10.2.1.20


End of Lesson.

Sunday, March 30, 2014

MEC 2014 Notes


Resources: