Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

If you work with Network Interface cards (NIC) or manage systems, you will want to become familiar with the new Windows Server 2012 PowerShell Cmdlets that simplify many common NIC and Network configuration tasks. These Cmdlets make it easy to automate the configuration management multiple NICs on multiple servers.
In subsequent installments of this series, we'll be looking at Network latency and adjusting NIC parameters quite a bit, so becoming familiar with the basics is time well spent.
In this article I will demonstrate how to use PowerShell to perform NIC configuration tasks, including:
    • Naming your NIC
    • Getting and setting advanced NIC parameter settings
    • Determining valid NIC parameters
    • Resetting Parameters to Factory Default Values
    • Using the -NoRestart flag to 'batch' changes
    • Determining the NIC Driver Version
The reference documentation for these Cmdlets is available on-line at
These commands can be used on your local machine, remote machines, or to configure an arbitrary number of NIC adapters on an arbitrary number of machines.
There are a large number of CmdLets covering virtually all aspects of network configuration, but I’m going to limit myself to performing some common NIC configuration tasks.

Naming Your NIC


If you have multiple NICs, remembering which is which can be difficult. The Consistent Device Naming (CDN) feature added in Windows 8 and Windows Server 2012 makes it easier for those who are concerned with network cabling to determine which physical network interface is which.
And with PowerShell, you can also give your NICs descriptive names which you can use for subsequent configuration tasks. This is particularly useful if you have multiple NICs or if you manage multiple servers.
Let's get a list of all the NICs on my machine. (abbreviated to fit on the page). The names below don't tell us very much about which NIC interface is used for:
PS > Get-NetAdapter
NameInterfaceDescriptionifIndexStatus ...
WiredEthernetConnec...6Intel(R) Gigabit ET Dual Port Serv...#417Up
WiredEthernetConnec...5Intel(R) Gigabit ET Dual Port Serv...#315Up
WiredEthernetConnec...4Realtek PCIe GBE Family Controller15Disconnected
WiredEthernetConnec...3NetEffect(TM) Ethernet Server Cluste...14Up
WiredEthernetConnec...2Intel(R) Gigabit ET Dual Port Serv...#213Up
WiredEthernetConnectionIntel(R) Gigabit ET Dual Port Server...12Disabled

Let's rename the NICs to something easier to understand. In this example, I'll name the NICs to reflect their function.
PS> Rename-NetAdapter -Name "Wired Ethernet Connection 4" PublicInternet1

After a few more of these commands, we arrive at a much easier to understand display. Notice each NIC now has a descriptive name:
PS > Get-NetAdapter
NameInterfaceDescriptionifIndexStatus ...
PublicInternet16Intel(R) Gigabit ET Dual Port Serv...#417Up
PublicInternet25Intel(R) Gigabit ET Dual Port Serv...#315Up
ManagementNetwork4Realtek PCIe GBE Family Controller15Up
DatabaseLink3NetEffect(TM) Ethernet Server Cluste...14Disconnected
ClusterNetwork2Intel(R) Gigabit ET Dual Port Serv...#213Up
BackupLink1Intel(R) Gigabit ET Dual Port Server...12Disabled

Looking at this table, you can answer questions like "Why can't I reach the database?" It's disconnected. And you can fix this admittedly contrived example problem by enabling the back-up link - by name.
PS> Enable-NetAdapter BackupLink
Now that we have an easier way to refer to specific NIC interfaces, let’s move on to NIC configuration parameters.

Viewing and Setting Advanced NIC Parameters


