<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Haus &#187; Uncategorized</title>
	<atom:link href="http://techha.us/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://techha.us</link>
	<description>House of Tech</description>
	<lastBuildDate>Tue, 28 Sep 2010 14:14:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PowerCLI Quick One-liner: List VMs, Current Datastore, and Total HD size</title>
		<link>http://techha.us/2010/09/powercli-quick-one-liner-list-vms-current-datastore-and-total-hd-size/</link>
		<comments>http://techha.us/2010/09/powercli-quick-one-liner-list-vms-current-datastore-and-total-hd-size/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 14:14:50 +0000</pubDate>
		<dc:creator>pezhore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://techha.us/2010/09/powercli-quick-one-liner-list-vms-current-datastore-and-total-hd-size/</guid>
		<description><![CDATA[I wrote this quick one-liner when I was tasked to perform an audit of our VMs in a specified cluster to determine if they could be moved to a different LUN. The current setup, although functional, doesn’t truly utilize our Clarion’s two types of drives effectively (SATA, SCSI). This script is just the first step [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this quick one-liner when I was tasked to perform an audit of our VMs in a specified cluster to determine if they could be moved to a different LUN. The current setup, although functional, doesn’t truly utilize our Clarion’s two types of drives effectively (SATA, SCSI). This script is just the first step in our plan to reclaim the various LUNs and implement a more cost-effective layout.</p>
<p>Note that this may not be a true one-liner as it requires a few variables that I have stored in my profile:</p>
<h3>Code</h3>
<p><font face="Consolas" color="#c0c0c0">[<font color="#00ff00">vSphere PowerCLI</font>] D:\&gt; $HDPrimarySize = @{       <br />&gt;&gt;&#160;&#160;&#160;&#160; Name = &quot;Primary HD Size (GB)&quot;       <br />&gt;&gt;&#160;&#160;&#160;&#160; Expression = { $_.HardDisks[0].CapacityKB / 1MB }       <br />&gt;&gt; }       <br />&gt;&gt; $HDSecondarySize = @{       <br />&gt;&gt;&#160;&#160;&#160;&#160; Name = &quot;Secondary HD Size(GB)&quot;       <br />&gt;&gt;&#160;&#160;&#160;&#160; Expression = { $_.HardDisks[1].CapacityKB / 1MB }       <br />&gt;&gt; }       <br />&gt;&gt; $TotalHD = @{       <br />&gt;&gt;&#160;&#160;&#160;&#160; Name = &quot;Total HD Capacity&quot;       <br />&gt;&gt;&#160;&#160;&#160;&#160; Expression = { ($_.HardDisks[1].CapacityKB / 1MB) + ($_.HardDisks[0].CapacityKB / 1MB)}       <br />&gt;&gt; }       <br />&gt;&gt;</font></p>
<p><font face="Consolas" color="#c0c0c0">[<font color="#00ff00">vSphere PowerCLI</font>] D:\&gt; get-cluster MyCluster | get-vm | select Name, @{N=”Datastore”;E={Get-Datastore –VM $_}},$TotalHD | sort Datastore | Export-CSV vms.csv</font></p>
]]></content:encoded>
			<wfw:commentRss>http://techha.us/2010/09/powercli-quick-one-liner-list-vms-current-datastore-and-total-hd-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unity + vmware-unity-helper = Parallels for Ubuntu</title>
		<link>http://techha.us/2010/08/unity-vmware-unity-helper-parallels-for-ubuntu/</link>
		<comments>http://techha.us/2010/08/unity-vmware-unity-helper-parallels-for-ubuntu/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 15:32:22 +0000</pubDate>
		<dc:creator>pezhore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://techha.us/2010/08/unity-vmware-unity-helper-parallels-for-ubuntu/</guid>
		<description><![CDATA[Technorati Tags: VMware,Unity,Ubntu A friend of mine has parallels for OSX on his macbook. It is fairly cool – having a Windows-only program appear to be running natively in OSX. With parallels, there’s no need to dual boot – just use your favorite OS (OSX) and your favorite windows apps seamlessly. This enabled my co-worker [...]]]></description>
			<content:encoded><![CDATA[<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:41852dee-b736-4189-9518-f87c33987dc4" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/VMware" rel="tag">VMware</a>,<a href="http://technorati.com/tags/Unity" rel="tag">Unity</a>,<a href="http://technorati.com/tags/Ubntu" rel="tag">Ubntu</a></div>
<p>A friend of mine has parallels for OSX on his macbook. It is fairly cool – having a Windows-only program appear to be running natively in OSX. With parallels, there’s no need to dual boot – just use your favorite OS (OSX) and your favorite windows apps seamlessly. This enabled my co-worker to open up VMware’s vSphere Infrastructure Client from within OSX – something that normally takes a ton of configuration and hacking to accomplish.</p>
<p>I was a little jealous that my Ubuntu 10.04 LTS couldn’t do the same… or could it?</p>
<p>I recently passed my VMware Certified Professional 4 exam and as part of the congratulatory package from VMware, I received a copy of VMware Workstation 7 for free. I choose the Linux flavor because that’s what I prefer to use as my primary OS. I fired up a VM of XP, and started tinkering around when I came upon the Unity feature. For supported VMs with VMware tools installed, Unity will allow you to interact with the guest OS/programs as if they were native to the host. Behold!</p>
<p><a href="http://techha.us/wp-content/uploads/2010/08/Screenshot.png"><img title="Screenshot" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="139" alt="Screenshot" src="http://techha.us/wp-content/uploads/2010/08/Screenshot_thumb.png" width="244" border="0" /></a> </p>
<p>(That’s the XP system information window sitting on top of a Linux console running top, on top of the Windows Live Writer program)</p>
<p>Unfortunately, to get to this point, I had to manually start the XP VM, then wait for VMware tools to start up before I was able to manually click the Unity button. It’s a boring, repetitive process – so like most things, I decided to see if I could script it somehow.</p>
<h1>Enter vmware-unity-helper</h1>
<p>I came upon the vmware-unity-helper tool somewhere in the VMware Communities. The question was asked, “How can I get a VM to automatically start with my OS” and the unity helper tool was mentioned in passing. A bit of Googling later and I had my answer.</p>
<p><font face="Courier" color="#ffffff" size="2">vmware-unity-helper &#8211;run /path/to/vmx-file/vm.vmx &quot;c://path//to//program.exe&quot;</font></p>
<p>This command will attempt to run the specified program in the VM specified by the vmx configuration file. If the VM isn’t running, it will automatically start it, and when VMware tools starts up, the program is run.</p>
<p>To make my life a little easier, I created a <strong>very</strong> simple bash script that would run the vSphere client.</p>
<p><a href="http://techha.us/wp-content/uploads/2010/08/Screenshot1.png"><img title="Screenshot1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="246" alt="Screenshot1" src="http://techha.us/wp-content/uploads/2010/08/Screenshot1_thumb.png" width="496" border="0" /></a></p>
<p>After marking the script as executable, I can now run it and have the Infrastructure Client running “natively” in Ubuntu!</p>
<p><a href="http://techha.us/wp-content/uploads/2010/08/Screenshot11.png"><img title="Screenshot-1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="Screenshot-1" src="http://techha.us/wp-content/uploads/2010/08/Screenshot1_thumb1.png" width="323" border="0" /></a></p>
</p>
<p>The only downside is that I can’t seem to fully maximize the windows… they seem to only maximize to the top portion of the screen. It may be related to guest resolution, but I’m not certain. For now, manually resizing is sufficient for my needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://techha.us/2010/08/unity-vmware-unity-helper-parallels-for-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sudo for Powershell</title>
		<link>http://techha.us/2010/05/sudo-for-powershell/</link>
		<comments>http://techha.us/2010/05/sudo-for-powershell/#comments</comments>
		<pubDate>Tue, 25 May 2010 16:51:21 +0000</pubDate>
		<dc:creator>pezhore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://techha.us/?p=129</guid>
		<description><![CDATA[Today I discovered I had written a script that required admin rights (restarting a Windows service). I began looking into options for the Linux equivalent of sudo and came upon these two pages: Link 1, Link 2. Both describe simplified ways of trying to launch an app from an elevated account (notepad, powershell, etc). However, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I discovered I had written a script that required admin rights (restarting a Windows service). I began looking into options for the Linux equivalent of sudo and came upon these two pages: <a title="Link 1" href="http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell" target="_blank">Link 1</a>, <a title="Link 2" href="http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for-powershell-sorta" target="_blank">Link 2</a>. Both describe simplified ways of trying to launch an app from an elevated account (notepad, powershell, etc). However, there were a few things missing. First, if I want to run an elevated powershell script I had to run</p>
<pre>sudo powershell</pre>
<p>, then once in the elevated prompt, cd to the directory and run the script</p>
<pre>.\services.ps1</pre>
<p>This obviously isn&#8217;t ideal &#8211; and the one source had a few mistakes with how the actual passed file was called (it didn&#8217;t deal well with the &#8220;.\&#8221; portion of a passed script.</p>
<p>I made some changes, added comments, and updated to allow for powershell scripts to be run with a simple flag &#8220;-ps&#8221;</p>
<p>Here&#8217;s the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">## sudo.ps1</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Authors: pezhore, mrigns, This guy: http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell,</span>
<span style="color: #008000;">#             other powershell peoples</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Sources:</span>
<span style="color: #008000;">#       http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell</span>
<span style="color: #008000;">#       http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for-powershell-sorta</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Version:</span>
<span style="color: #008000;">#       1.0     Initial version</span>
<span style="color: #008000;">#       1.1     added -ps flag, cleaned up passed $file/$script full path</span>
<span style="color: #008000;">#       1.2     Comments</span>
<span style="color: #008000;">#       1.3     Fixed passing working directory to powershell/auto closing</span>
&nbsp;
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span>
        <span style="color: #000000;">&#91;</span><span style="color: #0000FF;">switch</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ps</span><span style="color: pink;">,</span>               <span style="color: #008000;"># Switch for running args as powershell script</span>
        <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$file</span><span style="color: pink;">,</span>             <span style="color: #008000;"># Script/Program to run</span>
        <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$arguments</span> <span style="color: pink;">=</span> <span style="color: #000080;">$args</span> <span style="color: #008000;"># Arguments to program/script</span>
     <span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008000;"># Find our powershell full path</span>
<span style="color: #800080;">$powershell</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-command</span> powershell<span style="color: #000000;">&#41;</span>.definition
&nbsp;
<span style="color: #008000;"># Get current directory</span>
<span style="color: #800080;">$dir</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">get-location</span>
&nbsp;
<span style="color: #008000;">#If we're running this as a elevated powershell script</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$ps</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #008000;"># Script verification</span>
        <span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::Exists<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;$(get-location)\$file&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
                <span style="color: #008000;"># Set the $script to full path of the ps script</span>
                <span style="color: #800080;">$script</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-childitem</span> <span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span>.fullname
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;"># Create a powershell process</span>
        <span style="color: #800080;">$psi</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> System.Diagnostics.ProcessStartInfo <span style="color: #800080;">$powershell</span>
&nbsp;
        <span style="color: #800080;">$psi</span>.WorkingDirectory <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Location</span>
&nbsp;
        <span style="color: #008000;"># Combine the script and its arguments</span>
        <span style="color: #800080;">$sArgs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$script</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$arguments</span>
&nbsp;
        <span style="color: #008000;"># Set the arguments to be the ps script and it's arguments</span>
        <span style="color: #800080;">$psi</span>.Arguments <span style="color: pink;">=</span> <span style="color: #800000;">&quot;-noexit -command set-location $dir; $sArgs&quot;</span>
&nbsp;
        <span style="color: #008000;"># Magic to run as elevated</span>
        <span style="color: #800080;">$psi</span>.Verb <span style="color: pink;">=</span> <span style="color: #800000;">&quot;runas&quot;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># We're running something other than a powershells script</span>
<span style="color: #0000FF;">else</span> <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #008000;"># File verification</span>
        <span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::Exists<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;$(get-location)\$file&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
                <span style="color: #008000;"># Get full path</span>
                <span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-childitem</span> <span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span>.fullname
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;"># Same as above, create proccess/working directory/arguments/runas</span>
        <span style="color: #800080;">$psi</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> System.Diagnostics.ProcessStartInfo <span style="color: #800080;">$file</span>
        <span style="color: #800080;">$psi</span>.Arguments <span style="color: pink;">=</span> <span style="color: #800080;">$arguments</span>
        <span style="color: #800080;">$psi</span>.Verb <span style="color: pink;">=</span> <span style="color: #800000;">&quot;runas&quot;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Start the process</span>
<span style="color: #000000;">&#91;</span>System.Diagnostics.Process<span style="color: #000000;">&#93;</span>::Start<span style="color: #000000;">&#40;</span><span style="color: #800080;">$psi</span><span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

<p>I added an alias in my profile and sudo was born:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">New-Alias</span> <span style="color: #008080; font-style: italic;">-name</span> sudo <span style="color: #800000;">'d:\git-code\Powershell\ps_misc\sudo.ps1'</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://techha.us/2010/05/sudo-for-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun thing of today: Powershell and VMware &#8211; Part 1</title>
		<link>http://techha.us/2010/05/fun-thing-of-today-powershell-and-vmware-part-1/</link>
		<comments>http://techha.us/2010/05/fun-thing-of-today-powershell-and-vmware-part-1/#comments</comments>
		<pubDate>Wed, 19 May 2010 15:15:33 +0000</pubDate>
		<dc:creator>pezhore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://techha.us/?p=119</guid>
		<description><![CDATA[Today&#8217;s fun thing: utilizing powershell to test stuff in VMware. There are a few cool things I have been able to piece together with Powershell and VMware -hopefully some of those will make it into a brief series. I wrote two scripts to help with testing the various VLANs that were necessary for our VMs. [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s fun thing: utilizing powershell to test stuff in VMware. There are a few cool things I have been able to piece together with Powershell and VMware -hopefully some of those will make it into a brief series.</p>
<div>I wrote two scripts to help with testing the various VLANs that were necessary for our VMs. (Really less scripts and more basic functions)</div>
<h2>Function 1: PowerCLI</h2>
<pre><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-weight: normal; line-height: 18px; font-size: 12px; white-space: pre;">$vm = get-vm testVM
$VLANs = "3","5","08","09","11","18","22","35","59","106","112","201","202","222"
foreach ($vlan in $VLANs){
     $vm |Get-NetworkAdapter|Set-NetworkAdapter -networkname "VLAN $vlan" -Confirm:$false
     write-host "Press any key to continue..."
     $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}</span></pre>
<h2>Function 2: Testing VM</h2>
<pre>$VLANs = "3","5","08","09","11","18","22","35","59","106","112","201","202","222"
foreach ($vlan in $VLANS) {
     .\set-StaticIP.ps1 -ip 10.10.$vlan.254 -gtw 10.1.$vlan.254
     start-sleep 5
     $ping = new-object System.Net.NetworkInformation.Ping
     $rslt = $ping.send("10.10.3.3")
     if ($rslt.status.tostring() -eq "Success"){
          write-host "Vlan $vlan tested ok"
     }
     else {​
          write-host "Vlan $vlan ping test failed"
     }
     write-host "Press any key to continue..."
     $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}</pre>
<h2>Script 1: set-StaticIP.ps1</h2>
<pre>param(  [string]$ip,
     [string]$mask = "255.255.255.0",
     [string]$gtw = "192.168.1.254",
     [string]$dns1 = "192.168.1.1",
     [st​ring]$dns2
     )
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq "TRUE"}
Foreach($NIC in $NICs) {
     if ($ip){
          $no = $NIC.EnableStatic($ip, $mask)
     }
     $no = $NIC.SetGateways($gtw)
     if($dns2){
          $dns ="$dns1,$dns2"
     }
     $no = $NIC.SetDNSServerSearchOrder($dns)
     $no = $NIC.SetDynamicDNSRegistration("FALSE")
}</pre>
<h2>Explanation</h2>
<div id="_mcePaste">Function1 is started first using PowerCLI (after connecting to the appropriate ESX host). It configures the specified VM&#8217;s network adapter to be on the first VLAN, then pauses. After the vmnic is configured properly, Function2 is run on the testVM in powershell. This utilizes the set-StaticIP.ps1 script and configures the IP address to match the specified VLAN, then attempts a ping against MSIDI001 (This machine should be pingable from all the testing VLANS. If the ping is successful, it is indicated that the VLAN tested ok, if not, the failure is stated. After the result is noted, any key is pressed in PowerCLI to set the vmnic to the next VLAN. After it has been configured, any key is pressed in Fuction2 to set the new IP for testVM (the ping test then takes place on this new VLAN). This is repeated until all VLANs have been tested.</div>
<div>This is much quicker than manually assigning IPs or setting VLAN membership in VMware&#8217;s Infrastructure Client.</div>
]]></content:encoded>
			<wfw:commentRss>http://techha.us/2010/05/fun-thing-of-today-powershell-and-vmware-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

