How Do You Install Sikulix on a Windows Server?

Problem scenario
You want to leverage the power of image recognition and automation without an expensive license for software that has no API exposed.  In other words you want a free version of Robotic Process Automation software on your Windows server.   What do you do?

Solution
Prerequisites
Install Java version 8.  If you do not know how, see this posting.  We tested these directions on a Windows 2016 Server with 2 vCPUs and 4 GB of RAM.  The performance was fine.

Procedures
1.a.  If you are not using I.E., go to step #2.  If you have the recommended I.E. browser settings, you will need to do the following substeps.

1.b. Open I.E.  If you are prompted, you may want to accept the recommended settings.

1.c.  Go to the gear icon in the upper righthand corner.  Go to "Internet Options."

1.d.  Go to Security tab and then click on "Trusted Sites."

1.e.  Click on the "Sites" button.

1.f.  Enter this text with no quotes "https://launchpadlibrarian.net" and click "Add".  

2.  Download this file:  https://launchpad.net/sikuli/sikulix/1.1.1/+download/sikulixsetup-1.1.1.jar

3.  Create a folder called "Sikulix" in C:\.

4.  Transfer the downloaded .jar file to c:\Sikulix\

5.  Double click the .jar file

6.  Click "Yes" to the first window.

7.  Unless you have a reason to change the default settings, check the box for "Pack1".

8.  Click "Setup Now."

9.  To the question about "The following file(s) will be downloaded..." click "Yes".

10.  To the prompt about Jython version2 2.7.0, choose "Yes".

11.  To the last window that says "Have fun!" click "Ok".

