Sunday, January 26, 2014

WinPE 5.0 Portable Apps and my PowerShell Utility Menu

www.portableapps.com is awesome.  I found most of my apps on their site.  Here is a list of apps that work in WinPE:

Dropboxahk
Irfanview
Firefox
Chrome (version 24.0.1312.57)
EvincePDF
DiffPDF
SumatraPDF
Recuva
7Zip
XeonFileMgr
WiseDataRecovery
TreeSize
Clam Antivirus
Putty
FileZilla FTP
GIMP Image Editor
SoftPerfect File Recovery

I also copied timeout.exe from Windows to WinPE since I don't like PowerShell's start-sleep command -- it has no visual countdown.

Here's the PowerShell script I used for my Utility Menu:
Note: The menu spacing is funky as it's made to be presented inside the WinPE boot shell.

Function Utility
{
cls
write-Host "`n                                 UTILITY MENU`n" -fore White
Write-Host "`n              1"-f cyan -nonewline;write-host ":7Zip  "-f gray -nonewline;write-host "2" -f cyan -nonewline;write-host ":Chrome  "-f gray -nonewline;write-host "3"-f cyan -nonewline;write-host ":Firefox  "-f gray -nonewline;write-host "4"-f cyan -nonewline;write-host ":ClamWin Antivirus" -f gray
Write-Host "`n              5"-f cyan -nonewline;write-host ":Photo Viewer  "-f gray -nonewline;write-host "6"-f cyan -nonewline;write-host ":Wise File Recovery  "-f gray -nonewline;write-host "7" -f cyan -nonewline;write-host ":Recuva File Recovery" -f gray
Write-Host "`n              8"-f cyan -nonewline;write-host ":FileZilla FTP  "-f gray -nonewline;write-host "13" -f cyan -nonewline;write-host ":PuTTY Telnet  "-f gray -nonewline;write-host "9"-f cyan -nonewline;write-host ":GIMP Photo Viewer" -f gray
Write-Host "`n              10"-f cyan -nonewline;write-host ":PDF Viewer  " -f gray -nonewline;write-host "11" -f cyan -nonewline;write-host ":2nd PDF Viewer  "-f gray -nonewline;write-host "12" -f cyan -nonewline;write-host ":PDF Comparer" -f gray
Write-Host "`n              14"-f cyan -nonewline;write-host ":Folder Sizes  "-f gray -nonewline;write-host "15"-f cyan -nonewline;write-host ":File Manager  " -f gray -nonewline;write-host "16" -f cyan -nonewline;write-host ":SoftPerfect File Recovery" -f gray
Write-Host "`n              C"-f cyan -nonewline;write-host ":Open Command Window  "-nonewline;write-host "P" -f cyan -nonewline;write-host ":Open PowerShell Window  " -nonewline;write-host "N"-f cyan -nonewline;write-host ":Notepad"
Write-Host "`n              U"-f cyan -nonewline;write-host ":Update this UFD's scripts "-nonewline;write-host "B"-f cyan -nonewline;write-host ":Reload HD Boot Sector"
Write-Host "`n              NEW"-f cyan -nonewline;write-host ":Create Image from SysPrepped HDD"
write-host "`n              A"-f cyan -nonewline;write-host ":Apply custom role to existing image`n"
#Write-Host "`n              Enter"-f cyan -nonewline;write-host ": Return to Main Menu`n" -fore darkcyan

$util = read-host 'Select utility or press ENTER for Main Menu' 
if ($util -eq "1"){d:\apps\7Zip\7-ZipPortable.exe;Utility}
if ($util -eq "2"){d:\apps\Chrome\GoogleChromePortable.exe;Utility}
if ($util -eq "3"){d:\apps\firefox\firefoxportable.exe;Utility}
if ($util -eq "4"){d:\apps\ClamAV\ClamWinPortable.exe;Utility}
if ($util -eq "5"){d:\apps\Irfanview\IrfanViewPortable.exe;Utility}
if ($util -eq "6"){d:\apps\DataRecovery\WiseDataRecoveryPortable.exe;Utility}
if ($util -eq "7"){d:\apps\Recuva\Recuva.exe;Utility}
if ($util -eq "8"){d:\apps\FileZilla\FileZillaPortable.exe;Utility}
if ($util -eq "9"){d:\apps\GIMP\GIMPPortable.exe;Utility}
if ($util -eq "10"){d:\apps\evincepdf\evinceportable.exe;Utility}
if ($util -eq "11"){d:\apps\sumatrapdf\sumatraPDFportable.exe;Utility}
if ($util -eq "12"){d:\apps\diffpdf\diffpdfportable.exe;Utility}
if ($util -eq "13"){d:\apps\Putty\PuttyPortable.exe;Utility}
if ($util -eq "14"){d:\apps\TreeSize\TreeSizeFreePortable.exe;Utility}
if ($util -eq "15"){d:\apps\XenonFileMgr\XenonPortable.exe;Utility}
if ($util -eq "16"){d:\apps\file_recovery.exe;Utility}
if ($util -eq "C"){cmd /c start;Utility}
if ($util -eq "P"){cmd /c start PowerShell;Utility}
if ($util -eq "N"){Notepad.exe;Utility}
if ($util -eq "NEW"){Imaging;pause;utility}
if ($util -eq "A"){Scripts;copy d:\role.txt ($hdwin + ":\software\role.txt")}
if ($util -eq "U"){UpdateUFD;Utility}
if ($util -eq "B"){if (test-path e:\windows\system32\bcdboot.exe){e:\windows\system32\bcdboot.exe e:\windows;d:\apps\timeout 15;Utility}else{write-warning "Windows Boot Files Not Found";pause;Utility}}
}

