vlookup with powershell

I want to use the vlookup excel function within powershell and without data manipulation of the CSV itself. So I wrote a script to import a CSV, find some data and compare these data

$CSV = Import-Csv -Path C:\Users\user\some.csv

$trigger = $CSV| Where-Object {$_."Primary Description"  -like "some string with a computername"}
$result = $CSV| Where-Object {$_."Primary Description"  -like "another string with a computername"}

$triggerComputer = foreach ($i in $trigger) {($i."Primary Description" -split " ")[5]}
$resultComputer = foreach ($i in $result) {($i."Primary Description" -split " ")[5]}

Compare-Object $triggerComputer $resultComputer

Have fun!

Add Powershell 7 to your Powershell ISE

I find this code snippet somewhere on the internet and I like it 🙂

Swtich Powershell version in ISE

Just open ISE and paste these code and you are ready to rock!

$ErrorActionPreference= 'silentlycontinue'
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 7", { 
        function New-OutOfProcRunspace {
            param($ProcessId)
  
            $ConnInfo = New-Object -TypeName System.Management.Automation.Runspaces.NamedPipeConnectionInfo -ArgumentList @($ProcessId)
            $DefaultType = [System.Management.Automation.Runspaces.TypeTable]::LoadDefaultTypeFiles()
  
            $Runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($ConnInfo, $Host, $Default)
  
            $Runspace.Open()
            $Runspace
        }
  
        $PowerShell = Start-Process PWSH -ArgumentList @("-NoExit") -PassThru -WindowStyle Hidden
        $Runspace = New-OutOfProcRunspace -ProcessId $PowerShell.Id
        $Host.PushRunspace($Runspace)
}, "ALT+F5") | Out-Null
  
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 5", { 
    $Host.PopRunspace()
  
    $ChildProc = Get-CimInstance -ClassName win32_process | where {$_.ParentProcessId -eq $Pid}
    $ChildProc | ForEach-Object { Stop-Process -Id $_.ProcessId }
  
}, "ALT+F6") | Out-Null

Happy coding!

DHCP Test Tool

I had to check my DHCP configuration for a Dell Wyse Thin Client. But when you configure specific options like 161 and 162 you don’t see that options in a Wireshark capture during a Windows DHCP request.

Luckily for us CyberShadow created a great tool to test some specific DHCP settings an he even make it open source: https://github.com/CyberShadow/dhcptest

This DHCP tool have 2 great features:

  1. You can do a request for specific DHCP option
  2. You can send a vendor class so in my case I can pretend to be a Wyse Thin client.

DHCP Request Option

This will only work when you have configured Global DHCP settings.

dhcptest.exe --query --request 161

DHCP Vendor Class

First I had to figure what the vendor class was. I checked this on the DHCP server:

Or on a Thin client itself:

Then run this command:

dhcptest.exe --query --option "60=wyse-1000"

And you will get Vendor Specific Information in Hex.

You can do different things to translate the Hex into readable data.

  1. Compile the open source yourself yourself and create a output in a string
  2. Use a (online) hex convertor
  3. Open wireshark during the capture. Wireshark will translate this for you 🙂

Compile the tool

  • Download the git repo
git clone https://github.com/CyberShadow/dhcptest.git
  • Edit the file (add these 2 lines)
161 : DHCPOptionSpec("File Server", OptionFormat.str),
162 : DHCPOptionSpec("Root Path to the File Server", OptionFormat.str),
dmd dhcptest.d

This will create a exe for you and will translate the Hex to readable format.

Happy sniffing!

Regular Expressions Example

If you want to use regular expressions to know if some numerical value is higher then 199 use the following code:

^\d{1,2}$|^[1]\d\d$

Explanation:

^          = String begins with

\d         = numerical string (character 0-9)

{1,2}    = minimal 1 maximum 2 numerical characters

$          = end script

|           = OR (to bind 2 regular expressions)

^          = begins with

[1]        = first character = 1 (if you want to go till 299 it may be [1-2])

\d\d      = the next 2 character must be numerical strings

$          = end

For 399 the parameter can be:

^\d{1,2}$|^[1,2,3]\d\d$

or

^\d{1,2}$|^[1-3]\d\d$

Nice freeware regex tool: http://www.radsoftware.com.au/regexdesigner/

Lot of samples: http://www.regular-expressions.info/examples.html

Online test: http://www.regexplanet.com/simple/index.html

Very nice online test tool: https://regex101.com/

Hope this helps 🙂

Migrate my Joomla 1.0.15 to 1.5.x

Yes, I know… My Joomla site is very old. In this article I will write down all my migration steps. The best practise is to create a development environment. I download and install a Debian 5.0 (lenny) OS and installed all the common LAMP, SSH, Samba, PHPMyadmin & ImageMagick  packages. Then:

  1. I Copy the content of my site to my development environment
  2. Edit the joomla configuration.php file and change my physical paths
  3. Upload my database
  4. Check all my joomla modules
  5. set 777 permisions for easy testing 😉
  6. I know from earlier testing that mine Joomla template is not compatible with 1.5. So I download and install Artisteer 2 to create a new template. This software works so easy I created the template with my girlfriend 😉 (download torrent)
  7. My Biggest concern is the community builder component and the forum. This are the most important modules so I will upgrade them first.
  8. Backup administrator/components/com_comprofiler/ue_config.php, remove the CB module and reinstall the latest versions. (note: latest CB have 1.5.10 native support)
  9. My Fireboard version is aleady to the latest version (1.0.5 RC2) 😀
  10. Now I will install the migrator tools and follow the 5 migration steps @ http://docs.joomla.org/Migrating_from_1.0.x_to_1.5_Stable
  11. I have installed the migrator and the fireboard ETL’s. After that I create A SQL Dump. Now I must create a new 1.5 install and import everything.
  12. Note: You can now download your SQL dump file and upload it into your Joomla! 1.5 installation to continue the process. Don’t forget to select migration and use the prefix ‘jos_’ (this migrator rewrites your prefix to jos_ even if the sites prefix is different).
  13. I found a small community builder howto @ http://www.alledia.com/blog/joomla-15/migrating-to-joomla-15/
  14. * Step 1: Export the Community Builder database tables from 1.0
    * Step 2: Download administrator / components / com_profiler / ue_config.php
    * Step 3: Install CB on the 1.5 site:
    * Step 4: Delete the CBt database tables on 1.5 and import the old tables from 1.0
    * Step 5: Upload the old ue_config.php to administrator / components / com_profiler / ue_config.php
  15. For expose I can install the latest version. The copy the ../components/com_expose/expose/img and xml folders to the new site. That as very easy 🙂
  16. For the CB Profile pictures I copy images/comprofiler to the new site.
  17. .. to be continued

Template fix:

Extensions > Module manager > Top Menu (or any other menu, e.g. Main Menu) > click to Edit this module > select Position = user3. Save the configuration and go to the frontpage. You should see your Artisteer style applied to the menu items.

And first assign another default template and then your template

http://thepiratebay.org/torrent/5252382/Artisteer_2.3.0.23023___Crack_Loader___VirusFree___Working

Howto: Automaticly install printer and printer port

First create a port:

cscript %windir%\system32\prnport.vbs -a -s localhost -r IP_10.31.32.100 -h 10.31.32.100 -o raw -n 9100

Then create a printer:

rundll32 printui.dll,PrintUIEntry /if /b "Some Printer Name" /f C:\DEV\pcl5e_5c\P52KHAL.inf /r "IP_10.31.32.100" /m "Canon iR 3100C EUR PCL5c"

For more info try the /? commands