Category: Microsoft Windows PowerShell

Microsoft Windows PowerShell – List Installed Microsoft Updates

This script will provide a list of the Microsoft updates that have been applied to the local computer and provide the output in a file asd well as a directory of your choice.

Example: Get-HotFix | out-file -filepath “<File Path>”


Microsoft Windows PowerShell – List Microsoft Active Directory Group Members

This script will list the name and account name of each user within an Active Directory group and provide the output of the results in a file and directory of your choice.

Example: Get-ADGroupMember -identity “<Group Name>” | Select Name, SamAccountName | out-file -filepath “<File Path>”


Microsoft Exchange Server 2010 – Preinstallation Tasks

Prior to installing Microsoft Exchange Server 2010 server on Windows Server 2008 R2 Enterprise Edition (exchange01.root,sysadmin.net) you want to install Microsoft Filter Pack 2.0 x64 and import a number of Microsoft Windows PowerShell modules.

1. Verify the installation of Microsoft Filter Pack 2.0.

01

2. Next, open a Microsoft PowerShell, in an elevated session, and execute the following commands then restart the server.

05

3. Again, open a Microsoft PowerShell, in an elevated session, and execute the following commands then restart the server.

06

 

This completes the preinstallation tasks.


Microsoft Windows PowerShell – Configuring iSCSI Initiator Connections with Windows Server 2012 R2

You may modify the script below to automate the process of configuring an iSCSI Initiator with the Windows Server 2012 R2 operating system.

01


Microsoft Windows PowerShell – Enable IMCPv4 Ping Requests

You may use the following (2) commands to enable IMCPv4 ping requests for Windows Server 2012 R2 with Microsoft Windows PowerShell.

01


Microsoft Windows Powershell – Hyper-V Cmdlets

In order to view all of the Microsoft Hyper-V Cmdlets use the command get-command -module hyper-v. You may explore these commands and create scripts to automate your Hyper-V administration. Automation can save your Information Technology (IT) department both time and money.

01


Microsoft Windows PowerShell – Configure IP Address(es) and DNS Server(s)

You may modify the following Microsoft PowerShell (.ps1) script to configure the Internet Protocol (IP) and Domain Name System (DNS) servers for a Network Interface Card (NIC) in Windows Server 2012 R2.

01


Microsoft Hyper-V – Create a Virtual Switch using a PowerShell Script

Microsoft Hyper-V allows you to create (3) types of virtual switches (External, Internal and Private). These virtual switches may be created manually using the Hyper-V Manager or you may use a PowerShell (.ps1) script to automate the process. Below you will find a script to create an External virtual switch.

1. Issue the Get-NetAdapter command to provide a list of physical network interface (NIC) card(s) on the host. Take note of the name of the NIC that will be used for the external virtual switch.
01

2. You may modify the script below to create an external virtual switch.

02

3. Run Microsoft Powershell (as an Administrator) to create the external virtual switch.

03

4. Lastly, verify the creation of the virtual switch using the Hyper-V Manager > Virtual Switch Manager.

04


Microsoft Hyper-V – Install Hyper-V and the Management Tools using PowerShell

Microsoft allows you to install the Hyper-V role using PowerShell (run as an administrator) as well as the graphical user interface (GUI). One of the advantages of using PowerShell is that you can create a script to deploy a large number of Hyper-V hosts. During my initial testing I was able to install the Hyper-V role but the Management Tools were not being installed. The PowerShell installation requires the -IncludeManagementTools parameter to install the Management Tools.

The command to install both the Hyper-V role and the Management Tools is as follows:

Install-WindowsFeature –Name Hyper-V -ComputerName <computer_name> -IncludeManagementTools -Restart

01

If you will be installing the Hyper-V role on the local host then remove the -ComputerName <computer_name> parameter.

Microsoft provides great documentation for their solutions and the Install the Hyper-V Role and Configure a Virtual Machine document is no exception.

Enjoy!


Microsoft Windows PowerShell – Save Output Directly to a Text File

Using the Out-File Cmdlet in Microsoft Windows PowerShell allows you to send the output of a command directly to a text file. For instance, the example below you will send the output of the netstat -a command directly to the desktop of the user.

NOTE: Substitute the the actual username where %username% is located.

Microsoft Windows PowerShell - Save Output Directly to a Text File - 00

 

Enjoy!