With Windows Server 2012, PowerShell makes it easy to set and check the network parameters that previously had to be set using the Network Control Panel application. You can still use the control panel application of course, but PowerShell makes it possible to automate the process.
Let's try some practical examples. First well look at some NIC parameters, then see how to change them from PowerShell. To examine the NIC parameters for the PublicInternet1 NIC we can use.
To save a little typing, I'm going to abbreviate the NIC Name PublicIntenet1 as P*1. PowerShell will expand the wild-card for me.
PS C> Get-NetAdapterAdvancedProperty P*1
NameDisplayNameDisplayValueRegistryKeywordRegistrValue
PublicInternet1Flow ControlTx Enabled*FlowControl{1}
PublicInternet1Interrupt ModerationEnabled*InterruptMo...{1}
PublicInternet1IPv4 Checksum OffloadRx & Tx Enabled*IPChecksumO...{3}
PublicInternet1IPsec OffloadAuth Header & ESP Enabled*IPsecOffloadV2{3}
PublicInternet1Jumbo PacketDisabled*JumboPacket{1514}
PublicInternet1Large Send Offload V2 (IPv4)Enabled*LsoV2IPv4{1}
PublicInternet1Large Send Offload V2 (IPv6)Enabled*LsoV2IPv6{1}
PublicInternet1Max number of RSS Processors8*MaxRssProce...{8}
PublicInternet1Preferred NUMA nodeSystem Default *NumaNodeId{65535}
PublicInternet1Maximum Number of RSS Queues2 Queues*NumRssQueues{2}
PublicInternet1Priority & VLANPriority & VLAN Enabled*PriorityVLA...{3}
PublicInternet1Receive Buffers512*ReceiveBuffers{512}
PublicInternet1Receive Side ScalingDisabled*RSS{0}
PublicInternet1Speed & DuplexAuto Negotiation*SpeedDuplex{0}
PublicInternet1SR-IOVDisabled*Sriov{0}
PublicInternet1TCP Checksum Offload (IPv4)Rx & Tx Enabled*TCPChecksum...{3}
PublicInternet1TCP Checksum Offload (IPv6)Rx & Tx Enabled*TCPChecksum...{3}
PublicInternet1Transmit Buffers2048*TransmitBuf...{2048}
PublicInternet1UDP Checksum Offload (IPv4)Rx & Tx Enabled*UDPChecksum...{3}
PublicInternet1UDP Checksum Offload (IPv6)Rx & Tx Enabled*UDPChecksum...{3}
PublicInternet1Virtual Machine QueuesDisabled*VMQ{0}
PublicInternet1Interrupt Moderation RateAdaptiveITR{65535}
PublicInternet1Log Link State EventEnabledLogLinkState...{51}
PublicInternet1Gigabit Master Slave ModeAuto DetectMasterSlave{0}
PublicInternet1Locally Administered Address--NetworkAddress{--}
PublicInternet1Wait for LinkAuto DetectWaitAutoNegC...{2}

Let's increase the number of Receive Buffers to 2048. (Increasing the number of Receive Buffers (aka receive descriptors) increases the size of the buffering area used to hold arriving Ethernet frames. This buffering area resides in an area of system memory and is allocated from non-paged pool. On busy servers with lots of network traffic, increasing the number of buffers reduces the probability that an arriving frame will need to be discarded because there was no buffering available. The numeric value refers to the maximum number of Ethernet frames that can be buffered.)
PS> Set-NetAdapaterAdvancedProperty P*1 -DisplayName "Receive Buffers" -DisplayValue 2048.

Now let's check it.
PS> Get-NetAdapterAdvancedProperty P*1 -DisplayName "Receive Buffers"
NameDisplayNameDisplayValueRegistryKeywordRegistryValue
PublicInternet1Receive Buffers2048*ReceiveBuffers{2048}

This small example illustrates that by using the -DisplayName and -DisplayValue switches, we can set the NIC Advanced Configuration parameters from PowerShell.
This means it is also easy to automate the checking and setting of NIC parameters. For large installations, the parameters can be saved in a SQL-Server database, or in an XML file, or furnished by a Web Service, or simply in a comma separated variable (csv) file. Powershell makes it easy to access any of these.

Determining Valid NIC Parameter Values

