• No results found

available cmdlets

In document 20417D-ENU-TrainerHandbook (Page 99-102)

PowerShell for basic tasks such as formatting Windows PowerShell output, using variables and loops, and creating scripts.

The main tasks for this exercise are as follows:

1. Import the Active Directory Windows PowerShell module and view the available cmdlets. 2. View options for creating a report of users in the Active Directory domain.

3. Use a script to create new users in the domain by using a CSV-based file. 4. Create a script to modify the address of a user based on the day of the week.

Task 1: Import the Active Directory Windows PowerShell module and view the

available cmdlets

1. If it is necessary, open Windows PowerShell ISE as an administrator. 2. Import the Active Directory module by using the Import-Module cmdlet.

3. Use the Get-Command cmdlet to view the cmdlets available in the Active Directory module.

Task 2: View options for creating a report of users in the Active Directory domain

1. If it is necessary, open Windows PowerShell ISE as an administrator, and import the Active Directory

module.

2. Use the Get-Command cmdlet to view the cmdlets available in the ActiveDirectory module. 3. Use Windows PowerShell to view a list of all users in the domain. Review how Format-List modifies

formatting by running the following commands: Get-ADUser -Filter * | Format-List Get-ADUser –Filter * |

Format-List -Property GivenName, Surname

Get-ADUser –Filter * -Properties * | Format-List *

4. Use Windows PowerShell to view a list of all users in the domain. Review how Format-Table modifies the formatting by running the following commands:

Get-ADUser -Filter * | Format-Table Get-ADUser –Filter * |

Format-Table -Property GivenName, Surname

Get-ADUser –Filter * -Properties * | Format-Table

5. Use Windows PowerShell to view a list of all OUs in the domain. Review how Format-Wide modifies the formatting by running the following commands:

Get-ADOrganizationalUnit -Filter * | Format-Wide Get-ADOrganizationalUnit –Filter * |

MCT USE ONL

Y. STUDENT USE PROHIBITED

2-38 Managing Windows Server 2012 by Using Windows PowerShell

6. Use Windows PowerShell to adjust the formatting of the users report. Review how the Sort-Object cmdlet modified the output, by running the following commands:

Get-ADUser -Filter * | Sort-Object| Format-Wide

Get-ADUser -Filter * | Sort-Object -Property ObjectGUID | Format-Wide -Property ObjectGUID

7. Run the following command to see how to use the Measure-Object cmdlet: Get-ADUser -Filter * | Measure-Object

Task 3: Use a script to create new users in the domain by using a CSV-based file

1. On LON-DC1, browse to the Start screen, and then type Notepad.exe. Press Enter.

2. Use Notepad.exe to view E:\Labfiles\Mod02\Democode\LabUsers.csv. You will need to change the file type to All Files.

3. Use Windows PowerShell ISE to open the script that is located at

E:\Labfiles\Mod02\Democode\LabUsers.ps1.

4. On line 13 of the script, modify the $OU variable to read: $OU = “ou=sales, dc=adatum,dc=com”. 5. Run the LabUsers.ps1 script.

6. Use the following command to confirm that Luka Abrus, Marcel Truempy, Andy Brauninger, and Cynthia Carey were created.

Get-ADUser –Filter * –SearchBase “OU=Sales,DC=Adatum,DC=com”

7. If you are having difficulties locating the new accounts in the long list of users, use the following command:

Get-ADUser –Filter * –SearchBase “OU=Sales,DC=Adatum,DC=com” –Properties “whenCreated” | Where-Object {$_.whenCreated –ge (Get-Date).Date}

Task 4: Create a script to modify the address of a user based on the day of the week

1. If it is necessary, open Windows PowerShell ISE as an administrator, and import the Active Directory

module.

2. Use Windows PowerShell ISE to open the script that is located at

E:\Labfiles\Mod02\Democode\Using If Statements.ps1

3. Verify that line 9 of the script reads:

$Admin = Get-ADUser –Identity Administrator –Properties StreetAddress.

4. Review each section of the script, and then run the script. Run the script a second time to view the changes.

Results: After completing this lab, you will have explored the Active Directory Windows PowerShell

module, experienced formatting output in Windows PowerShell, used a Windows PowerShell script to create users, and used Windows PowerShell conditional loops to modify Active Directory properties.

MCT USE ONL

Y. STUDENT USE PROHIBITED

Upgrading Your Skills to MCSA Windows Server® 2012 2-39

Exercise 3: Managing Servers by Using Windows PowerShell

Scenario

Because of your organization’s plans for remote server management, you want to explore possibilities to use Windows PowerShell for remote management. You want to test remote connections in Windows PowerShell and Windows PowerShell Web Access.

The main tasks for this exercise are as follows:

1. Install and configure Windows PowerShell Web Access. 2. Verify Windows PowerShell Web Access configuration.

Task 1: Install and configure Windows PowerShell Web Access

1. Install Windows PowerShell Web Access on LON-DC1 by using the following command: Install-WindowsFeature –Name WindowsPowerShellWebAccess -ComputerName LON-DC1 - IncludeManagementTools –Restart

2. Configure Windows PowerShell Web Access by running Install-PswaWebApplication.

3. Create a Windows PowerShell Web Access Authorization Rule that only enables the administrator to access the gateway by using the Add-PSWaAuthorizationRule.

Task 2: Verify Windows PowerShell Web Access configuration

1. Open Internet Explorer®, and navigate to https://LON-DC1.adatum.com/pswa.

2. Sign in to Windows PowerShell Web Access by using the following information: o User: Administrator

o Password: Pa$$w0rd o Computer: LON-DC1

3. Verify that you can retrieve information from LON-DC1 by retrieving the five newest system events. Run the following command:

Get-EventLog System –Newest 5

4. Obtain event log information from LON-SVR1 and LON-SVR2 by running the following command: Invoke-Command -ScriptBlock { Get-Eventlog Security -Newest 20 } -ComputerName LON- SVR1,LON-SVR2

Results: After this exercise, you will have performed one-to-many management of remote servers by

using Windows PowerShell, installed and configured Windows PowerShell Web Access, and managed servers by using Windows PowerShell Web Access.

MCT USE ONL

Y. STUDENT USE PROHIBITED

2-40 Managing Windows Server 2012 by Using Windows PowerShell

In document 20417D-ENU-TrainerHandbook (Page 99-102)