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…”,

 » Read more..

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.,

 » Read more..

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,

 » Read more..

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 

 » Read more..

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.

 » Read more..

How do you troubleshoot a CM tool doing an unattended installation on Windows Server 2012?

Problem scenario:  Using a CM tool, you transfer a PowerShell script to do an unattended installation on Windows Server 2012.  The CM tool transfers the media and the PowerShell script and launches the script once transferred. However, when you log into the Windows Server, you do not see the application installed.  When you manually run the PowerShell script and transfer the media over, there is no problem.  You want the CM tool to do the installation (transfer of media and execution of the PowerShell script).

 » Read more..

Troubleshooting Ansible With Windows Managed Nodes

Problem scenario
When running various Ansible operations, such as “ping,” result in an error like this “SSL: 500 WinRM Transport. [Error 104] Connection reset by peer.”  What should you do to get Ansible to work with Windows managed nodes?

Solution

Prerequisites
Install pip. If you need assistance, see this posting.

Procedures
Upgrade pywinrm to 0.2.2. 

 » Read more..

How Do You Boot To CD/DVD-ROM (or USB stick) on an HP Laptop one time?

Question:  How Do You Boot To CD/DVD-ROM on an HP Laptop one time (e.g., to reformat it)?

Answer:

  1. Turn off the laptop.
  2. Turn on the laptop, and when it is booting up, press Escape.
  3. Then choose option “F11” for System Recovery.
  4. You’ll see a screen for “Choose an option.”
  5. Select “Use a Device.”
  6. Then select “Internal CD/DVD-ROM Drive (UEFI)” (or the USB stick option).

 » Read more..