Showing posts with label Howto. Show all posts
Showing posts with label Howto. Show all posts

Friday, 22 April 2022

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 until midnight on the 22nd April 2022 :-

  Get-WinEvent -FilterHashtable @{logname='Security'; id=4624; StartTime="2022-04-21 12:00"; EndTime="2022-04-22 00:00"} -MaxEvents 5000 | Where-Object {($_.Message -like '*Logon Type: 10*')} | select -Property @{Name = 'Info'; Expression = {$_.Message.SubString($_.Message.LastIndexOf("Network Account Name:") -195,300)}},Id, TimeCreated, Message -First 10 | fl Id, TimeCreated, Info


Further to this, to find all the times a particular user has logged on to a machine, use the following query


Get-WinEvent -LogName 'Security' -FilterXPath 'Event[System[EventID=4624] and EventData[Data[@Name="TargetUserName"]="justusernamenodomain"]]' -MaxEvents 10 | fl id, timecreated


Alternatively you can edit the custom filter in the event log to look like this


<QueryList>

  <Query Id="0" Path="Security">

    <Select Path="Security">*[System[(EventID=4624) and TimeCreated[@SystemTime&gt;='2022-04-25T15:30:20.000Z' and @SystemTime&lt;='2022-04-25T16:30:20.999Z']]]

and *[EventData[Data[@Name="LogonType"]=10]]

</Select>

  </Query>

</QueryList>




Tuesday, 19 November 2019

How to Fix a Humax HDR FOX T2 PVR that will not stay powered on

Issue
When you attempt to power on your Humax the standby orange light goes blue for a moment, and then powers off automatically again.

Cause
The reason for this could be a bad boot sector on the hard disk.

Resolution
To fix this, remove the hard disk cable that connects to the mother board, power the machine on, then whilst it is showing your channel on the display, connect the hard disk cable back onto the motherboard. Then ftp to the machine using humaxftp / 0000 as the default username and password, and change directory (cd) to "my videos" and then list the contents of the directory using a dir command. After doing this you should be able to put the machine back into standby, and wait until you hear the hard disk spin down and stop, and then switch off at the wall and the back on again.





Note: There also appears to be a telnet command line interface to run disk repairs on the Humax but I wasn't able to get this working myself, and in the end did not need to do this.

Tuesday, 22 January 2019

How to retrieve a list of programs installed on Windows using PowerShell

Use the following powershell command

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Sort-object -Property DisplayName | Format-Table –AutoSize | Out-File \temp\myinstalls.txt

Friday, 9 February 2018

How to replace the watch battery in Logitech K750 solar power keyboard


  1. Buy this battery http://www.watchbattery.co.uk/shop/products/BB-ML2032.shtml
  2. Open the battery cover on the back of the keyboard, you’ll need a small screw driver to get the cover out
  3. Take out the old one and fit the new one
  4. Leave the keyboard in the light somewhere to fully charge up the new battery

Watch this video if you want to see this done…

https://www.youtube.com/watch?v=sKZXyUjytmE

image

Friday, 5 January 2018

How to fix blurry images in Google Chrome

Problem
When browsing sites with thumbnail images, those images appear blurred in Chrome, but not in other browsers such as Internet Explorer
Resolution
Uncheck the use hardware acceleration option in chrome settings.
  1. Open Chrome
  2. Navigate to chrome://settings
  3. Scroll to the bottom, and expand the Advanced options
  4. Near the bottom, uncheck the Use hardware acceleration when available option, and then click the RELAUNCH link that appears after you change this option.
image

Problem 2
When browsing google maps, image and text appears blurred in Chrome, but not in other browsers such as Internet Explorer
Resolution
  1. Open Chrome
  2. Navigate to http://maps.google.co.uk/maps 
  3. Press F12 to open Developer tools 
  4. Click on the Application Tab, and then select Clear Storage
  5. Check Local and session storage,  Cookies, Cache Storage and Application Cache
  6. Click Clear site data
  7. Relaunch Google Chrome

Friday, 15 September 2017

