Monthly Archives: May 2014

Install HyperV or another feature using installshield

I am using installshield 2013, but this may apply to other versions.

My goal was to be able install the hyperV feature on a windows 2012 server using installshield.

First you follow the directions at http://helpnet.flexerasoftware.com/installshield20helplib/Content/helplibrary/CAPowerShell.htm

Add the property IS_PS_EXECUTIONPOLICY and set it to Unrestricted

InstallShield IS_PS_EXECUTIONPOLICY

Add a Predefined System Search to check for powershell

InstallShield Add System Search

Installshield system search powershell

Create a new custom action. I am using a powershell from a binary table

InstallShield Add custom action

I am being lazy so the script I am running is on my desktop
Add Install Exec Sequence: After InstallFinalize
Add Install Exec Condition: POWERSHELLVERSION

InstallShield PowerShell custom Action

Now comes the magic,
Installshield runs using 32 bit mode by default, which means it also runs the 32bit powershell verison, From what I can tell the 32bit version of PowerShell doesn’t implement a bunch of stuff, so you either have to convert your installshield project to strict 64bit or put some magic at the top of you Powershell script to switch it to 64bit

To set your installshield project to strict 64bit (see https://www.youtube.com/watch?v=yfOFvsfjSeA)

set the template x64; 1033
Installshield 64bit template

then you must tell the release to be strict about using 64bit components only

InstallShield Release Strict

The other option is to use the magic from http://www.nivot.org/blog/post/2012/12/18/Ensuring-a-PowerShell-script-will-always-run-in-a-64-bit-shell. I choose to use the magic at the top of my power shell since I may have to install 32 bit components as part of my installer, so I didn’t want to be restricted to only installing 64bit components.

# am I running in 32 bit shell?
if ($pshome -like "*syswow64*") {
    write-warning "Restarting script under 64 bit powershell"

    # relaunch this script under 64 bit shell
    # if you want powershell 2.0, add -version 2 *before* -file parameter
    & (join-path ($pshome -replace "syswow64", "sysnative") powershell.exe) -file `
        (join-path $psscriptroot $myinvocation.mycommand) @args

    # exit 32 bit script
    exit
}

# start of script for 64 bit powershell

 whoami | Add-Content -Path c:\file.txt
 echo "check admin" | Add-Content -Path c:\file.txt
 $64bit = [Environment]::Is64BitProcess

 ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
        [Security.Principal.WindowsBuiltInRole] "Administrator") | Add-Content -Path c:\file.txt

Add-Content -Path c:\file.txt -Value (’64-bit process = ‘ + $64bit);
echo "check feature" | Add-Content -Path c:\file.txt
Get-WindowsFeature | Where-Object {$_.Name -eq "Hyper-V"}  | Add-Content -Path c:\file.txt
$check = Get-WindowsFeature | Where-Object {$_.Name -eq "Hyper-V"}
If ($check.Installed -ne "True") {
        echo "notInstalled" | Add-Content -Path c:\file.txt
        #Install/Enable SNMP Services
        #Add-WindowsFeature SNMP-Services | Out-Null
        echo $check.Installed | Add-Content -Path c:\file.txt
        echo "Do Install" | Add-Content -Path c:\file.txt
        Install-WindowsFeature –Name Hyper-V -IncludeManagementTools -whatif | Out-File -Append c:\file.txt
}
else {
  echo "Installed" | Add-Content -Path c:\file.txt
}

Please excuse the c:\file.txt, those were my way of debugging to see what was going on.

I still need to work on handling the required reboot, but that is tomorrows problem

Start Microsoft Remote Desktop Session from command line on mac

You need to have at least 8.0.6 installed.

Start a command prompt

open "rdp://full address=s:10.10.10.10:3389&screen mode id=i:1&Desktopheight=i:1024&Desktopwidth=i:1280"

I am still trying to workout how to pass a username with a domain, when I put in &username=s:localhost\administrator it appears in the login box as

localhost%5Cadministrator

For a full list of commands that should work see http://technet.microsoft.com/en-us/library/dn690096.aspx

Centos/RHEL stops looking for a dhcp ip

I managed to mess up my vm network a few times and the centos machines lost there DHCP address, what surprised me was that they stopped requesting an IP address, so once I fixed my KVM test machine I would have to connect to the console restart the network

I found a website http://www.cyberciti.biz/faq/rhel-centos-configure-persistent-dhcp-client/ that mentions a setting

PERSISTENT_DHCLIENT=1

That you can set in the /etc/sysconfig/network-scripts/ifcfg-eth0

So
Edit the file

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

Append line PERSISTENT_DHCLIENT=1, at the end configuration should look as follows:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
PERSISTENT_DHCLIENT=1

Save and close the file. Restart networking service or reboot laptop / desktop to test the changes:

# /etc/init.d/networking restart