DDNS without DDNS: The PowerShell Edition

I've been meaning to do this for a while. My Wife needs tech support at home while I am at work every once in a while, but it is often something that I need to see to help her with. However, I don't afford the convenience of a static IP address from my ISP, so I am usually unable to connect to her computer remotely. Hence, the need to know what my public address is.

Now I know that anyone lured into this blog post by the title will be asking, "Colin, why not use a DDNS provider?", and the answer would be, "Because I don't want to!". It's a lot easier to justify spent time on technology to your wife than it is to justify spent money. ;)

So, the code:

#$F = File
#$U = Username
#$P = Password
#$B = Browser
#$C = Credentials
#$E = Email Address
#$I = IP Address
#$S = SMTP Server

function Store-myPass
$global:U = $args[0]
$global:F = $args[1]
$Credential = Get-Credential $U
$credential.Password | ConvertFrom-SecureString | Set-Content $F

function Get-myCred
$U = $args[0]
$F = $args[1]
$P = Get-Content $F | ConvertTo-SecureString
$C = New-Object System.Management.Automation.PsCredential($U,$P)

function Send-IP
$U = $args[0]
$F = $args[1]
$C = get-myCred $U $F
$url = "http://www.whatismyip.com/automation/n09230945.asp"
$browser = New-Object Net.Webclient
$S = "smtp.gmail.com"
$E = $U + "@gmail.com"
$I = $browser.DownloadString($url)
Send-MailMessage -to $E -from $E -Subject $I -Credential $C -SmtpServer $S -UseSsl

$Uv1 = $args[0]
$Setup = $args[1]

