Active Directory Powershell-Modul aktualisieren
1. April 2019
Mit den passenden Powershell-Skripts sparen sich die Systembetreuer Zeit und Nerven. Besonders wenn es darum geht, unterschiedliche Operationen auf einer Vielzahl an Systemen durchzuführen.
Möchten die Administratoren die Powershell (PS) unter Windows 10 auf den aktuellen Stand bringen, muss im ersten Schritt das passende PS-Modul heruntergeladen werden. Im nächsten Schritt wird in der Regel RSAT (Remote Server Administration Tools) installiert und aktiviert, um danach die Hilfefunktion für das AD-Modul auf den aktuellen Stand gebracht. Anstatt dies manuell abzuarbeiten, lässt sich auch ein entsprechendes Skript aus der Technet-Galerie einsetzten. Dabei werden folgende Punkte nacheinander abgearbeitet:
Find and download the CPU-architecture-appropriate Windows 10 RSAT package (Remote Server Administration Tools)
Install the RSAT
Enable the Active Directory PowerShell feature
Update-Help for the AD module
Dabei wird das Skript in der aktuell installierten S-Version ausgeführt, entweder in einem PS-Kommandozeilenfenster, oder beispielsweise auch mit Hilfe der ISE (Integrated Scripting Environment):
7
Ashley McGlone, Microsoft Premier Field Engineer
15
For Windows 10 performs the following tasks:
17
- Downloads and installs Windows 10 RSAT
for
the appropriate system architecture
19
- Enables the RSAT AD PowerShell feature
21
- Updates help
for
the AD module
23
- Displays validation output
25
-------------------------------------------------------------------------------
29
This Sample Code is provided
for
the purpose of illustration only and is not
31
intended to be used
in
a production environment. THIS SAMPLE CODE AND ANY
33
RELATED INFORMATION ARE PROVIDED
"AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER
35
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
37
MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. We grant You a
39
nonexclusive, royalty-
free
right to use and modify the Sample Code and to
41
reproduce and distribute the object code form of the Sample Code, provided
43
that You agree: (i) to not use Our name, logo, or trademarks to market Your
45
software product
in
which
the Sample Code is embedded; (ii) to include a valid
47
copyright notice on Your software product
in
which
the Sample Code is embedded;
49
and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and
51
against any claims or lawsuits, including attorneys’ fees, that arise or result
53
from the use or distribution of the Sample Code.
57
This posting is provided
"AS IS"
with no warranties, and confers no rights. Use
59
of included script samples are subject to the terms specified
63
-----------------------------------------------------------------------------
73
Installs the AD PowerShell module from RSAT
for
Windows 10
77
Performs the following tasks:
79
- Downloads and installs Windows 10 RSAT
for
the appropriate system architecture
81
- Enables the RSAT AD PowerShell feature
83
- Updates help
for
the AD module
85
- Displays validation output
89
Requires an elevated PowerShell host.
93
Requires an internet connection to download the RSAT
install
.
97
The RSAT hotfix download (&
lt
;100MB) will be stored
in
the Downloads
99
folder of the user running the script.
103
Checks the following before taking action:
105
- Is the system running Windows 10?
107
- Is the RSAT already installed?
109
- Is the AD PowerShell feature already enabled?
113
Switch parameter to validate the
install
. Performs the following:
115
- Displays the RSAT update
file
that was downloaded.
117
- Confirms the hotfix is installed.
119
- Displays help
for
Get-ADDomain.
121
- Run the cmdlets Get-ADDomain.
125
Install-ADModule -Verbose
129
Install-ADModule -Test -Verbose
133
Function Install-ADModule {
139
[switch]$Test = $
false
145
If ((Get-CimInstance Win32_OperatingSystem).Caption -like
"*Windows 10*"
) {
147
Write-Verbose
'---This system is running Windows 10'
151
Write-Warning
'---This system is not running Windows 10'
159
If (Get-HotFix -Id KB2693643 -ErrorAction SilentlyContinue) {
163
Write-Verbose
'---RSAT for Windows 10 is already installed'
171
Write-Verbose
'---Downloading RSAT for Windows 10'
175
If ((Get-CimInstance Win32_ComputerSystem).SystemType -like
"x64*"
) {
177
$dl =
'WindowsTH-KB2693643-x64.msu'
181
$dl =
'WindowsTH-KB2693643-x86.msu'
185
Write-Verbose
"---Hotfix file is $dl"
189
Write-Verbose
"---$(Get-Date)"
199
$Destination = Join-Path -Path $HOME -ChildPath
"Downloads\$dl"
201
$WebClient = New-Object System.Net.WebClient
203
$WebClient.DownloadFile($URL,$Destination)
209
Write-Verbose
'---Installing RSAT for Windows 10'
211
Write-Verbose
"---$(Get-Date)"
215
wusa.exe $Destination /quiet /norestart /log:$home\Documents\RSAT.log
223
Write-Host
"."
-NoNewline
225
Start-Sleep -Seconds 3
227
}
until
(Get-HotFix -Id KB2693643 -ErrorAction SilentlyContinue)
231
Write-Verbose
"---$(Get-Date)"
239
If ((Get-WindowsOptionalFeature -Online -FeatureName `
241
RSATClient-Roles-AD-Powershell -ErrorAction SilentlyContinue).State `
247
Write-Verbose
'---RSAT AD PowerShell already enabled'
255
Write-Verbose
'---Enabling RSAT AD PowerShell'
257
Enable-WindowsOptionalFeature -Online -FeatureName RSATClient-Roles-AD-Powershell
265
Write-Verbose
'---Downloading help for AD PowerShell'
267
Update-Help -Module ActiveDirectory -Verbose -Force
271
Write-Verbose
'---ActiveDirectory PowerShell module install complete.'
279
Write-Verbose
'---Validating AD PowerShell install'
281
dir
(Join-Path -Path $HOME -ChildPath Downloads\*msu)
283
Get-HotFix -Id KB2693643
295
Get-Help Install-ADModule -Full
299
Install-ADModule -Verbose
315
wusa.exe /uninstall /kb:2693643 /quiet /norestart /log:$home\RSAT.log
Das Listing ist alternativt auf der entsprechenden Microsoft-Seite im TXT-Format abrufbar, und muss mit Administrator-berechtigungen ausgeführt werden.
Florian Huttenloher