12.  Now to open Sikulix, double click the "runsikulix" (Windows Command Script) in C:\Sikulix.  (You may want to remove the Trusted Site you added in I.E. if you did step #1.)

Remember
Sikulix is straight-forward and intuitive to use after it has been installed. If you use a web browser with your Skiluix automated sequences, be aware of one thing.  Some web browsers have an "auto-fill" or suggestion feature.  The browser may dynamically and quickly display text  that could interfere with picture recognition.  You may want to add a step in Sikulix to click into another field that is not affected or obfuscated by the suggested text to make such text disappear for the next step in the Sikulix program to execute without a problem.  This dropping-down text will usually disappear if an irrelevant text field is clicked on.

If you want step-by-step directions on how to use Sikulix as an example for the first time, see this posting.

In Windows How Do You Search the Contents of Files in a Folder and Recursively the Files in the Folder’s Subdirectories for a Specific Pattern?

Problem scenario
You want to find an .html, .txt, or .rtf file that has the pattern "cool" in it.  You do not need to search for .doc or .docx files. How do you write a PowerShell command to search the contents of files and subdirectories of a given folder to see if they have a text string that matches the word "cool"?

Solution
Run these two commands:

cd c:\to\the\folder\you\want\

Get-ChildItem -recurse | Select-String -pattern "cool"

How Do You Install npm on a CentOS/RedHat/Fedora Server?

Problem scenario
You enter the command "npm -v" but get an error about the command not being found or recognized.  How do you install npm on a RedHat derivative Linux server?

Solution
(You may want to see these directions instead if you want to use a script that will work on any distribution of Linux (including RHEL, Debian or SUSE distributions).  These other directions may also be of interest to you.) 

Run these two commands:

sudo su -
yum -y install npm nodejs epel-release

How Do You Install Puppet Master on a Linux SUSE Server (an AWS Instance)?

Problem scenario
You want to install Puppet Master on SUSE 12.x running in AWS.  You only have five minutes to complete this task.  How do you install Puppet Master immediately?

Solution
1.  Create this file: /etc/zypp/repos.d/puppet.repo

2.  The content of the above file should be the following:

[systemsmanagement_puppet]
name=A network tool for managing many disparate systems (SLE_12)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/systemsmanagement:/puppet/SLE_12/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/systemsmanagement:/puppet/SLE_12/repodata/rep0md.xml.key
enabled=1

3. As root, run this command: zypper install puppetmaster

You'll get this prompt:  "Do you want to reject the key, trust temporarily, or trust always? [r/t/a/? shows all options] (r): "

Respond with "t" and press "Enter."

You'll then get this prompt:  
"Overall download size: 4.9 MiB. Already cached: 0 B. After the operation, additional 9.8 MiB will be used."

Respond with "y" and press "Enter."

4.  Start it like this:  puppet master start

How Do You Install Vagrant on an AWS Instance of SUSE?

Problem scenario
You are using a Linux SUSE server in AWS.  You want to install Vagrant. What do you do?

Solution
Run these commands:
cd /tmp
sudo curl https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm > vagrant_1.8.1_x86_64.rpm 

sudo zypper -n install vagrant_1.8.1_x86_64.rpm
To verify the installation, run this command: vagrant version

How Do You Use JEA (Just Enough Administration) to Give Users the Rights to Perform Select PowerShell Tasks?

Problem scenario
You want to empower non-administrator users to perform a subset of Windows administrator-level functions.  Specifically you want to give a user with limited privileges the ability to check the local software firewall rules.  This user needs to validate if they are configured appropriately.  This user account will otherwise have limited privileges.  You want to adhere to the recommended practice of least privileges.  You want to use JEA (Just Enough Administration) to enhance the user's privileges.  What do you do to give a limited scope of privileges to a user without elevating them to Windows server administrators?

Solution

Prerequisuites
This assumes you have a local user with limited privileges including the ability to log in remotely.  If you do not know how to create a local user with limited privileges see this posting.  If you do not know how to give the user access to log in remotely see this posting.

Procedures
Steps 1 through 3 are optional.  Doing them will help you see what JEA does. 

1.  Start a PowerShell session with this user (e.g., from another server on the same workgroup or domain).  It could be from the same server when you are logged in as an administrator.  Run a command like this, but replace "coolhn" with the server name and replace "jane" with the local username:

$pss = New-PSSession -ConfigurationName Microsoft.PowerShell -ConnectionUri http://coolhn:5985/wsman -Credential jane

2.  Run this command:  Enter-PSsession $pss

3.  Try out some commands to prove the limited access:  show-netfirewallrule
# You should see access is denied.  If you do not, the user is not limited.  You may not need JEA for this user.

4.  Now set up JEA.  Open a PowerShell Window as an Administrator.  Run these commands (remember you can replace "sample" with a word of your choice as long as you are consistent):

cd c:\
mkdir tempb
mkdir .\tempb\transcript
cd tempb
New-PSRoleCapabilityFile -Path c:\tempb\sample.psrc


5.  Modify the file above (c:\tempb\sample.psrc) in the following way. Underneath the stanza with "# VisibleCmdlets"
place this single line:
VisibleCmdlets = 'Show-NetFirewallRule', 'Get-EventLog', 'Write-EventLog'
# Save the this file with a new name.  Back up the original to a different name too.  

6.  Change the modified version with back to the original name; in this case the file would be called sample.psrc.  We suggest using a PowerShell command if Notepad and Windows inadvertently associated the new file with a .txt extension. Here is an example:
mv samplenew.psrc.txt sample.psrc

7.  Run this command: New-PSSessionConfigurationFile -Path c:\tempb\sample.pssc -Full

8.a.  Open c:\tempb\sample.pssc (the file created above).  Make the following changes:
8.b. Insert this stanza underneath the commented out "# TranscriptDirectory" line:
TranscriptDirectory = 'C:\tempb\transcript\'

8.c.*  Insert a line like this underneath the commented out "# RoleDefinitions " line:
RoleDefinitions = @{'coolhn\jane' = @{ VisibleCmdlets = 'Show-NetFirewallRule', 'Get-EventLog', 'Write-EventLog' }}

# Do not include this comment about the line above.  Do change "coolhn" to the hostname of your server. Change "jane" to the desired username.

8.d.  Uncomment the phrase "RunAsVirtualAccount = $true" by removing the "#". Remove the leading space before the letter "R".
8.e. The stanza "SessionType = " should be changed. Set it to "RestrictedRemoteServer".  It should look like this:
SessionType = 'RestrictedRemoteServer'

8.f. Save it as a new name.  Back up the original file to a different name so the file with the original name is no longer in the directory.  

8.g.  Change the modified version of the file back to the original name now that no file with that name is in the directory; in this case the file would be called sample.pssc.  We suggest using a PowerShell command if Notepad and Windows inadvertently associated the new file with a .txt extension.  Here is an example:
mv samplenew.pssc.txt sample.pssc

8.h.  Run this command:
Register-PSSessionConfiguration -Name sample -Path 'C:\tempb\sample.pssc'

8.i.  Run this command:  Restart-Service WinRM

8.j.  Run this command but replace "coolhn" with the hostname of your server and "jane" with the username with limited privileges:

Enter-PSSession -ComputerName coolhn -ConfigurationName sample -Credential jane

# Enter the password to the "jane" user.

8.k.  Ignore the error pop-up about "Failed to refresh.  'The term 'Get-Module' is not recognized..."  Just click "OK".

8.l.  Use this command as a test (to compare it to step #3):  show-netfirewallrule
You are done. 

How Do You Troubleshoot Weebly Blog Editor Not Updating Posts after You Make Changes to Them?

Problem scenario
You are using Weebly website editor. You make changes to a post, then click "Update."  You then click "Publish."  But the changes to your website are not updating.  What do you do?

Solution
Log out of the Weebly editor.  Close all of the instances of the web browser you were using.  Then reopen the web browser.  Clear the cache, history and cookies.  Now the problem should be gone.  Go back into the Weebly website editor and update your website as normal.

How Do You Troubleshoot the Error “VpcLimitExceeded” When Running an Ansible Playbook in AWS?

Problem scenario
You are running an Ansible playbook in AWS, and you get this message:

TASK [metron-test:  Create virtual private cloud] ******************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "VpcLimitExceeded: The maximum number of VPCs has been reached."}
        to retry, use: --limit @/usr/bin/metron/metron-deployment/amazon-ec2/playbook.retry

Solution
You must have an AWS account with a special maximum of VPCs.  The default number of VPCs one can create is five according to AWS documentation.  While we know you can create more than five without a special request, we have found this limit to be enforced on occasion.  

If you are willing to take the risk of being billed for numerous EC-2 servers, we recommend you go to this link and request your account have a new limit of VPCs in west-2.  If you are trying to deploy Apache Metron, you will want need 10 EC-2 instances for a typical configuration.  If you want the region to support servers beyond this purpose, you may need a limit value greater than 10.  

​The form should be filled out like this:

This request may take a 30 minutes or so.  Depending on various factors (e.g., how busy Amazon is and time for the changes to take effect), the time you wait will vary.

How Do You Connect to a Specific Database in Postgres Using PHP?

Problem scenario
Using PHP you want to connect to a specific database to run SQL queries.  How do you do this?

Solution
Assuming you have installed PHP and Postgres on the same Ubuntu Linux server, install the php-pgsql package.  Follow this link if you need assistance.  

1.  Create a file like this named contint.php:

<?php
   $host        = "host=127.0.0.1";
   $port        = "port=5432";
   $dbname      = "dbname=contintdb";
   $credentials = 'user=jdoe password=abcd1234';

   $db = pg_connect( "$host $port $dbname $credentials"  );

   pg_query("insert into contintTable values(511);");
?>

2.  Change the $dbname variable assignment in the code below.  This is how you specify a database. You will need to change the credentials and the pg_query code too. Change the IP address if the Postgres server is on a different server from the server with PHP.

​3.  Run it with this command: php contint.php