Inline Images not showing for Work Items in Visual Studio with 401 unauthorized error

To fix this, right click the broken image link from the Visual studio work item description pane, then copy the link from the properties dialog (it looks like a label, but you can select all on it by right mouse clicking).

image

Then simply copy and paste that into Internet Explorer bar, and when prompted enter your credentials.

Next, back in Visual Studio, just click the refresh work item button on the header of the work item window, and do this once for each in line image in the description.

Thursday, 31 August 2017

How to fix battery drain issue on Samsung Galaxy S5 G900F

DO NOT DO FACTORY RESET, just wipe cache partitions.

Turn off the device.
Press and hold the following three buttons at the same time: Volume Up key, Home key, and Power key.
When the phone vibrates, release the Power key but continue to press and hold the Volume Up key and the Home key.
When the Android System Recovery screen appears, release the Volume Up and Home keys.
Press the Volume Down key to highlight wipe cache partition.
Press the Power key to select.
When the wipe cache partition is complete, Reboot system now is highlighted.
Press the Power key to restart the device.


Thanks to  https://thedroidguy.com/2017/01/solutions-for-galaxy-s5-battery-drain-issue-1049822

Monday, 26 June 2017

Android mediaserver process killing battery life


If this happens to you, then do the following

  1. Force stop on Settings, Applications, All, Media Storage.
  2. Clear Cache and Clear Data, for the Media Storage application
  3. Unmount SD card
  4. Take out your sd card and put it in computer
  5. Find the LOST.DIR folder and delete it from the card
  6. Put the card back into the phone
  7. Reboot the phone
Got this from here...

Solution 1. Clear media storage data

The simplest solution is to clear media storage database and let it restart the process from scratch. Chances are this will fix most of the issues with Mediascanner/Mediaserver. Do the following, and it should help ease-out the pain:
Settings > applications > Media Storage > clear data, force stop and reboot.



Read more: http://geeknizer.com/fix-android-media-server-scanner-sdcard-cpu-battery-drain/#ixzz4lIDijXJ7



Friday, 19 May 2017

Megaflow draining instructions

If your megaflow overflow (d2) pipe starts leaking water then this is what you do…

image

Thursday, 23 February 2017

DELL 968 Printer problem–Cartridge slams against printer wall

Fix was as simple as removing the cartridges, then turing off the printer at the plug socket on the wall, then squeezing the drive belt and computer cables that connects to the cartridge compartment, with my finger and thumb a few times.

Many thanks to the forums for posting this fix here, has saved me the cost of a new printer …

http://en.community.dell.com/support-forums/desktop/f/3514/t/6603745

Wednesday, 4 January 2017

Edit.SelectToLastGoBack in Visual Studio

 

image

Very handy shortcut for this Ctrl + = in visual studio. Basically selects all the text between the last two navigation points you were looking at in a text file.

Friday, 4 November 2016

Powershell for finding hotfixes

One liner:

$Session = New-Object -ComObject Microsoft.Update.Session; $Searcher = $Session.CreateUpdateSearcher(); $HistoryCount = $Searcher.GetTotalHistoryCount();$Searcher.QueryHistory(0,$HistoryCount) | Sort-Object -Property Date -Descending | Select Title, Date | Export-Csv -Path c:\temp\hotfixlist.csv

More full version:


$wu = new-object -com “Microsoft.Update.Searcher”

$totalupdates = $wu.GetTotalHistoryCount()

$all = $wu.QueryHistory(0,$totalupdates)

# Define a new array to gather output
$OutputCollection=  @()
             
Foreach ($update in $all)
    {
    $string = $update.title

    $Regex = “KB\d*”
    $KB = $string | Select-String -Pattern $regex | Select-Object { $_.Matches }

     $output = New-Object -TypeName PSobject
     $output | add-member NoteProperty “HotFixID” -value $KB.‘ $_.Matches ‘.Value
     $output | add-member NoteProperty “Title” -value $string
     $OutputCollection += $output

    }

# Oupput the collection sorted and formatted:
$OutputCollection | Sort-Object HotFixID | Format-Table -AutoSize | Out-File c:\temp\output.txt

