Friday, 19 August 2016

ASCII art with Powershell

$colors = [System.ConsoleColor]::GetValues([System.ConsoleColor]); 1..100 | % { $var= ($_ %= $colors.Length ); Write-Host $var.ToString().PadRight($var * 10, '*') -ForegroundColor $colors[$var] -BackgroundColor $colors[$var -1 ] }

image

Tuesday, 2 August 2016

Extract file version from all machines on network using powershell

cls
$computers = (Get-ADComputer -Filter "Name -like 'WDUKLON*'" | select -ExpandProperty Name)

$ErrorActionPreference = 'SilentlyContinue'

$computers | % {
    $computername = $_;
    $dllfile = (get-childitem "\\$computername\c$\Program Files (x86)\RRA\Beacon\RRA.Beacon.Recruiter.Business.dll" -ErrorAction SilentlyContinue);
    $fileversion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllfile).FileVersion;
    If (!$fileversion.ToString().StartsWith("4") ) {"{0}`t{1}" -f $computername, $fileversion.ToString()}
    }

N.B. RSA pack will need installing on win 7 machine https://www.microsoft.com/en-gb/download/details.aspx?id=7887

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...