Different kinds of NICs may have different parameter settings. How do you know what parameters values are valid for your NIC? You can use PowerShell to determine which values are valid for a particular parameter on a particular NIC. The values are supplied by the NIC Driver supplier and will reflect NIC specific capabilities.
Let's see all the parameters and their permissible values for the PublicInternet1 NIC and format the display as a table using 'ft' (format table).
PS> Get-NetAdapterAdvancedProperty P*1 | ft DisplayName, DisplayValue, ValidDisplayValues
DisplayNameDisplayValueValidDisplayValues
-----------------------------------------
Flow ControlTx Enabled{Disabled, Tx Enabled, Rx Enabled...
Interrupt ModerationEnabled{Disabled, Enabled}
IPv4 Checksum OffloadRx & Tx Enabled{Disabled, Tx Enabled, Rx Enabled,..
IPsec OffloadAuth Header & ESP Enabled{Disabled, Auth Header Enabled, ...
Jumbo PacketDisabled{Disabled, 4088 Bytes, 9014 Bytes}
Large Send Offload V2 (IPv4)Enabled{Disabled, Enabled}
Large Send Offload V2 (IPv6)Enabled{Disabled, Enabled}
Max number of RSS Processors8{1, 2, 4, 8}
Preferred NUMA nodeSystem Default{System Default, Node 0, Node 1, N..
Maximum Number of RSS Queues2 Queues{1 Queue, 2 Queues, 4 Queues, 8...
Priority & VLANPriority & VLAN Enabled{Priority & VLAN Disabled, Priority
Receive Buffers2048
Receive Side ScalingDisabled{Disabled, Enabled}
Speed & DuplexAuto Negotiation{Auto Negotiation, 10 Mbps Half Dup.
SR-IOVDisabled{Disabled, Enabled}
TCP Checksum Offload (IPv4)Rx & Tx Enabled{Disabled, Tx Enabled, Rx Enabled..
TCP Checksum Offload (IPv6)Rx & Tx Enabled{Disabled, Tx Enabled, Rx Enabled,
Transmit Buffers2048
UDP Checksum Offload (IPv4)Rx & Tx Enabled{Disabled, Tx Enabled, Rx Enabled,
UDP Checksum Offload (IPv6)Rx & Tx Enabled{Disabled, Tx Enabled, Rx Enabled,
Virtual Machine QueuesDisabled{Disabled, Enabled}
Interrupt Moderation RateAdaptive{Adaptive, Extreme, High, Medium...}
Log Link State EventEnabled{Enabled, Disabled}
Gigabit Master Slave ModeAuto Detect{Auto Detect, Force Master Mode, ..
Locally Administered Address
Wait for LinkAuto Detect{Off, On, Auto Detect}

For example, let’s see what values are possible for Flow Control:
PS> Get-NetAdapterAdvancedProperty P*1 -DisplayName *flow* | fl DisplayName, ValidDisplayValues

DisplayName :Flow Control
ValidDisplayValues :{Disabled, Tx Enabled, Rx Enabled, Rx & Tx Enabled}
'
Here we see the only permissible values for the "Flow Control" parameter are:
{Disabled, Tx Enabled, Rx Enabled, Rx & Tx Enabled}

and we could use those to set the flow control to "Rx & Tx" Enabled as follows:
PS> Set-NetAdapterAdvancedProperty P*1 -DisplayName "Flow Control"-DisplayValue "Rx & Tx Enabled"

Determining Valid Numeric Parameters

Some parameters accept range of numeric values. For these values, you can determine the valid values by examining the NumericaParameterBaseValue, NumericParameterMaxValue, NumericParameterMinValue, and NumericParametersStepValue.
As an example, let's see the permissible settings for Transmit Buffers and Receive Buffers on this particular NIC.
PS> Get-NetAdapterAdvancedProperty P*1 -DisplayName *Buffers | fl DisplayName, NumericP*

DisplayName :Receive Buffers
NumericParameterBaseValue :10
NumericParameterMaxValue :2048
NumericParameterMinValue :80
NumericParameterStepValue :8
DisplayName :Transmit Buffers
NumericParameterBaseValue :10
NumericParameterMaxValue :2048
NumericParameterMinValue :80
NumericParameterStepValue :8

As another example, we can check the Receive Side Scaling (RSS) Maximum RSS Processor Number and
RSS Base Processor Number. (notice that by specifying the first and last letter of these names and an asterisk, (i.e. M*r and R*r) PowerShell will expand the property names automatically)
PS > Get-NetAdapterAdvancedProperty P*1 -DisplayName M*r | fl DisplayName, NumericP*
DisplayName: Maximum RSS Processor Number
NumericParameterBaseValue: 10
NumericParameterMaxValue: 63
NumericParameterMinValue: 0
NumericParameterStepValue: 1

PS > Get-NetAdapterAdvancedProperty P*1 -DisplayName R*r | fl DisplayName, NumericP*
DisplayName: RSS Base Processor Number
NumericParameterBaseValue: 10
NumericParameterMaxValue: 63
NumericParameterMinValue: 0
NumericParameterStepValue: 1




Resetting a Parameter to the Default Value

If you want to reset an advanced parameter back to the factory default value, you can use the Reset-NetAdapterAdvancedProperty CmdLet. In the following example, we set the Interrupt Moderation parameter to the factory default:
PS> Reset-NetAdapterAdvancedProperty P*1 –DisplayName “Interrupt Moderation”

If you want to reset all the advanced parameters back to default value, you can use a wild card
PS> Reset-NetAdapterAdvancedProperty P*1 –DisplayName *

 Batching Commands

PowerShell provides a neat new feature which can batch multiple parameter changes into a single operation. This reduces the number of Network link 'bounces' during configuration and speeds up the configuration dramatically.
When you change a NIC parameter, the NIC driver needs to be restarted for the change to be applied. If you are used to using control panel, you may have noticed that when you make a change the affected network interface goes down briefly while the driver is restarted. This is especially noticeable if you are using a remote terminal session and reset the NIC you are using for the connection. This will temporarily interrupt your remote terminal session. Although the link will be restored, this is annoying, particularly if you need to do this repeatedly when using the network control panel to change NIC setting. But not with PowerShell.
If you are making multiple changes, PowerShell allows you to batch multiple changes and have them all applied with a single restart by using the -NoRestart flag.
For example, suppose I have four parameters I want to set. I append -NoRestart to all the CmdLet invocations except the last.
Set-NetAdapterAdvancedProperty $eth -DisplayName name1 -DisplayValue val1 -NoRestart
Set-NetAdapterAdvancedProperty $eth -DisplayName name2 -DisplayValue val2 -NoRestart
Set-NetAdapterAdvancedProperty $eth -DisplayName name3 -DisplayValue val3 -NoRestart
Set-NetAdapterAdvancedProperty $eth -DisplayName name4 -DisplayValue val4
The NIC will be restarted on when the last CmdLet runs, and will apply all the previous settings at one time. There will be only one link bounce.
Alternatively, you can explicitly restart the NIC by invoking
Restart-NetAdapter (NIC Name)
That's useful if your configuration script is a loop. Each CmdLet in the loop would include -NoRestart. Finally, when the loop completes, issue an explicit restart to apply all the changes. Restarting the NIC disables and re-enables the NIC, applying pending parameter changes in the process.

Determining the NIC Driver VersionA common operations task is checking the version of all the NICs and drivers on a server. This is easy to do with PowerShell by examining the NetAdapter properties. In the following example, we use a wild card to display all the driver related properties in a list format:
PS> Get-NetAdapter P*1 | fl Dri*
DriverVersion: 12.1.77.0
DriverInformation: Driver Date 2012-07-10 Version 12.1.77.0 NDIS 6.30
DriverFileName: e1q63x64.sys
DriverDate: 2012-07-10
DriverDateData: 129863520000000000
DriverDescription: Intel(R) Gigabit ET Dual Port Server Adapter
DriverMajorNdisVersion: 6
DriverMinorNdisVersion: 30
DriverName: \SystemRoot\system32\DRIVERS\e1q63x64.sys
DriverProvider: Intel


Installation of Microsoft IIS


  • Go to [Start/Control Panel/Programs and Features]
     
  • Click in the left panel on "Turn Windows features on or off”
     
  • Expand “Internet Information Services” and enable these options:
    • Web Management Tools, IIS6 Management Compatibility, check “II6 Scripting tools”
    • Web Management Tools, IIS Management console
    • Web Management Tools, IIS Management Scripts and Tools
    • Web Management Tools, IIS Management Service
  • At 'World Wide Web Services/ Application Development Features', enable :
    • .NET Extensibility
    • ASP
    • ASP.NET
  • At 'World Wide Web Services/Common Http features', enable:
    • Static Content

  • Click “OK” and let Windows update. This may take some time.

Configuration of IIS

  • Go to Start/Control Panel/Administrative Tools and start “Internet Information Services (IIS) Manager”
     
  • In the left pane, expand server name, “Sites”, “Default web site”
      
  • Right-click on “Default web site” and choose “Add Application …” (not: virtual folder)

  • Alias = the name where the WMS site would be available, for instance "WMS"
  • Physical path = The path where the IIS files for WMS ASP are located, for example C:\E-WMS\IIS
    (note: these ASP files have to be extracted from the Exact.WMS.Web.zip file which is downloaded with the Globe product update)
  • Click 'OK'.
     
  • Click on your WMS virtual directory in the left pane and double-click “Authentication” in the options screen, make sure that 'Anonymous Authentication' is enabled. WMS does not use the other authentication methods.

  •   Click on your WMS virtual directory in the left pane and now double-click "ASP.Net Globalization" in the upper part of the middle pane. In this screen you can determine what regional settings to apply on the 'hand terminal', by setting the options 'Culture' and 'IU Culture'. This is especially important for input of decimals and dates on the hand terminal.

Set these options to "English (United States) (en-us)" if you want to use the 'dot' as decimal sign. Set these options to "Dutch (Netherlands) (nl-nl)" if you want use the 'comma' as decimal sign. Keep in mind that on a hand terminal the 'dot' 
is often a separate key on the keyboard. When entering dates on the hand terminal, the format YYYY-MM-DD (2010-12-31) will always work, regardless of regional settings.

English Us = enter decimals as 5.5 on the mobile device
Dutch (NL) = enter decimals as 5,5 on the mobile device

Application Pool

WMS ASP requires .NET Framework 3.5 to run properly. (shown as  '.NET Framework v2.0.50727'). In this IIS version the .NET version is managed through the IIS 'Application pool'.

Create a new Application Pool

Start the IIS manager and expand the server name. Right click on "Application Pools" and select Add Application Pool. Name the Application Pool, for instance E-WMS. 


Set .NET to 2.0.50727 ( = Framework 3.5 - Framework 4 is not supported yet) 
Set 'Managed pipeline mode' to 'Classic'
Press OK to save this new Application Pool.

Application Pool advanced settings

In 64-bit Windows, it is necessary to define a specific setting, which is only available in the Application Pool settings.
Start the IIS manager and expand the server name. Click on "Application Pools", a list with available Application Pools will show. Select the pool you want to use for E-WMS and then press right clickAdvanced Settings.  

On a 64 bit server,  change the setting "Enable 32-bit Applications" to True and press OK.
Also make sure 'Managed Pipeline Mode' is set to 'Classic'.


Link Application Pool to E-WMS web site

When a specific Application Pool was configured for E-WMS, it still has to be linked to the E-WMS web site.
Start IIS manager, expand the server name, expand "Sites", expand "Default web site". Click on the E-WMS web site and choose Basic settings in the far right panel. Click on Select and choose the specific Application Pool which was created in the previous step:

Press OK to save this configuration.




If the computer clock loses time although you keep fixing it, there may be a serious cause. This article shows you what the underlying causes may be and how you can fix them.


1. CMOS Battery

This is the most likely scenario, especially if your computer is not brand new.
The CMOS battery sits on your computer’s motherboard and provides power to the Complementary Metal Oxide Semiconductor (CMOS) chip. The CMOS chip stores information about the system configuration, including the date and time. The CMOS battery makes sure the chip can store this data even while the computer is turned off and not hooked up to power. If the battery goes bad, the chip starts losing information and one of the symptoms is that your computer no longer maintains its time and date.

Replacing the CMOS battery is pretty easy. You just have to turn off your computer, ground yourself, open the case, find out which type of battery sits on your motherboard, go buy it, start over, and exchange the battery. 

2. Time Zone

This is an easy to fix cause for when your computer clock loses time.
Your computer may simply be set to the wrong time zone and every time you fix the time, it resets itself to that time zone when you reboot. If the minutes are correct and only the hour is bad, that’s probably the issue you’re dealing with.
In Windows 7 you can easily fix the time zone. Right-click the system clock in your taskbar and select > Adjust date/time. Under the headline > Time Zone check whether the information is correct. If not, click the > Change time zone… button and set your time zone. Don’t forget to confirm your changes and you’re all set.

3. Malware

This is the least pleasant and most difficult to manage scenario.
Your computer may have been hijacked by a virus that messes with your computer time. To fix it, you need to gather a few tools. First, make sure your anti-virus program is up to date with the latest virus definitions. Then get a good malware scanner, for example Malwarebytes or Spybot Search & Destroy. 
Once you have all these tools downloaded, updated and installed, start in Safe Mode and run them. It’s important to start in safe mode because the malware won’t launch and be active when you choose this boot mode. This means that it is less likely to escape detection and removal.


As a systems admin, you might have probably wanted to deny your users to use a particular software application. This is pretty common since using some applications in some network environments is illegal.

In order to block an application, we can make user of a great feature called AppLocker available in Windows 7 and Windows Server 2008 R2. Here is a step by step guide on how to configure AppLocker in the domain or on computers in a special OU or site.

Let’s assume in this exercise you want to block the Chess game on all the computers in your domain.

First of all, on your DC you need to go to Administrative Tools and open up Group Policy Management console and then right click on the Default Domain Policy and clickEdit to open Group Policy Management Editor.

Then here, under Computer Configuration go to Windows Settings -> Security Settings -> Application Control Policies -> AppLocker

Before anything right-click on AppLocker and click on Properties and then underExecutable Rules, click on Configured and choose Enforce rules:





















And then as shown in the below photo right click on Executable Rules and choose Create New Rule:














Once you click on Create New Rule, this window will open up and you just need to click on Next:


















On the next Window, you will need to select which users or groups this rule applies to and whether you want the rule to allow users or deny them to use that application. Once Configured, click Next:


















On the next window choose File Hash and then click Next:


















On the next windows click on Browse Files and choose the program file and then click Next:


















Give the new rule a name and then click Create:


















Now the new rule must have been added under Executable Rules as shown below:








Now if anyone in the domain tries to open Chess from their computer, they will receive this message, meaning that Chess game has been blocked by a policy: