The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for July, 2019

No IPMI? Use a Raspberry Pi to remotely control the power of your computer

Posted by jpluimers on 2019/07/12

Interesting project: [WayBack] WtRPM: A Web-based (Wt) suite to power up/down your computers – mupuf.org

It hooks a RaspberryPi to your ATX power supply.

Via: [WayBack] gpio – Use Raspberry Pi to control PC’s power switch – Raspberry Pi Stack Exchange

–jeroen

Posted in Development, Hardware Development, Hardware Interfacing, Raspberry Pi | Leave a Comment »

Government & Govt Owned – Netherlands – Phishing Scorecard

Posted by jpluimers on 2019/07/12

The archive is of late 2017; I wonder what the state is now: [WaybackGovernment & Govt Owned – Netherlands – Phishing Scorecard

This Phishing Scorecard is the current situation of the security of e-mail stream banks compared. If a bank is one of the technical building blocks to implement in their e-mail security the red cross will be a green check mark. Once a bank’s security policy has only green check marks will stand up and protect them 40% of their customers.

–jeroen

Via: [WayBack‘Mailservers Tweede Kamer missen beveiliging tegen e-mailspoofing’ – update – IT Pro – Nieuws – Tweakers

De mailservers van de Tweede Kamer missen beveiligingsmaatregelen die e-mailspoofing tegen moeten gaan, waardoor het mogelijk is om uit naam van politici e-mails te versturen. Dat blijkt uit een onderzoek van Follow the Money.

Posted in Power User, Security | Leave a Comment »

Tech Notes: TypeScript at Google

Posted by jpluimers on 2019/07/11

For my link archive: [WayBack] Tech Notes: TypeScript at Google.

A good discussion, also about alternatives (like Kotin, Scala, GTW) is at [WayBack] TypeScript at Google | Hacker News

Via [WayBack] TypeScript at Google https://news.ycombinator.com/item?id=17894764 #typescript #google #microsoft #javascript – Adrian Marius Popa – Google+

–jeroen

Posted in Development, JavaScript/ECMAScript, Scripting, Software Development, TypeScript | Leave a Comment »

Visual Studio: show whitespace and configure spaces instead of tabs

Posted by jpluimers on 2019/07/11

As I always forgets this and fresh Visual Studio installations favour tabs over spaces, here is how to get it into sane mode:

Related: [WayBackWhitespace: The Silent Killer

–jeroen

Read the rest of this entry »

Posted in .NET, Development, Software Development, Visual Studio 2012, Visual Studio 2013, Visual Studio 2014, Visual Studio 2015, Visual Studio and tools | Leave a Comment »

PowerShell: get WindowsUpdate information

Posted by jpluimers on 2019/07/11

A while back, I needed to check Windows Update information on a few hosts, so I wanted to script it. Below are a few links that helped me solve this started.

Note: For Windows Update, you need the TiWorker.exe process, which can consume a lot of CPU. See DISM fix for Windows 8.1 high CPU usage of TiWorker.exe which is basically the same for all Windows versions since 8.0.

The infrastructure management on that site was ehm, a bit lacking, so PowerShell modules were out, heck even PowerShell itself was initially problematic (it needed running of unsigned sources.

A few notes on the above links.

Using Microsoft.Update.AutoUpdate

This gets the last date that anything was done (query, actual update, download) on Windows Updates, but does not guarantee the installation date; on some systems it does not even return a result:

$windowsUpdateObject = New-Object -ComObject Microsoft.Update.AutoUpdate
$windowsUpdateObject.Results

This one works better though:

$windowsUpdateObject = New-Object -ComObject Microsoft.Update.AutoUpdate
$windowsUpdateObject.Results.LastInstallationSuccessDate

Based on that, you can get the number of days like this:

(New-TimeSpan -Start $windowsUpdateObject.Results.LastInstallationSuccessDate.Date -End (Get-Date)).Days

Using Get-HotFix

Though some people report that InstalledOn can be empty, I’ve hardly that happen with Get-HotFix. The easiest way to get around that is filtering with | Where-Object InstalledOn -ne $null

The cool thing with Get-HotFix is that you can filter on the kind of security update, so this gets the moment the last security update got installed:

(Get-HotFix -Description "Security Update" | Where-Object InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn

And this the number of days since the last security update got installed:

(New-TimeSpan -Start (Get-HotFix -Description "Security Update" | Where-Object InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn -End (Get-Date)).Days

Step by step:

Get-HotFix -Description "Security Update"

Gets all the security updates.

| Where-Object InstalledOn -ne $null

Filter out entries having an empty InstalledOn.

Sort-Object InstalledOn -Descending

Get the most recent on the top.

| Select-Object -First 1

Select only the top entry.

(Get-HotFix -Description "Security Update"...).InstalledOn

Get only the InstalledOn property.

Get-Date

Get the current timestamp consisting of date and time.

New-TimeSpan -Start (...).InstalledOn -End (Get-Date)

Get a TimeSpan over a start and end timestamp.

(New-TimeSpan ...).Days

Get the Days property of a TimeSpan.

You can do the same for regular updates by changing the -Description parameter:

(Get-HotFix -Description "Update" | Where-Object InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn
(New-TimeSpan -Start (Get-HotFix -Description "Update" | Where-Object InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn -End (Get-Date)).Days

The Description values I found are these:

PS C:\Users\Developer> Get-HotFix | Sort-Object -Unique Description | Select-Object Description

Description
-----------
Hotfix
Security Update
Update

Ironically, since the command is called Get-HotFix, the Hotfix entries on my various Windows systems have been a  long long time ago:

(New-TimeSpan -Start (Get-HotFix -Description "Hotfix" | Where-Object InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn -End (Get-Date)).Days

When writing this in 2017, on Windows 8.1, this was more than 600 days, Windows 7 more than 400 days and Windows 10 did not have any Hotfix entries.

Old PowerShell versions

On PowerShell 2 and older, you get an error containing “Where-Object : Cannot bind parameter ‘FilterScript'”:

Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert the "InstalledOn" value of type "System.String" to type "System.Management.Automation.ScriptBlock".
At line:1 char:48
+ (New-TimeSpan -Start (Get-HotFix | Where-Object <<<< InstalledOn -ne $null | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn -End (Get-Date)).Days
+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand

You solve it like this:

(New-TimeSpan -Start (Get-HotFix | Where-Object { $_.InstalledOn -ne $null } | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn -End (Get-Date)).Days

By now code has become almost unreadable, so you can split it using backtick ` characters:

( `
New-TimeSpan -Start `
  ( `
    Get-HotFix | Where-Object { $_.InstalledOn -ne $null } `
    | Sort-Object InstalledOn -Descending `
    | Select-Object -First 1 `
  ).InstalledOn `
  -End (Get-Date)`
).Days

One more thing

On non-English Windows systems, the InstalledOn might actually be in the future, as you can view this happening by this simple command which I ran on 2017-11-02 :

Get-HotFix | Out-GridView

You solve it by adding a filter:

Get-HotFix | Where-Object InstalledOn -lt (Get-Date) | Out-GridView

If you run them from a script (like a batch file Get-HotFix ^| Out-GridView or ps1 file Get-HotFix | Out-GridView), then the grid-view will pop-up and immediately close because the PowerShell process ends. In that case, you need to change your scripts to add the -Wait parameter:

PowerShell Get-HotFix ^| Out-GridView -Wait

Powershell.exe -Command "Get-HotFix | Out-GridView -Wait"

Get-HotFix | Out-GridView -Wait

See:

In C#

If I ever want to do the same from C#, I need to figure out where to get the WUApiLib from; more on that library is at [WayBack] Use C# to interact with Windows Update – Stack Overflow and [WayBack] Searching, Downloading, and Installing Updates (Windows).

–jeroen

Posted in Development, Power User, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

esxi listing usb devices on host console: lsusb

Posted by jpluimers on 2019/07/10

Searching for esxi list usb devices on host console did not return meaningful results, but after a few more deeper tries I found that ESXi has lsusb at

Here the difference when connecting another USB hub with devices to an existing ESXi machine:

[root@ESXi-X10SRH-CF:~] lsusb
Bus 001 Device 005: ID 0781:5583 SanDisk Corp. Ultra Fit
Bus 001 Device 004: ID 0557:2419 ATEN International Co., Ltd 
Bus 001 Device 003: ID 0557:7000 ATEN International Co., Ltd Hub
Bus 003 Device 002: ID 8087:8002 Intel Corp. 
Bus 002 Device 002: ID 8087:800a Intel Corp. 
Bus 001 Device 002: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 003 Device 001: ID 0e0f:8002 VMware, Inc. 
Bus 002 Device 001: ID 0e0f:8002 VMware, Inc. 
Bus 001 Device 001: ID 0e0f:8003 VMware, Inc. 
[root@ESXi-X10SRH-CF:~] lsusb
Bus 001 Device 010: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 009: ID 0922:0019 Dymo-CoStar Corp. LabelWriter 400
Bus 001 Device 008: ID 06bc:0324 Oki Data Corp. 
Bus 001 Device 007: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 006: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 005: ID 0781:5583 SanDisk Corp. Ultra Fit
Bus 001 Device 004: ID 0557:2419 ATEN International Co., Ltd 
Bus 001 Device 003: ID 0557:7000 ATEN International Co., Ltd Hub
Bus 003 Device 002: ID 8087:8002 Intel Corp. 
Bus 002 Device 002: ID 8087:800a Intel Corp. 
Bus 001 Device 002: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 003 Device 001: ID 0e0f:8002 VMware, Inc. 
Bus 002 Device 001: ID 0e0f:8002 VMware, Inc. 
Bus 001 Device 001: ID 0e0f:8003 VMware, Inc.

A few odd things about the devices listed above:

  1. are in none of the /var/log/* files when searching for Oki, Dymo or NEC
  2. are listed differently in Windows:
    • Windows lists the 06bc:0324 Oki Data Corp.  as a “Composite device” with a few sub-devices “MC5(3)x2/ES5(3)4×2” and “USB Printing Support”
    • Windows lists the 0922:0019 Dymo-CoStar Corp. LabelWriter 400 as “USB Printing Support” with a subdevice “DYMO LabelWriter 400”
  3. are listed differently when assigning them to a VM:

Two indispensable tools on Windows for dealing with USB devices are:

They give a much easier to read view than devmgmt.msc, this despite the “hidden devices” trick at [WayBack] Tweak Device Manager for a more Complete View of Devices

Related:

–jeroen

Read the rest of this entry »

Posted in Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

XKCD – Making Progress: lots of problems

Posted by jpluimers on 2019/07/10

I think the alt-text is even better than the cartoon itself:

I started off with countless problems. But now I know, thanks to COUNT(), that I have “#REF! ERROR: Circular dependency detected” problems.

Source: [WayBackXKCD 1906: I started the day with lots of problems. But now, after hours and hours of work, I have lots of problems in a spreadsheet.

–jeroen

Read the rest of this entry »

Posted in Agile, Development, Fun, Quotes, Software Development | Leave a Comment »

PowerShell “Set-ExecutionPolicy” via the registry

Posted by jpluimers on 2019/07/10

I wrote about the PowerShell Set-ExecutionPolicy a few times before (links are below).

After writing those, I found out there is another value ByPass and that there are ways to perform this in the Registry not just for the local machine, but also for a user. In retrospect, that last observation is a bit obvious, but it can be really convenient if you want to change it for a different user than yourself.

For the machine and current user, these are the registry paths where Set-ExecutionPolicy will set the value of ExecutionPolicy to the desired enumeration string:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  • HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

The trick is that you can set this for any user if you have their SID, which – for many known entities – you can get from [MS-DTYP]: Well-Known SID Structures via The mother lode of well-known SIDs – The Old New Thing.

So for instance, below are the users, keys and statements for the users under which most services run, so after executing the one for your target service, it can run PowerShell scripts:

  • LOCAL_SYSTEM : HKEY_USERS\S-1-5-18\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  • LOCAL_SERVICE : HKEY_USERS\S-1-5-19\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  • NETWORK_SERVICE : HKEY_USERS\S-1-5-20\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

A command to set the value of ExecutionPolicy there to RemoteSigned is this:

::LOCAL_SYSTEM
reg add "HKEY_USERS\S-1-5-18\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" /v "ExecutionPolicy" /t REG_SZ /d "RemoteSigned" /f

::LOCAL_SERVICE
reg add "HKEY_USERS\S-1-5-19\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" /v "ExecutionPolicy" /t REG_SZ /d "RemoteSigned" /f

::NETWORK_SERVICE
reg add "HKEY_USERS\S-1-5-20\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" /v "ExecutionPolicy" /t REG_SZ /d "RemoteSigned" /f

Related:

–jeroen

Posted in Development, PowerShell, Scripting, Software Development | Leave a Comment »

Thread around DCEF3 leaking memory, but DCEF4 doesn’t taught me to look at madExcept for memory leak checking too

Posted by jpluimers on 2019/07/09

This thread about [WayBack] DCEF3 memory leak in Delphi XE2  – Alberto Paganini – Google+ taught me that madExcept has a much more elaborate memory leak checking than FastMM4: it checks any Windows memory heap allocation, handle leaks, etc, not just the Delphi code induced memory allocations.

Thanks David Heffernan for commenting this part:

The madExcept leak tracking tools are much more comprehensive than those of FastMM because have much greater coverage. FastMM’s leak tracking tools are great, but only track native Delphi allocations. With the madExcept tooling you get all heap allocations (including non-native ones), handle leaks etc.

That is not to belittle the FastMM tooling at all…

Time to again look at [WayBack] madshi.net – madExcept description

–jeroen

Posted in Delphi, Development, Software Development | 2 Comments »

David A. Koontz on Twitter: “Software – so many options” – rethink SOLID

Posted by jpluimers on 2019/07/09

[WayBackDavid A. Koontz‏ @davidakoontz More Software – so many options

via: [WayBackWeekend Reader 2017.42 – reality-loop

Oldest I could find: [WayBackNo free lunch – Free Agile! Community

–jeroen

Read the rest of this entry »

Posted in Development, Software Development | Leave a Comment »