if ($args[0] -eq $null){
Write-Host ""
Write-Host ""
Write-Host -ForegroundColor Yellow "Welcome to Send-IP2Gmail Usage Instructions!"
Write-Host ""
Write-Host ""
Write-Host -ForegroundColor Yellow "Running this cmdlet without specifying a username will bring you to this message."
Write-Host -ForegroundColor Yellow 'For initial configuration, or to change your password, use the "setup" command:'
Write-Host ""
Write-Host -ForegroundColor Red ".\Send-IP2Gmail davidcolinsmith setup"
Write-Host ""
Write-Host ""
Write-Host -ForegroundColor Yellow "After this command is run, your password is securely hashed in a file in the "
Write-Host -ForegroundColor Yellow 'C:\creds\ folder. Subsequent use of this command without the "setup"'
Write-Host -ForegroundColor Yellow "feature can be schedule or scripted using this syntax:"
Write-Host ""
Write-Host -ForegroundColor Red ".\Send-IP2Gmail davidcolinsmith"
Write-Host ""

if ($Setup -eq "setup")
$U = $Uv1
$Result = test-path -path "c:\creds"
if (!(test-path -path "c:\creds"))
new-item c:\creds -type directory
$credspath = "c:\creds\" + $U + ".txt"
if (!(test-path -path $credspath))
new-item $credspath -type file
Write-Host "Send your Public DHCP-assigned IP address to your gMail account"
[environment]::SetEnvironmentVariable("Send-IP-Username", $U, "User")
$global:F = "c:\creds\" + $U + ".txt"
[environment]::SetEnvironmentVariable("Send-IP-CredPath", $F, "User")
Store-myPass $U $F
Write-Host "Send your Public DHCP-assigned IP address to your gMail account"
[environment]::SetEnvironmentVariable("Send-IP-Username", $U, "User")
$global:F = "c:\creds\" + $U + ".txt"
[environment]::SetEnvironmentVariable("Send-IP-CredPath", $F, "User")
Store-myPass $U $F
else {
$U = get-childitem env:send-ip-username
$F = get-childitem env:Send-IP-CredPath
$U = $U.value
$F = $F.value
Send-IP $U $F

Comments, questions, concerns, or suggestions are welcome!


Week 3, Day 1

So it's been a bit of a rough last couple of days for me. I had a sick family and a large amount of homework due over the weekend, in addition to studying for the Cisco BCSI test that I took yesterday. Instead of waking up an hour early to exercise, I've slept in the last two days. I am committing to exercise tonight after the kids go to bed. I'll scale today's CrossFit workout, as follows:

4 laps around the block
20 pound dumbell thruster, 21 reps
21 Pull-ups
2 laps around the block
20 pound dumbell thruster, 15 reps
15 Pull-ups
1 lap around the block
20 pound dumbell thruster, 9 reps
9 Pull-ups

I only have 40 pounds of weights right now, hence the 20 pound thrusters. My gym membership should be coming in any day now, and I am looking forward to seeing how I can fit CrossFit exercises into a "normal" gym.


Week 2, Day 2

This morning's exercise went really well! I had planned to perform three sets last night, but realized that I was pretty beat after the first two. I was reading a couple of Crossfit Journal editions (May 2003 and June 2005), and I am convinced that it is just as important to not push myself too hard now as it will be later.

Today's exercises - 2 sets of:

100 jump-rope
20 push presses (each hand)
20 air squats

The jump-rope is getting better, I just need to do more of it! I got through 70 jumps before tripping my second round. Also, I had Erin check my form on the squats last night, and my first set today felt right. The second fell apart, though. Gotta get into shape!


Week 2, Day 1

It was nice to take a break this last weekend, and to spend some time enjoying nature with the family while camping at Alva Lake in Montana. We got back on Monday, and I slept in on Tuesday morning, as I did not get much sleep while camping. I was energized by the beauty of nature and the enjoyment of spending good health with family and friends, and I come back to work and home with a renewed desire to be strong for life.

Today's workout - 2 sets of:

20 bar dips
20 push-ups
10 pull-ups
20 air squats

There are a few exercises in there that I cannot get very high reps on. I really struggled through my second set of push-ups, where I can normally nail out 40-50 without much trouble. I think that I need to ease up on difficulty and focus on attaining higher-rep workouts. Also, I am planning on getting some running in there!

Found a great document of countless bodyweight exercises here (post #33). I am going to try some of these over the next weeks and months.


Day 4

This morning, I had a hard time getting motivated to go downstairs and kill it. I think that my lack of enough sleep last night contributed to my sluggishness, but I also think that my failure to plan today's workout before I went to bed last night was a bad idea. Fail to plan, plan to fail - I'll be more committed to intentionality from here on out. Anyway, here was the workout:

3 sets of:
90 yd. bear crawl
20 reduced-load pull-ups

The first set today was maybe a little easier than it should have been. Because I didn't plan the workout the night before, I was a little easier on myself than I could have been. Maybe I should have thrown in something to work the quads a little. However, after the third set I was just about ready to puke. Had I done a fourth set, I might have.

Tomorrow is a rest day, and we are leaving early to go camping in MT, but I'm still going to knock out 30 push-ups every stop that we make.


Day 3

This morning's workout:

2:00/1:30/1:00/0:30 back-to-back intervals of jump-rope and crunches

Without breaks, this would take 10 minutes flat. I had 15 or 30 seconds between each interval, so it took a little longer. It was nice to set a goal and get all of the way through the workout. I will be working towards the same time intervals with double-under jump-rope and full-range sit-ups, but for now, I'm happy with my accomplishment.

I am feeling moderately sore just about everywhere today. Not so sore that I would think that I pushed myself too hard, just sore enough that I know the exercise is making a difference.

No ideas yet what I'll do tomorrow, may try sets of bear crawls or crab walks for duration.


Day 2

I woke up this morning less sore than I had expected, but still dreading getting out of bed because that meant I had to go exercise. I hadn't decided what I was going to do this morning, but as I stretched out and warmed up, I decided on three sets of:

20 bar dips
10 hindu push-ups
30 cone hops

Got through the first set without too much trouble, but when I got to 4th rep in the second set of hindu push-ups, I ran out of chest. Tried to finish the set with standard push-ups, but I literally collapsed. Cone hops on the second set were finished out just fine, though I'm sure that my form was terrible, and I stopped there.

In retrospect, I should have pushed into the third set, but I didn't. I'm riding a fine line between pushing myself hard and being able to exercise tomorrow.

On the plate for tomorrow, modified from Monday's CrossFit.com WOD:

Jump rope for 2 minutes
Sit-up for 2 minutes
Jump rope for 90 seconds
Sit-up for 90 seconds
Jump rope for 1-minute
Sit-up for 1-minute
Jump rope for 30 seconds
Sit-up for 30 seconds

Not sure if I should be doing cardio as well, but this is enough to start, for sure!


Another Beginning

I started something new today. Up at 6 am, stumbled downstairs and tried to get through five sets of the following.

20 chin-ups
30 push-ups
40 sit-ups
50 squats

Finished the first set in 4 minutes, finished the second in another 9 minutes, never started the third.

All in all, a good beginning. :)


"It's been a long time since I've done anything musically creative - I seem to find great joy in the creativity that ones and zeros bring me these days. But it _does_ make me happy to sing again, and to be heard. This track (attached below) was just a little 2-hour burst of creativity. I know that it'll never be a career, but I know just as well that it will ALWAYS be a hobby, and a joy."

Little Song