UFD Imaging and Dell Driver Cabs

One trick I found while creating Windows sysprep images is to make the core image as neutral as possible so there's no conflicts when installing on various vendor hardware.  As such, after applying an image to a new computer, I copy over the appropriate hardware drivers to the new C:\Drivers folder.  Since I use PowerShell to install the images, the command I use to detect the hardware is:

if (gwmi win32_computersystem|?{$_.model -like '*Latitude E6430*'}){robocopy d:\drivers\E6430 n:\drivers /e}

This is after I've already performed the registry update so the new image can detect drivers at the c:\drivers location:

1. Open Regedit
2. Browse to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
3. Locate DevicePath and edit it to be: c:\drivers;%SystemRoot%\inf
4. Continue with sysprep and create the image

I use Dell computers most of the time and found this location to be wonderful:
It has all the driver cabs.  Simply extract the cab into a folder and use the contents for the new computer.

HP has a similar site:


PowerShell and Dropbox to provide updated URL to ROSS and I-Suite Downloads

I've created a UFD-based fire computer image and will be sharing with other CTSP's in our upcoming meeting.  My goal was to create a UFD that can be updated with the most current script fixes and URL updates.  As such, I decided to use Dropbox for hosting the scripts and links.  I used PowerShell to pull the information from Dropbox and update the scripts.

Here's an example:
When WinPE boots, the UFD is the D: drive.  I also create a ROSS and I-Suite root subfolder on the clients.  The problem I've found is when getting dispatched to a fire, there isn't much time to get I-Suite and ROSS before heading out.  I wrote two simple scripts that rely on my Dropbox URL's to get the most current version of ROSS and I-Suite then save them to either the c:\ross/c:\isuite or d:\ross/d:\isuite folders.

Double click on ROSSUpdater.bat:
powershell -executionpolicy unrestricted .\rossdownloader.ps1

