Rob van der Woude's Scripting Pages

News Archives 2016 Q4

 

[ Back to the current news page... ]

 

December 22, 2016
• Stephen R. Noble sent me some improvements on the IELogin.vbs code, i.e. code to ensure the login dialog is active and "in front".
This code is a work in progress, and will be published later.
However, while testing some of the changes, I discovered an error in my current version (positioning of the dialog window), so I decided to publish a corrected "intermediate" version right now.

Thanks Stephen
December 15, 2016
• A minor update for SearchMSI.vbs: an error in its help text has been corrected.
• The first "final" release of WMIGen.exe 10.0 is available.
The evaluation version, available for download, will not expire. The licensed version features query editing as a bonus.
December 12, 2016
MaskText.exe is a new command line tool to check if text "fits" or "matches" a mask.
The masking "language" is based on the Masked Edit control in Visual Basic 6.0.
SearchMSI.vbs is a "pimped" version of the script I used to find out in which one of many downloaded MSI files DEVCON was located.
It will list all files inside all MSI files in a directory tree, and you can specify an optional search filter to limit the output.
The script was based on ListMSI.vbs by Adriaan Westra.

Thanks Adriaan
December 9, 2016
• For a new project I had to regularly use DEVCON.
A new version was available, with new features, so I had to check the help text often.
That is why I wrote devcon_help.vbs, a script to create an HTML page with all available commands for the current DEVCON version.
A sample output page generated by the script can be viewed here.
Of course, the DEVCON page has also been updated to support the latest version.
November 20, 2016
• A crashed harddisk drive temporarily rendered my Windows desktop computer useless for a couple of days.
Obeying Murphy's laws, that was the moment I found out I should have modified my backup scripts a couple of months ago, when I moved my profile directory to that particular harddisk after reinstalling Windows on a new SSD drive.
Besides correcting the backup scripts after the computer was fixed, I also wrote GetHDDStatus.ps1, a new PowerShell script to check the local harddisks' SMART status. It may prevent future problems by giving me an early warning...
This is what its output looks like in Windows:


Volume  Status  Disk            Capacity        Model
======  ======  ====            ========        =====

C:      OK      [Disk 0]          466 GB        Samsung SSD 850 EVO 500GB ATA Device
D:      OK      [Disk 1]         2795 GB        TOSHIBA DT01ACA300 ATA Device
E:      OK      [Disk 3]         1863 GB        WDC WD20EARS-00MVWB0 ATA Device
F:      OK      [Disk 4]         1863 GB        WDC WD20EARX-00PASB0 ATA Device
G:      OK      [Disk 2]         1863 GB        WDC WD20EARS-00MVWB0 ATA Device
H:      OK      [Disk 5]         1863 GB        WDC WD20 EARS-00MVWB0 SCSI Disk Device


And this is what it looks like in Linux:


Volume       Status    Capacity    Model
======       ======    ========    =====

/dev/sda     PASSED      455 GB    500GB ST3500830AS


Of course, if the status is not OK, the color will change from green to red.
The Windows WMI queries were based on code by Geoff @ UVM.

Thanks Geoff
P.S.: If you prefer using the command line instead of scripts, try this PowerShell one-liner (Windows-only):

Get-WmiObject Win32_DiskDrive | ForEach-Object { $_.Status + "`t" + $_.Caption }

OK      Samsung SSD 850 EVO 500GB ATA Device
OK      TOSHIBA DT01ACA300 ATA Device
OK      WDC WD20EARS-00MVWB0 ATA Device
OK      WDC WD20EARS-00MVWB0 ATA Device
OK      WDC WD20EARX-00PASB0 ATA Device
OK      WDC WD20 EARS-00MVWB0 SCSI Disk Device


Or this one, which I wouldn't want to type every day:

$i = 0; Get-WmiObject Win32_DiskDrive | Sort-Object DeviceID | ForEach-Object { $_.Status + "`t[Disk $i]`t" + $_.Caption; $i++ }

OK      [Disk 0]        Samsung SSD 850 EVO 500GB ATA Device
OK      [Disk 1]        TOSHIBA DT01ACA300 ATA Device
OK      [Disk 2]        WDC WD20EARS-00MVWB0 ATA Device
OK      [Disk 3]        WDC WD20EARS-00MVWB0 ATA Device
OK      [Disk 4]        WDC WD20EARX-00PASB0 ATA Device
OK      [Disk 5]        WDC WD20 EARS-00MVWB0 SCSI Disk Device

