PowerShell 4.0 Implementation Automation settings server _powershell

Source: Internet
Author: User

PowerShell is a powerful operating tool in Microsoft's Windows operating system. The PowerShell version is updated with the release of Windows, for example, the latest version of PowerShell 4.0 is available in the latest Windows Server r2/windows 8.1. The new version of Windows Server is expected to bring the PowerShell 5.0 version next year.

PowerShell 4.0 brings a lot of new features to help administrators, most notably enhanced automation. Here I share the PowerShell tips that Mark Minasi on the windowsitpro of foreign websites, which the authors have been experimenting with for a number of times, specifically for Windows Server 2012, Windows Server 2012 R2 and Windows 8.

Let's take a look at how PowerShell makes life easier for Windows Server administrators by automating them.

Tip 1: Build USB 3.0 Installation Stick

Tools to use: mount a USB 3.0U disk with Windows Server R2 installation Mirror, and an XML file created by Windows System Image Manager (Wsim). Wsim is a free download of the Automation and Deployment Toolkit (ADK). Wsim requires you to answer dozens of questions in advance about the system you created, disabling Internet Explorer (IE) Enhanced Security configuration from the product key to the disk.
When these problems are completed, Wsim produces a file named Autounattend.xml. If you copy the file to the root of the USB drive installation, Windows Setup will read and execute the commands in Autounattend.xml. (If you think it's a stupid way to install through a USB drive, it's not: Setup in Server 2012 supports USB 3.0, and all deletion and reconstruction work takes only 3-4 minutes when the power is low.) When you build a Web server with this method, some of the installation work takes less than a minute. )

Tip 2: Dump tunnel adapters, Tweak IPv6

The output of Ipconfig seems too much. Paste copy the following three lines of command, you will find ipconfig output too much streamlining:
Set-netteredoconfiguration-type Disabled
Set-netisatapconfiguration-state Disabled
Set-net6to4configuration-state Disabled
If you're using IPV6, your organization uses Teredo, intrasite Automatic Tunnel Addressing (Protocol) or 6to4 technology, so don't worry.

Undo the command, just replace the disable default. Based on these principles, I'm not suggesting that you completely disable IPV6, but I have a lot of clients and colleagues to do, so if you want to go to ipv6-less, you can use this command on any given network adapter:

If you want to undo these commands, you only need to restore to disable the default. It is not recommended that you completely disable IPV6, but if you want to do so, you can use the following command on any network adapter:

Copy Code code as follows:

Set-netadapterbinding-name <nic name>-displayname "Internet Protocol Version 6 (Tcp/ipv6)"-enabled: $false

If you are creating a server on hardware that has only one wired network card, the command is as follows:

Copy Code code as follows:

Set-netadapterbinding-name ethernet-displayname "Internet Protocol Version 6 (Tcp/ipv6)"-enabled: $false

Alternatively, you can componentid skip the lengthy displayname values:

Copy Code code as follows:

Set-netadapterbinding-name Ethernet-componentid MS_TCPIP6

DisplayName and ComponentID values for the NIC:

Copy Code code as follows:

get-netadapterbinding | Select Interfacealias,displayname,componentid | Ogv

Tip 3: Set the TCP/IP and DNS settings for the server

The server needs a static IP address, but it is cumbersome to set it up. This process can be simplified by using the PowerShell new-netipaddress and Set-dnsclientserveraddress cmdlet. Although a bit verbose, it is far more readable than the Netsh commands.
New-netipaddress is as follows:

Copy Code code as follows:

New-netipaddress-interfacealias <NICname>-ipaddress <address>-defaultgateway <address>- Prefixlength <nn>
eg. New-netipaddress-interfacealias ethernet-ipaddress 24

Prefixlength refers to the number of 1 in the subnet mask. It uses the short class inter-domain routing (IDR) method to describe a IPv4 subnet mask, such as Microsoft has not added the-dnsserver option to this cmdlet, but there is a bunch of DNS-related cmdlet that can be easily serviced for DNS servers and DNS clients.

In any case, setting up a static DNS server address on the NIC requires only the use of set-dnsclientserveraddress. It only needs to know which network card is assigned to and the IP address of the DNS server, such as

Copy Code code as follows:

Set-dnsclientserveraddress-interfacealias ethernet-serveraddresses

If you want to restore the system and find the DNS server by DHCP, use –resetserveraddresses, such as

Copy Code code as follows:

Set-dnsclientserveraddress-interfacealias ethernet-resetserveraddresses

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.