Automate "Remote Server Administration Tools (RSAT)" Deployment Using PowerShell

Automate "Remote Server Administration Tools (RSAT)" Deployment Using PowerShell

HI,

 

These days I am working on a script which does few “Active directory” task for us. This was seems simple so for but then I have found a major hurdle comes.

 

Problem:

 

The script on which I am working will be run on newly formatted system which is having Windows7 installed. The problem was that this script will is using few “Active Directory” cmdlets. And the new installation of windows doesn’t have “RSAT” installed by default. So until or unless I don’t have “ActiveDirectory” module installed till then I can’t use my

 “get-ADComputer ; get-ADComputerServiceAccount” cmdlets.

 

Then I thought there should be way to sort this out. So finally after spending whole day I found a way to do this within my PowerShell Script.

 

Solution:

 

The “Active Directory” module only available after installing the “Windows6.1-KB958830-x86-RefreshPkg.msu” package and then enable the “Active Directory Module for windows Powershell” in optional features.

 

The “Windows6.1-KB958830-x86-RefreshPkg.msu” is a “Microsoft update Standalone Package” and we can install these packages usingwusa.exe {Windows Update Standalone installer}.

 

 

So after installation of the “Windows6.1-KB958830-x86-RefreshPkg.msu” we need to enable the “Active Directory Module for windows Powershell” in optional features for this we are using dism.exe { Deployment Image Servicing and Management tool}.

 

The Script:

 

  • I am placing “Windows6.1-KB958830-x86-RefreshPkg.msu” in a central location so that script the executable from it.

o    \\soft-server\SoftRes\$hotfix

  • Normally I copied all the scripts in “c:\tools” folder and if that folder doesn’t exists it create it for us and write a message on screen that “C:\tools” is created.
    • $tool = test-Path C:\tools

if ($tool -eq $false ) {new-Item -Name "Tools" -Path c:\ -ItemType Directory; write-Host " folder "C:\Tools" created" -ForegroundColor Green }

  • Now it check if “Windows6.1-KB958830-x86-RefreshPkg.msu” file in exists in “C:\tools” folder and if it doesn’t exists it will copy the file from our central share folder  \\soft-server\SoftRes\$hotfix

o    hotfix = "Windows6.1-KB958830-x86-RefreshPkg.msu"

if ($testpath -eq $false) { Copy-Item \\dc3-del\PublicShare\$hotfix c:\tools\

Write-host "Files has Copied Sucessfully, Now I am going to  install the HOTFIX." -ForegroundColor RED

}

  • After copy the file from server it will install the files using wusa.exe
    • & wusa.exe "c:\tools\$hotfix" /quiet | out-null
    • After the installation finishes it will enable the “Active Directory PowerShell Module” feature in “windows Optional feature” using DISM
      • & dism.exe /Online /Enable-Feature /FeatureName:RemoteServerAdministrationTools /FeatureName:RemoteServerAdministrationTools-Roles /FeatureName:RemoteServerAdministrationTools-Roles-AD /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell | Out-Null

 

Download the script from here : http://dl.dropbox.com/u/17858935/RSAT_Deployment.zip

 

:::::::::::::::::::::::::::::::;; Start of the script ############

$hotfix = "Windows6.1-KB958830-x86-RefreshPkg.msu"

$testpath  test-path -path "c:\tools\$hotfix"

$tool = test-Path C:\tools

if ($tool -eq $false ) {new-Item -Name "Tools" -Path c:\ -ItemType Directory; write-Host " folder "C:\Tools" created" -ForegroundColor Green }

if ($testpath -eq $false) { Copy-Item \\soft-server\SoftRes\$hotfix c:\tools\

Write-host "Files has Copied Sucessfully, Now I am going to  install the HOTFIX." -ForegroundColor RED

}

 

Write-Host "Installing Remote Server Administration Tools...... " -ForegroundColor Yellow                  

& wusa.exe "c:\tools\$hotfix" /quiet | out-null

Write-Host "HotFix Installed, lets enable the Active Directory Features in "Optional Features"" -ForegroundColor "Green"

& dism.exe /Online /Enable-Feature /FeatureName:RemoteServerAdministrationTools /FeatureName:RemoteServerAdministrationTools-Roles /FeatureName:RemoteServerAdministrationTools-Roles-AD /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell | Out-Null

Write-Host "Lets Import the Active directory PowerShell Module Now.." -BackgroundColor Green  -ForegroundColor Blue

Import-Module ActiveDirectory

write-Host "Module successfully Imported" -ForegroundColor Red -BackgroundColor White

 

########## End of the Script ############## 

 

Download the script from here : http://dl.dropbox.com/u/17858935/RSAT_Deployment.zip

 

Screenshots:

13-02-2012 20-41-20 

Note: I tested this script on Windows 7 machine and it works perfectly for me . you can download installation file of "Windows6.1-KB958830-x86-RefreshPkg.msu" from here http://www.microsoft.com/download/en/details.aspx?id=7887. Also this is a simple static script no error checking is enable in it.

 

Thanks for viewing

Aman Dhally

messenger_freak_adp1 (30)

Leave a Comment
  • Please add 4 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Ed Price - MSFT edited Original. Comment: Title casing

Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Ed Price - MSFT edited Original. Comment: Title casing

Page 1 of 1 (1 items)