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.




Saturday, May 12, 2018

8 bit nostalgia itch.



Today, I started to dig out my Nintendo games again.  My favorite cart label design is Baseball.  I don't think there is a better artwork on a Nintendo game out there.  Gameplay for Baseball is little to be desired as this was one of the original releases and developers hadn't learn to use the complete capabilities of the NES at that point.  The graphics looks very pixelated even for 8 bit standard compared to games later in the NES' life.  Even so, I like to take this out and play it once in a while.  I am trying to collect all these black box games (I think there are around 30?) and its taken a while to find for a good price.  I've got half of them so far.  Below is what I'm missing.  Any one interested in trading, drop me a note.  


-Clu Clu Land
-Donkey Kong Arcade Classic Series
-Donkey Kong 3
-Donkey Kong Jr.
-Donkey Kong Jr. Math
-Gumshoe
-Ice Climber
-Pinball
-Slalom
-Soccer
-Popeye
-Stack-Up
-Urban Champion
-Volleyball
-Wrecking Crew