Further reading
https://github.com/tomarbuthnot/Get-MicrosoftUpdate

Thursday, 3 November 2016

How to configure the app pool recycle time from batch file


Stick the following in a configure_app_pool.bat batch file and run...


cls
@echo off

set last_five_chars_of_computername=%COMPUTERNAME:~-5%
echo.Running on %last_five_chars_of_computername%

SET recyle_time=01:55:00
IF "%last_five_chars_of_computername%" EQU "BAP01" SET recyle_time=01:55:00
IF "%last_five_chars_of_computername%" EQU "BAP02" SET recyle_time=01:56:00
IF "%last_five_chars_of_computername%" EQU "BAP03" SET recyle_time=01:57:00

REM CHOICE /C 123 /N /M "Enter 1 for bap01, 2 for bap02 or 3 for bap03, or press Ctrl+C to cancel"

REM SET answer=%ERRORLEVEL%
REM IF %answer% EQU 1 SET recyle_time=01:55:00
REM IF %answer% EQU 2 SET recyle_time=01:56:00
REM IF %answer% EQU 3 SET recyle_time=01:57:00

echo setting apppool recycle time to %recyle_time%

set recycle_period=1.05:00:00
echo setting apppool recycle period to %recycle_period%

setlocal


set servers=Beacon@RRA
set servers=%servers:@=,%

for %%a in (%servers%) do (
  FOR /F "delims=," %%i in ('%systemroot%\system32\inetsrv\appcmd list apppool /name:"$=*%%a*" /text:name') do (
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo         Setting up app pool: "%%i"                       
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call:setFunc "%%i"
)
)

goto :eos

:eos
endlocal
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo         Please verify above configuration changes      
echo         Then press any key to exit      
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pause
@echo on
goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:setFunc
echo.
echo ***** BEFORE ******
%systemroot%\system32\inetsrv\APPCMD list apppool /apppool.name:"%~1" /config
%systemroot%\system32\inetsrv\APPCMD set apppool /apppool.name:"%~1" /recycling.periodicRestart.time:%recycle_period%
%systemroot%\system32\inetsrv\APPCMD set apppool /apppool.name:"%~1" /+recycling.periodicRestart.schedule.[value='%recyle_time%']
%systemroot%\system32\inetsrv\APPCMD set config /section:applicationPools /[name='"%~1"'].recycling.logEventOnRecycle:Time,Schedule,Memory,IsapiUnhealthy,OnDemand,ConfigChange,PrivateMemory -commit:apphost
echo.
echo ***** AFTER ******
%systemroot%\system32\inetsrv\APPCMD list apppool /apppool.name:"%~1" /config

Friday, 2 September 2016

How to retrieve the logged on user of a remote machine in powershell

Note: For windows 7 desktop users you’ll need to install the active directory modules for powershell by following the installation steps here
https://www.microsoft.com/en-gb/download/details.aspx?id=7887

A better version could be to filter the process for explorer.exe

Get-WmiObject -class win32_process -Filter "name = 'Explorer.exe'" -ComputerName MACHINENAME -EA "Stop" | % {$_.GetOwner().User}

Or if you wish to resolve down to the actual full person's name

Get-WmiObject -class win32_process -Filter "name = 'Explorer.exe'" -ComputerName WDUKLON-0102 -EA "Stop" | % {Get-AdUser -Identity $_.GetOwner().User | Select -Property Name}

For all logged on users though, use the following script…

 https://gallery.technet.microsoft.com/scriptcenter/d46b1f3b-36a4-4a56-951b-e37815a2df0c
