Thursday, August 30, 2018

APC UPS and Powerchute


Today, while trying to set up a static IP for a production UPS, I mistakenly powered off the UPS taking down a network switch that's running off of.  Normally, to configure an IP on a device, I would normally use a console/serial (here's where the confusion lies for me) cable.  I saw a port marked "Serial" and thinking that was the console port when in fact its a port to configure the Powerchute, which is a power down management software from APC that is in most of their UPS devices.  The issue lies in that serial port.  If anything but a Powerchute serial cable that is plugged into that port marked "Serial" on the UPS, once a unrecognized signal is sent to that serial port, Powerchute will shutdown the entire UPS along with the devices that's plugged into it.  Bad.  Why?  I don't know.

Took me about 10 mins to figure out what had happened and went to power the UPS back on.  There is a port labeled "Console" on the back of the UPS but I didn't think too much of it since there was just a little hole next to it.  The little hole is actually for the real console cable in the form of a 2.5mm jack.  I've never seen a console cable like that until now.

What could APC have done?  Well maybe rename the "Serial" port as "Serial for Powerchute" and maybe have some warning if plugging in a non-Powerchute serial will result in UPS shutdown if any unrecognize signal is passed to it.

I digress.  



Thursday, July 12, 2018

How to clear your variables in Powershell.


After running a Powershell command with a variable, the contents in that variable will stay in memory unless its cleared or overwritten to.  The command below is how to clear it from memory.  This helps when you're writing and testing a script to make sure you get accurate results and not results from stale memory in variables.

Remove-Variable * -ErrorAction SilentlyContinue

Power on a batch of VM's using Powershell


If you have a list of vm's and you need it to be powered on, the script below will help you do that.  To give the storage system air to breathe and not cause a boot storm, it powers on a VM every 2 seconds and waits 5 minutes after ever 50 VM is powered on.

Import-Module vmware.vimautomation.core
Remove-Variable * -ErrorAction SilentlyContinue
$vcenter = "hostname of vCenter or ESX host"
connect-viserver $vcenter
$count = 0
$csvfile = import-csv "Path to csv file"
foreach($vm in $csvfile)
{
    $vm_info = Get-VM -Name $vm.VMName   #VMName refers to column header in the  csv file.
    if ($vm_info.PowerState -eq "PoweredOff")
    {
        Write-Host "Powering on "$vm_info.Name
        $poweron = Get-VM $vm_info.Name | Start-VM -Confirm:$false
        Sleep 2             #power on a vm every 2 seconds.
        $count++
        if($count -eq 50)   #powers on 50 vm's then waits for 5 minutes for  storage to breathe.
        {
            Sleep 300
            $count = 0
        }
    }
}

Tuesday, July 10, 2018

Find a file in linux


To find a file in linux called "myfile", use the command below.
    [root@testbox /]# find / -name "myfile"


Tuesday, July 3, 2018

Power on a batch of virtual machines in a csv file using PowerCLI.

Use the following PowerCLI script to power on a list of Virtual Machines from a CSV file.

import-module vmware.vimautomation.core

$vcenter = <my vCenter server>
connect-viserver $vcenter
$allvms = import-csv RVTools_tabvInfo.csv

foreach ($strNewVMName in $allvms)
{   
        #gets all the VM's properties.  We're interested in the PowerState  Property.
        $vmdata = Get-view -ViewType VirtualMachine -Filter @{"name" =  $strNewVMName.vm}  #vm is the column header name in the csv on the first line.
        #if the PowerState is not PoweredOn, then power it on.
        if ($vmdata.Runtime.PowerState -ne "PoweredOn")
        {
            Write-Host "Powering on "$strNewVMName.vm
            Start-VM -VM $strNewVMName.vm
            Sleep 2
        }
}

Monday, July 2, 2018

Speed test on Google GCP instance.

Spun up a GCP instance today and ran a speed test.   No speed issues there.


Wednesday, June 20, 2018

Change IP from Windows command line using netsh.



Use the following command to change the ip of a network interface in Windows.

netsh interface ipv4 set address name="Ethernet0" static <new ip address> <subnet mask> <gateway>

Saturday, June 9, 2018

Change IP address using Powershell.


  1. Get-NetIPAddress
    1. get the InterfaceIndex number for the nic you want to change the IP address on.
  2. Remove-NetIPAddress -InterfaceIndex X
  3. New-NetIPAddress -InterfaceIndex X -IPAddress x.x.x.x -PrefixLength 23 -DefaultGateway x.x.x.x
  4. Set-DnsClientServerAddress -InterfaceIndex X -ServerAddresses  x.x.x.x, x.x.x.x

Thursday, June 7, 2018

Get regkey value on a batch of computers remotely.


Here's a Powershell script I created to get value in the registry on a batch of computers remotely.  Very handy if you have many computers to check.  Will output 'Offline' if the computer is turned off.

$strMachineName = Get-Content computer_name.txt
foreach ($line in $strMachineName)
{
    try{
            $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $line)
            $regkey = $reg.OpenSubkey("<registry path>")
            $serialkey = $regkey.GetValue("LicenseInformation")
            if ($serialkey -eq ""){
                  write-host $line
           }
     }
    catch{
                write-host $line ----- "Offline"
    }
}

Monday, May 14, 2018

Game Cataloging


With any type of collecting hobby, you need some way to catalog your collection.  I use CLZ games to catalog my games.  It's available as an Android/IOS app, and you can access via the web as well by hitting    .  It is extremely useful and it's one of only 3 apps I've bought on my phone.  The software doesn't limit itself to only games.  Another version of the app does movies, music and books cataloging as well.  Your items automatically get's sync'd to the cloud so you do not need to worry about backing up when switching phones.  It will automatically sync back all your data upon a new installation of the software.  You can add games by scanning the bar code of the box and if its in the CLZ's database, then it will add it with all the information about the game for you.  You can try it out for free.  I think you can add up to 50 items on the free version.