November 14, 2016
APIPA.ps1 is a new PowerShell script to get or set Windows' IP AutoConfiguration status (a.k.a. APIPA) for all network adapters.
November 13, 2016
GetDotNETVersion.ps1 is a new PowerShell script to list all .NET Framework versions installed in Windows (that's right: Windows-only).
It can be used to just list the installed versions, or you can use it to check for a minimum required version.
November 12, 2016
CDEject.ps1 has been updated to make it work in Linux too.
The script requires Windows Media Player to eject all CDROMs in Windows; in Linux the native eject command is used.
November 11, 2016
Ping.ps1 has been updated to make it work in Linux too.
As it turned out, the Net.NetworkInformation.Ping object in Linux does not have a Send method, while its Windows counterpart does.
Using the SendPingAsync method instead made the script work in Windows as well as Linux.
AirReg.ps1 has been updated: in Linux it will now open the URL with the command for the default web browser, instead of relying on file/protocol associations.
This did introduce a new nuisance, i.e. a "Vector smash protection is enabled" message, which could be solved by redirecting standard output to NUL.
November 10, 2016
• A new internet link speed test page has been added to this site.
It is based on code by Jan Moesen.
Since Jan's original code gave me results in the 75 MB/s range, whereas my provider's bill states 6 MB/s, I added more "randomness" in the test data, thus eliminating (or at least diminishing) the effect of data compression.
The test now gives me more realistic figures in the 4 MB/s range...

Thanks Jan
November 9, 2016
Backup2ExternalHDD.vbs is a new script, intended to be scheduled at logon, that will start a backup command as soon as a specific external disk drive is connected.
November 4, 2016
Ping.ps1 is a new PowerShell script to ping multiple computers and return the combined results.
So far, I could not get it running successfully in Linux.
LoginDialog.ps1 had a minor update: its return code is now set to 1 if the help screen is displayed.
Drives.ps1 is a new PowerShell script that lists all available and/or used drive letters.
It does not require elevated privileges.
Note for Windows users: if you're wondering if this script can be run on Linux... it can, but doing so would be completely useless... unlike Windows, Linux doesn't use drive letters.
November 3, 2016
LoginDialog.ps1 is a new PowerShell script that presents a login dialog box and returns the user name and password.
It is intended to be used as helper script in a shell script (bash shell script or Windows batch file)



In Linux, the script is console-only, without a GUI style dialog box.

me@MYPC:~/PowerShell$
me@MYPC:~/PowerShell$ powershell ./LoginDialog.ps1 Theboss

Windows PowerShell credential request
Enter your credentials.
Password for user Theboss: ***********

Theboss;thepassword
me@MYPC:~/PowerShell$
 
November 2, 2016
Reboot.ps1 is a new PowerShell script to reboot the computer.
In Windows it uses WMI, in Linux it uses shutdown -r.
That may be considered cheating, because we're using an external command in Linux, but hey, it works.
• Reboot's "evil twin" ShutDown.ps1 is a new PowerShell script to shutdown and power-off the computer.
In Windows it uses WMI, in Linux it uses shutdown -P.
ChineseYear.ps1 is a new PowerShell script showing the Chinese designation of the year, e.g. 2016 is the Chinese year of the Monkey.
November 1, 2016
GetRes.ps1 has been updated.
The original Windows-only version used WMI to get the screen dimensions and refresh rate.
The new version uses $HOME[0] to detect if it runs in Linux (in Linux $HOME[0] always is a forward slash, in Windows it will be either a drive letter or, for UNC paths, a backslash). If the script detects Linux it uses XRANDR instead of WMI (tip by "diegows" on StackOverflow.com).

Thanks "diegows"
• Like GetRes.ps1, Memory.ps1 has been updated to work in PowerShell on Linux.
The new version uses /proc/memoryinfo when running in Linux, or WMI when running in Windows.
Tip by "silver_moon" in his blog entry "5 commands to check memory usage on Linux".

Thanks "silver_moon"
• A minor update for TxtComp.ps1: its command line parsing and error handling have been improved.
Actually, all code but the last line is dedicated to command line parsing and error handling.
And yes, it runs in PowerShell on Linux too.
• Release Candidate 3 of WMIGen.exe is available for download. The generated PowerShell code has been modified.
October 30, 2016
Chr.ps1 has been updated:
AirReg.ps1 is a new PowerShell demo script, derived from AirReg.hta, to find an airplane's type and model by its registration number.
And yes, it works in PowerShell on Linux too, after applying a trick by Jason Ginchereau to remove annoying progress messages from Invoke-WebRequest commands (add $ProgressPreference = "SilentlyContinue" just before Invoke-WebRequest commands, and optionally restore $ProgressPreference to its original value immediately after the Invoke-WebRequest commands).

Thanks Jason
October 25, 2016
Asc.ps1 is a new PowerShell script that returns the numeric ASCII value of the specified character.
It uses a trick by Serge van de Oever to return the ASCII value as "errorlevel".
Asc.ps1 works in PowerShell on Linux too.

Thanks Serge
Chr.ps1 is a new PowerShell script that returns the ASCII character for the specified numeric value.
Due to its use of the Microsoft­.VisualBasic­.Information object to check if the command line argument is numeric, Chr.ps1 will not work in PowerShell on Linux. Remove or replace this check to make the script work in PowerShell on Linux too.
October 24, 2016
• Using the links I published on October 5, I managed to install PowerShell on Linux (Ubuntu 16.04) and to run my LeapYear.ps1 sample script:

me@MYPC:~/PowerShell$
me@MYPC:~/PowerShell$ powershell ./LeapYear.ps1
2016 is a leap year
me@MYPC:~/PowerShell$ powershell ./LeapYear.ps1 2017
2017 will NOT be a leap year
me@MYPC:~/PowerShell$
 

If you want to try it yourself, use a script with "native" PowerShell commands only; avoid external commands, WMI or other "dependencies".
October 21, 2016
AirReg.hta has been updated:
October 20, 2016
RxReplace.exe has been updated: it now accepts an optional command line switch /F:bytes telling it to read and search only the first bytes of the file or input stream.
Note: if this switch is used, the remainder of the input stream or file will be discarded.
October 14, 2016
RxGrep.exe has been updated: it now accepts an optional command line switch /F:bytes telling it to read and search only the first bytes of the file or input stream.
October 6, 2016
RipCD.bat has been updated: if the number of tracks exceeds 9, it will add leading zeroes to tracks 1..9, making sorting a little easier.
October 5, 2016
DateDiff.exe has been updated:
• From the Interesting News Department: PowerShell is now Open Source and available for Linux. More info:

 

 

Archived News pages
Archived news from 2016
Archived news from 2015
Archived news from 2014
Archived news from 2013
Archived news from 2012
Archived news from 2011
Archived news from 2010
Archived news from 2009
Archived news from 2008
Archived news from 2007

 

 


page last modified: 2018-04-16; loaded in 0.0019 seconds