function Get-LoggedOnUser {
#Requires -Version 2.0           
[CmdletBinding()]           
Param            
   (                      
    [Parameter(Mandatory=$true,
               Position=0,                         
               ValueFromPipeline=$true,           
               ValueFromPipelineByPropertyName=$true)]           
    [String[]]$ComputerName
   )#End Param

Begin           
{           
Write-Host "`n Checking Users . . . "
$i = 0           
}#Begin         
Process           
{
    $ComputerName | Foreach-object {
    $Computer = $_
    try
        {
            $processinfo = @(Get-WmiObject -class win32_process -ComputerName $Computer -EA "Stop")
                if ($processinfo)
                {   
                    $processinfo | Foreach-Object {$_.GetOwner().User} |
                    Where-Object {$_ -ne "NETWORK SERVICE" -and $_ -ne "LOCAL SERVICE" -and $_ -ne "SYSTEM"} |
                    Sort-Object -Unique |
                    ForEach-Object { New-Object psobject -Property @{Computer=$Computer;LoggedOn=$_} } |
                    Select-Object Computer,LoggedOn
                }#If
        }
    catch
        {
            "Cannot find any processes running on $computer" | Out-Host
        }
     }#Forech-object(ComputerName)      
           
}#Process
End
{

}#End
}#Get-LoggedOnUser

Thursday, 30 June 2016

Macro for connecting Visual Studio to windows service for debugging

Got this through today from my old colleague Kevin McConaghy,…
 
1.  Hack for service OnStart event, essentially to stall the service for long enough for the VS Extension to connect after starting it, only in debug mode and only if you send a special argument.
 
        protected override void OnStart(string[] args)
        {
#if DEBUG
            // If the "WaitForDebugger" argument is passed, wait for 15 seconds for a debugger to become attached.
            if (args.OfType<string>().Contains("WaitForDebugger"))
            {
                for (var i = 1; i <= 15; i++)
                {
                    if (Debugger.IsAttached)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                // If no debugger is attached, abort attempt to start service.
                if (!Debugger.IsAttached)
                {
                    Stop();
                    return;
                }
            }
#endif
2. The vCmd script, this automates the starting of the service if it is not started, and then the connection of the debugger to the process.
using EnvDTE;
using EnvDTE80;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.ServiceProcess;
public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
    {
        var serviceName = "MessagingService";
        using(var serviceController = new ServiceController(serviceName))
        using(var serviceManagement = new ManagementObject("Win32_Service.Name='"+serviceName+"'"))
        {
            // Start service with "WaitForDebugger" parameter, if the service is stopped.
            if (serviceController.Status == ServiceControllerStatus.Stopped)
            {
                serviceController.Start(new []{"WaitForDebugger"});
            }
            // Attach debugger to process.
            var servicePath = serviceManagement.Properties["PathName"].Value.ToString().Trim('\"');
            try
            {
                var serviceProcess = DTE.Debugger.LocalProcesses.OfType<Process>().Single(x => x.Name == servicePath);
                serviceProcess.Attach();
                return;
            }
            catch(Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format("Could not find process: {0}, {1}.", servicePath, ex.Message));
            }
        }
    }
}
3. The script requires the following references, added via the button.
System.Core
System.Linq
System.ServiceProcess
System.Management





Monday, 9 May 2016

Unshelving from one branch to another in TFS

 

This works fine…

tfpt unshelve /migrate /source:$/MyProject/Fb3.9.8 /target:$/MyProject/Main

But put quotes round and it does NOT work

tfpt unshelve /migrate /source:"$/MyProject/Fb3.9.8" /target:"$/MyProject/Main"

Further information can be found here…

http://geekswithblogs.net/TarunArora/archive/2011/06/06/unshelve-shelveset-created-from-one-branch-to-another.aspx

Thursday, 3 September 2015

How to convert C# bool to Javascript boolean in Razor .cshtml views

I was wanting a clean way to convert a C# Boolean property on a view model into a javascript true / false bit of text for passing into our Typescript context settings constructors, and stumbled upon this way …

@Json.Encode(Model.BoolPropertyName)

clip_image002

Works a treat too!

clip_image004

Thursday, 14 May 2015

C# 6 and Roslyn plugins to VS 2015 RC

In order to get the refactoring support listed here...

https://github.com/DustinCampbell/CSharpEssentials

you can simply install the following versions of the Tools, Extensions and Updates in Visual Studio 2015 RC.

image

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...