Dism

For reference only
change commands to suit your needs.

1. Boot with WinPE 5.0
2. Follow normal diskpart procedures to prepare/configure Hard disk.
3. At the command prompt:
DISM /mount-wim /wimfile:[Path to eduSTAR Image] /index:1 /MountDir:[Path of folder created]
* may need /ReadOnly
DISM /unmount-wim /MountDir:[Path to mounted directory] /commit
4.

DISM /Apply-image /Imagefile:[Path to image on usb] /index:1 /ApplyDir:C:\


ex: dism /Apply-image /Imagefile:d\win8.wim /index:1 /ApplyDir:C:\
5.

DISM /Apply-image /Imagefile:[Path to image on usb] /index:2 /ApplyDir:D:\


6. remove all media, reboot.
===Confirmed: After diskpart, skip step 3, then do step 4/5 to apply image.===
If after rebooted, and there is error about OS not found.
boot into WinPE5.0 again, in cmd:> bcdboot C:\Windows
Reboot again.

Diskpart

This is for reference only:
* Change commands to suit your needs.
diskpart /s f:\diskpart.txt
Or manually:

> diskpart
> list disk
> select disk 0 (usually 0, which is the disk you want to image)
> clean
> list volume
> select volume 1 (drive C)
> delete volume
> create partition primary (This is will the default size left, or you could specify ex: create partition primary size=80000
> list partition
> select partition 1 (The newly created partition)
> format fs=ntfs quick
> active
> assign letter=c
> exit


cd TechTools
> imagex /apply source:\C.wim 1 C:

Works on Excel files with Powershell

Here is a powershell script where it could "compare and update".
This particular powershell will look for the username and insert it from one file to the other.

* Adjust and use it in your own risk.


$strPath = "C:\s\library.csv"  # this is the main spreadsheet which we look for the username and update the password
$strPath2 = "C:\s\Year102016.csv" # this is the csv file which contains the username and password

$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $false

$workbook1 = $objExcel.Workbooks.Open($strPath)
$worksheet1 = $workbook1.sheets.item("library")
$intRowMax1 =  ($worksheet1.UsedRange.Rows).count

$workbook2 = $objExcel.Workbooks.Open($strPath2)
$worksheet2 = $workbook2.sheets.item("Year102016")
$intRowMax2 =  ($worksheet2.UsedRange.Rows).count


$colA = 1 # column contain the username
$colO = 15 # Where we need to insert the password

# 
#
Function checkAndAdd
{

        Param($username, $password)

        write-host "Second FOR Loop: " $intRow1 " Looking for username: " $username

        # Loop from Row 1 to the last Row
        for ($intRow1 = 1 ; $intRow1 -le $intRowMax1 ; $intRow1++) 
        {
            # read the username into $colA
            $colA = $worksheet1.cells.item($intRow1,1).value2 

            if ($colA -match $username)
            {
                Write-Host "Found username: " $username " insert password to column now."
                $worksheet1.cells.item($intRow1, $colO) = $password
                break
            } 
                
         } # ROW FOR LOOP
}



# READ the Year102016.csv row by row, pass in the Username, Password, to the other Excel file
# MAIN For Loop
#

Function ReadUsernamePassword
{ 
    # Loop from Row 2 to the last Row
    for ($intRow2 = 2; $intRow2 -le $intRowMax2 ; $intRow2++) 
    {
        # Make sure column 1 = username, column 8 = password
        $username = $worksheet2.cells.item($intRow2, 1).value2
        $password = $worksheet2.cells.item($intRow2, 8).value2

        
        write-host "MAIN For Loop: "$intRow2 " checking username: " $username " password: " $password 
        checkAndAdd $username $password

    } 
}    
#>


# Check 1 code only
# Beware the strPath file that you read/write to may need to change.

Function Check1Code
{
    Param($username, $password)
    checkAndAdd $username $password
}

## Uncomment this to Run Check1Code  
## 
## 
#
#Check1Code "abc1234" "password"

ReadUsernamePassword

      
$workbook1.SaveAs('C:\s\LibraryFINAL.csv') # output file 
$objexcel.quit()

Cisco 1262 WAP

Had to replace a dead WAP with this 1262 the other day, but the replacement had an automous config which need to be converted to lightweight for it to talk to WLC.

The WAP got an ip from DHCP which I needed to telnet to it later. (Otherwise would need a console cable)
Setup a tftp server (SolarWinds), which will serve the tar file.

Use putty, telnet to the WAP (u: cisco, p: Cisco)

ap> Enable
ap# archive download-sw tftp://<tftp-ip>/ap3g1-rcvk9w8-tar.124-23c.JA.tar
ap# wr mem
ap# reload

Windows activation with KMS and TMG2010

Our TMG2010 was deactivated for sometimes now. Eventhough tmg is still working, but it is annoying that it prompts you to activate everytime you login. (And the black background)

So I decided to deal with it, and it is quite easy to fix.

Basically you need to allow TCP port 1688 outbound to the KMS server.

Full article from Microsoft Support here.

 

How-to import certificates in Chromebook

in Chrome, chrome://settings/certificates
select -> Your Certificates tab -> "Import and Bind to Device" .pfx
select -> Authorities tab -> import (ex: Deet.cer)

In Chrome settings, under Internet Connection, Add Connection
Join wifi (Advanced), insert SSID and identity, and proxy details if needed.

Secure Password & Key with Powershell

To encrypt credential which works on different computer(s), you need to generate the key and the encrypted password file.

After you have both key and encrypted file, you could run powershell using that credential generated.

Here is the reference which I referred on.

Creating AES key with random data and export to file:

$KeyFile = "\\Machine1\SharedPath\AES.key"
$Key = New-Object Byte[] 16   # You can use 16, 24, or 32 for AES
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key)
$Key | out-file $KeyFile

Creating SecureString object

$PasswordFile = "\\Machine1\SharedPath\Password.txt"
$KeyFile = "\\Machine1\SharedPath\AES.key"
$Key = Get-Content $KeyFile
$Password = "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force
$Password | ConvertFrom-SecureString -key $Key | Out-File $PasswordFile

Creating PSCredential object

$User = "MyUserName"
$PasswordFile = "\\Machine1\SharedPath\Password.txt"
$KeyFile = "\\Machine1\SharedPath\AES.key"
$key = Get-Content $KeyFile
$MyCredential = New-Object -TypeName System.Management.Automation.PSCredential `
 -ArgumentList $User, (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)

Example of how to use PSCredential to map network drive:

New-PSDrive -Name P -PSProvider FileSystem -Root $UNC_PATH -Credential $MyCredential -Persist

* Keep the key file somewhere safe, because it is the key that could encrypt/decrypt the password file.