How Do You Install IIS In An Automated Way Without The Install-WindowsFeature Command?

Problem scenario:  You want to install IIS on Windows Server 2016 in an automated way.  But you are prevented from using Install-WindowsFeature or Add-WindowsFeature commands for business related reasons.
Normally something like this would work: 
Import-module servermanager; Add-WindowsFeature web-server, web-webserver -Verbose
What do you do?

Solution:  Use PowerShell with the System.Windows.Forms.SendKeys feature.

servermanager
start-sleep 2
[System.Windows.Forms.SendKeys]::SendWait{%”M”}
[System.Windows.Forms.SendKeys]::SendWait{%”M”}
start-sleep 1
[System.Windows.Forms.SendKeys]::SendWait(“{DOWN}”)
[System.Windows.Forms.SendKeys]::SendWait({~})
[System.Windows.Forms.SendKeys]::SendWait({nnn})
start-sleep 1
[System.Windows.Forms.SendKeys]::SendWait({w})
[System.Windows.Forms.SendKeys]::SendWait{~~}
start-sleep 1
[System.Windows.Forms.SendKeys]::SendWait(“%{n}”)
[System.Windows.Forms.SendKeys]::SendWait(“%{n}”)
[System.Windows.Forms.SendKeys]::SendWait(“%{n}”)
[System.Windows.Forms.SendKeys]::SendWait(“%{n}”)
[System.Windows.Forms.SendKeys]::SendWait(“%{i}”)

How do you update the hosts file on a Windows server with PowerShell?

Problem scenario:  Whenever you use PowerShell to append to the c:\windows\system32\drivers\etc\hosts file you get spaces before and after every character of every string.  The problem does not happen with ordinary text files.

To illustrate, here is a line of PowerShell code and take not of the destination flat file involved:
echo “8.8.8.8        continualintegration.com” >> c:\windows\system32\drivers\etc\hosts

The above code results in a line like this inside the file:
8 .

Installing Git 2.x on CentOS and Getting Passed Two Potential Problems

Notice that there are two problem scenarios and two solutions.

Problem scenario:  When installing Git on CentOS you get this error “http-push.c … fatal error … expat.h: No such file or directory”

Solution
Run this: yum install expat-devel

Problem scenario:  When running commands to install Git on CentOS, you use the “make” command. 

How Do You Install Ansible on an AWS Instance of Linux SUSE?

Problem scenario
You want to use Ansible with Linux SUSE.  How do you install Ansible (the control node) on an AWS Instance of Linux SUSE?

Solution
Prerequisite
You must have 2.5 GB of memory (either in RAM or with a combination of RAM and swap space). For directions on how to configure swap space in the amount of 2 GB,

How Do You Automate a Process That Involve a GUI Operation with Powershell?

Question:  How Do You Automate a Process That Involve a GUI (e.g., to save an .xps or .oxps file) Operation with Powershell?  You do not want any part to be interactive.

Solution:  This applies to PowerShell version 4 and above.  This will save the content of c:\temp\contint.txt to goodName.xps in the default folder (often the user’s Documents folder) without needing to attend to the process.

# These three lines (starting with “Add…”,

How Do I Know If I Have a Safe Version of NTP on a Linux Server?

Question  How do I know if I have a safe version of NTP on a Linux server?

Background  The United States Computer Emergency Readiness Team’s website indicates that this many versions of NTP are susceptible to a denial-of-service attack.

Answer  Run this command:  ntpd –version

The output should look something like this:

ntpd 4.2.8p9

If it is lower than that (e.g.,

How To Install and Configure Salt Stack on RedHat Linux (AWS Instances)

Problem scenario
You want to install SaltStack on RHEL instances for the first time on an AWS server.

Solution in Three Parts
(If you want instructions on how to do this with Debian/Ubuntu and/or Linux SUSE, see this posting.)

Part 1  Create a Salt Master Server
1.  Create a RHEL instance and put it in a Security Group that has access to the Internet for this initial setup,

How Do You Use Conditional Logic on PowerShell Variables To Test If They Are Empty When The Variable’s Value Can Span Two Or More Lines?

Problem scenario:  Sometimes variables get values you do not expect.  Handling these exceptions is the mark of a good programmer.  

A PowerShell variable (e.g., $contint) may have the following content:

second line
third line”

When a variable’s value can span lines, conditional tests act unpredictably when they use such a variable.  For example a conditional test of the variable like this 

In PowerShell, how do you convert an array value into an integer value?

Question:  In PowerShell, how do you convert an array value into an integer value?

Answer:  Assuming that the value is an integer (e.g., not value that is legal for an array but not an integer), do the following:

1.  Write the array value to a file.
2.  Use the key word trim to eliminate blank space or other characters that would not be supported by the integer data type.