It starts ROSSDownloader.ps1:
#This first command looks for c:\ross and d:\ross then assigns $filename appropriately
if (test-path c:\ross){
$filename = ("c:\ross\" + (get-date -format "yy.MM.dd") + ".ROSS.EXE")}else{
if (test-path d:\ross){$filename = ("d:\ross\" + (get-date -format "yy.MM.dd") + ".ROSS.EXE")}}

#if neither folder exist then sends a message and exits
if ((!(test-path c:\ross)) -and (!(test-path d:\ross))){write-warning "There is no ROSS subfolder off the root of your UFD or C: drive";pause;exit}

#Sends warning message about the download
write-warning "Closing this window will cancel the ROSS download"
write-warning "The new ROSS executable is located in the UFD's ROSS folder"
write-host ("The new ROSS file is: " + $filename)-f green

#grab the Dropbox file URL to ROSS, assign it to a variable then #download the file to the $filename folder
$ross = (new-object system.net.webclient).downloadstring("https://dl.dropboxusercontent.com/s/pz22mvi15sjp2y8/ross.txt")
(new-object system.net.webclient).downloadfile($ross,$filename)

#Check to ensure the file downloaded then send a message
if (test-path $filename){write-host "Download Complete"-f blue;timeout 30}else{write-warning "Something went wrong, download was not successful.";pause}

This technique is dependent on keeping up with the ROSS/ISuite URL's in Dropbox but changing it in one place will help all those who use this script.

Idea: Create an SMS Text Messaging webpage for team website

www.textsendr.com offers free SMS texting from their site.  They also have an option to create a widget.  You fill out the form with the recipients phone number and service provider and it generates a code snippet. I've modified a code snippet it generated for me.  My idea is to create a contact page on our local intranet server (Windows 7 Enterprise hosted-IIS) which is on the I-Suite server.  Those who want to share their phone information will get their own snippet and others in camp will be able to text them from any network computer or smart phone that can access the Internet team site.

<center>
<form action="http://www.textsendr.com/send.php" method="POST" target="_blank">
<input type=hidden name=refer value=widget>
<input type=hidden name=to value=xxxxxxxxxxxxxxxx>
<input type=hidden name=provider value=sprint>
<textarea name=message rows=3 cols=20></textarea><br>
Provide your name, role, contact information, and message.<br>
Recipient can't reply directly to your message.<br>
<input type=submit value="Send to George">
</form>
</center>

Update: After revisiting textsendr.com, I noticed all they do is wrap your text message into an email and send it via the companies text-to-email account.  Knowing this now, I'm going to create a different type of webpage that bypasses having to visit their site after every message.  I'll update this blog after creating the alternative code snippet.

ACS Alaska[phone number]@msg.acsalaska.com
Alltel[phone number]@message.alltel.com
Ameritech[phone number]@paging.acswireless.com
Arch[phone number]@archwireless.net
AT&T[phone number]@txt.att.net
Bell Canada[phone number]@txt.bellmobility.ca
Blue Sky Frog[phone number]@blueskyfrog.com
Boost[phone number]@myboostmobile.com
Carolina West[phone number]@cwwsms.com
Cellular One[phone number]@mobile.celloneusa.com
Cellular South[phone number]@csouth1.com
Cincinnati Bell[phone number]@gocbw.com
Cingular[phone number]@mobile.mycingular.com
Cingular Blue[phone number]@mmode.com
Claro[phone number]@clarotorpedo.com.br
Comviq[phone number]@sms.comviq.se
Cricket[phone number]@mms.mycricket.com
Edge[phone number]@sms.edgewireless.com
Einstein PCS[phone number]@einsteinsms.com
Fido[phone number]@fido.ca
Immix[phone number]@immixmail.com
Metro PCS[phone number]@mymetropcs.com
Mobile One[phone number]@m1.com.sg
MTN Africa[phone number]@sms.co.za
Nextel[phone number]@messaging.nextel.com
Ntelos[phone number]@pcs.ntelos.com
Optus[phone number]@optusmobile.com.au
Orange[phone number]@orange.net
Orange Poland[phone number]@orange.pl
Plus Poland[phone number]@text.plusgsm.pl
Qwest[phone number]@qwestmp.com
Rogers[phone number]@pcs.rogers.com
Sasktel[phone number]@pcs.sasktelmobility.com
Smart[phone number]@mysmart.mymobile.ph
Smart Telecom[phone number]@mysmart.mymobile.ph
Southern Linc[phone number]@page.southernlinc.com
Sprint[phone number]@messaging.sprintpcs.com
SunCom[phone number]@tms.suncom.com
Sure West[phone number]@mobile.surewest.com
SwissCom[phone number]@bluewin.ch
T Mobile[phone number]@tmomail.net
T Mobile (Ger)[phone number]@T-D1-SMS.de
T Mobile UK[phone number]@t-mobile.uk.net
TBayTel[phone number]@tbayteltxt.net
Telenor[phone number]@mobilpost.no
Telus[phone number]@msg.telus.com
Tim[phone number]@timnet.com
Unicel[phone number]@utext.com
V Mobile CA[phone number]@vmobile.ca
Verizon[phone number]@vtext.com
Virgin Mobile[phone number]@vmobl.com
Vodacom Africa[phone number]@voda.co.za
Vodafone[phone number]@vodafone.net
Vodafone Italy[phone number]@sms.vodafone.it
WellCom[phone number]@sms.welcome2well.com

Thursday, August 22, 2013

Building an in-camp Information Website

I noticed that initial information is sparse when camp is being setup.  I decided to turn on the IIS services on the I-Suite server and host a local website catered for team mobile phone users.  As long as they're in range of our secure local Wi-Fi network signal, they can get pertinent information about the fire.  I've started with the various office phone numbers, current fire situation, GIS maps, and links to fire photos.  This will be expanded as units add their input.  I've also added a QR code for folks to directly.  Here is a portion of the default.htm:

<!DOCTYPE html>
<html>
<head>
<style>
body {width:100%;}
h2 {text-align:center;}
p {text-align:center;}
table {}
td {padding:3px}

</style>
</head>
<center><body>
<h2>Fire Information</h2>
<p><b>Section Telephone Numbers</b></p>
<table>
<tr><td>IC / Liaison</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr>
<tr><td>Information</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Finance/Cost/PIO</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Time/Procurement</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Situation/FBAN/GIS/CTSP</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Demob/Resources/Check-in</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Communications</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Ordering</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Human Resources</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>Helibase</td><td><a href="tel:18005555555">(800) 555-5555</a></td></tr></p>
<tr><td>FAX</td><td>(800) 555-5555</td></tr></p>
</table>

<p><b>Maps</b></p>
<p><a href="/maps/landscape.pdf">Landscape</a></p>
<p><a href="/maps/roadclosure.pdf">Road Closure</a></p>
<p><a href="/maps/transportation.pdf">Transporation</a></p>
<p><h3><a href="/Photos/index.htm"><b>Photos</b></a></h3></p>
<p><a href="http://www.inciweb.org/"><img width=100 src="/images/inciweb.gif"></a><a href="http://www.nwcg.gov/""><img width=100 src="/images/nwcg.jpg"></a>
<p><a href="http://thunderstorm.vaisala.com/explorer.html" title="Lightning"><img width=100 src="/images/lightning.jpg"></a><a href="http://www.nifc.gov/"><img width=100 src="/images/nifc.gif"></a><a href="http://activefiremaps.fs.fed.us/lg_fire2.php" title="Active Fire Maps"><img width=100 src="/images/activefire.jpg"></a>
<p><a href="http://www.nwccweb.us/information/firemap.aspx" title="NW Interagency Coordination Center"><img src="/images/nwcc.jpg"></a><a href="http://www.nifc.gov/nicc/sitreprt.pdf" title="NIFC Situation Report">NIFC SitRep</a><a href="http://gacc.nifc.gov/"><img src="/images/
</body></center>
</html>

To make it easy for posting pictures, I created a PowerShell script that takes existing photos and makes thumbnails of them then outputs an index.htm file.  Here is the script:

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing.Imaging") 

del c:\inetpub\wwwroot\photos\thumbnails\*.*
$photos = gci c:\inetpub\wwwroot\photos\*.jpg
$index = write "<center><a href='/'>Return to Fire Information Page</a><br>"

foreach ($p in $photos){
$orig = $p
$origdir = $orig.directoryname
$origext = $orig.extension
$origbase = $orig.basename
$outfile = write ($origdir + "\thumbnails\" + $origbase + "_thumb" + $origext)

$picture = new-object system.drawing.bitmap $orig.fullname
$newwidth = [math]::round($picture.width * .10)
$newheight = [math]::round($picture.height * .10)

$thumb = $picture.getthumbnailimage($newwidth,$newheight,$null,[intptr]::zero)
$thumb.save($outfile)
}

$thumbs = gci c:\inetpub\wwwroot\photos\thumbnails\*.jpg

foreach ($t in $thumbs){
$tn = $t.name
$tnn = $t.name.replace('_thumb','')
$index += write "<a href='/photos/$tnn'><img src='/photos/thumbnails/$tn'></a><br>"`n
}
$index|out-file c:\inetpub\wwwroot\photos\index.htm

Now staff can dump photos into the c:\inetpub\wwwroot\photos folder and I can use the script to replace outdated thumbnails with the current photos.  Doing this simplifies the process and gives more time to continue putting the network together while also hosting a time-saving website which helps new fire staff.

Wednesday, August 21, 2013

3G to Windows XP Internet Connection Sharing PC to Network Solution

8/21/13 - The Verizon emergency team was able to create a mobile Internet solution for us but our current Cradlepoint MBR-1200 router was unable to connect to the service.  This was my solution:

  1. Obtain Verizon provided Android smartphone with HotSpot abilities.
  2. Create secured HotSpot for exclusive use by Windows XP laptop.
  3. Establish wireless connection between Windows XP laptop and HotSpot.
    1. HotSpot assigned 192.168.1.200, 255.255.255.0, 192.168.1.1 to wireless card
  4. Connect Windows XP wired network card to ISP port of router
  5. Program router pointing its gateway to the wired NIC's address
    1. Wired NIC's address was 192.168.0.1
    2. ISP router port address 192.168.0.2 with DNS 192.168.0.1, 192.168.1.1
  6. Establish Windows XP Internet Connection Sharing on the wireless card.  You'll see a sharing hand icon on the wireless cards NIC when finished.  Leave the firewall on as it's also the ICS service too.
  7. Test the connection with network laptop by pinging a website not on the workstations local DNS table.
Things to note:
The shared connection relies on both NIC's to constantly work together.  Anything can cause them to stop pairing.  Ensure to checkbox "Show icon in notification area when connected" on both NIC's so you can keep an eye on them.  If they become unteamed, restart the "Windows Firewall/Internet Connection Sharing" service.

Disable power saving settings on laptop so connection doesn't shutdown when the laptop goes to sleep.

Create a task to stop/start ICS service  (net stop sharedaccess  and net start sharedaccess)
I made a batch file with those two commands in it and had it run every hour.  It's quick and doesn't cause a hiccup if the connection is already working but fixes it if the connection is bad.

Tasks:

Please provide input about stuff I've missed.

NFES 1337 - Unit Log providing high overview of major events, agreements, delays and diagram of supported areas.  Create and give to Documentation.

Inventory - Create full inventory and give to Documentation

ROSS Imports - perform several imports at beginning of fire.  Every hour or so and less frequently as resource orders slow down.

Upload Finance Accrual and Data Repository to isuite.nwcg.gov 

Have Plans Chief sign daily Crew Time Report and turn in to Time

Complete Emergency Equipment Shift Ticket for "LAN" van - fill in 5 days at a time