Rob van der Woude's Scripting Pages

PowerShell Examples

This page lists some sample scripts I wrote in PowerShell.

Unless stated otherwise, these scripts run in Windows as well as in PowerShell on Linux (tested in Windows 7 SP1 and Ubuntu Linux 16.04)

Many of these scripts return their results or status as errorlevel.

Help is available for some of the scripts (the most recent ones) with the -h switch.
PowerShell itself provides "help" for a script with the -? switch, but this help will only list the allowed parameters without explaining them.
In that case you can check the source code for help on command line arguments (parameters and switches) and to check the meaning of return codes/errorlevels.

Download the program Click a download icon to download the script.
ZIP file's checksums Click a check mark icon to view the ZIP file's MD5 and SHA1 checksums.
  Click the script name to view its source code.

 

PowerShell Examples
Click a download icon to download the script Click a check mark icon to view the ZIP file's MD5 and SHA1 checksums Name Version Description Last modified Remarks
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums 2ASCII 1.00 Convert any text file to ASCII 2006-09-26  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums 2Unicode 1.00 Convert any text file to Unicode 2006-09-26  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums 2UTF8 1.00 Convert any text file to UTF-8 2006-09-26  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirReg 1.01 Demo script using Airport-data.com's API to lookup airplane data by its registration number 2016-11-11  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegCCmd 1.00 Search downloaded Canadian aircraft database (C-***) for specific aircraft(s) 2020-05-10 This program requires a downloaded Canadian aircraft registration file, located in the subdirectory "C"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegEICmd 1.00 Search downloaded Irish aircraft database (EI-***) for specific aircraft(s) 2020-05-10 This program requires a downloaded Irish aircraft registration file in Excel format, located in the subdirectory "EI", and Excel
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegFCmd 1.00 Search downloaded French aircraft database (F-***) for specific aircraft(s) 2020-05-16 This program requires a downloaded French aircraft registration file, located in the subdirectory "F"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegGUI 2.16 Demo GUI script using Airport-data.com's API to lookup airplane data by its registration number 2023-05-24  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegHBCmd 1.00 Search downloaded Swiss aircraft database (HB-***) for specific aircraft(s) 2021-08-17 This program requires a downloaded Swiss aircraft registration file in CSV format, located in the subdirectory "HB"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegLYCmd 1.00 Search downloaded Lithuanian aircraft database (LY-***) for specific aircraft(s) 2021-01-05 This program requires a downloaded copy of the Lithuanian aircraft registry database, located in the subdirectory "LY", and GhostScript to convert the downloaded PDF to plain text
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegNCmd 1.00 Search downloaded FAA aircraft database (N***) for specific aircraft(s) 2020-05-09 This program requires a downloaded copy of the FAA Aircraft Registry's Releasable Aircraft Database, located in the subdirectory "N"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegOECmd 1.01 Search downloaded Austrian aircraft database (OE-***) for specific aircraft(s) 2021-01-05 This program requires a downloaded copy of the Austrian aircraft registry database, located in the subdirectory "OE", and GhostScript to convert the downloaded PDF to plain text
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegOOCmd 1.00 Search Pascal Brugier's online Belgian aircraft registration database (O-*** or OO-***) for specific aircraft(s) 2021-01-07 This program uses Pascal Brugier's online Belgian aircraft registration database
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegOpenSkyCmd 1.02 Search downloaded OpenSky Network aircraft database for specific aircraft(s) 2023-05-27 This program requires a downloaded OpenSky Network aircraft registration file, located in the subdirectory "OpenSky"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPHCmd 1.03 Search downloaded Dutch aircraft database (PH-***) for specific aircraft(s) 2021-01-06 This program requires a downloaded Dutch aircraft registration file in Excel format, located in the subdirectory "PH", and Excel
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPPCmd 1.01 Search Brasilian aircraft online database (PP*** .. PU***) for specific aircraft(s) 2020-07-24 This program uses the Consultas ao Registro Aeronáutico Brasileiro online aircraft registry
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPRCmd 1.01 Search Brasilian aircraft online database (PR***) for specific aircraft(s) 2020-07-24 This program requires AirRegPPCmd.ps1
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPSCmd 1.01 Search Brasilian aircraft online database (PS***) for specific aircraft(s) 2020-07-24 This program requires AirRegPPCmd.ps1
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPTCmd 1.01 Search Brasilian aircraft online database (PT***) for specific aircraft(s) 2020-07-24 This program requires AirRegPPCmd.ps1
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegPUCmd 1.01 Search Brasilian aircraft online database (PU***) for specific aircraft(s) 2020-07-24 This program requires AirRegPPCmd.ps1
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegTFCmd 1.00 Search online Icelandic aircraft database (TF-***) for specific aircraft(s) 2020-05-09 This program uses the Icelandic Transport Authority online aircraft registry
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegVHCmd 1.00 Search downloaded Australian aircraft database (VH-***) for specific aircraft(s) 2020-05-19 This program requires a downloaded copy of the Australian aircraft registry database, located in the subdirectory "VH"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums AirRegZKCmd 1.00 Search downloaded New Zealand aircraft database (ZK-***) for specific aircraft(s) 2020-05-19 This program requires a downloaded copy of the New Zealand aircraft registry database, located in the subdirectory "ZK"
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums APIPA 1.00 Get or set the IP AutoConfiguration status (a.k.a. APIPA) for all network adapters 2016-11-14 Make sure you understand what this script will do before using it!
This is a Windows-only script.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Asc 1.00 Get the numeric ASCII value for the specified character 2016-10-25  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums BIOS 1.01 Display BIOS properties 2020-08-27 Generated by WMIGen.
Updated to PowerShell 7 by Thierry Montané.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums BootState 1.00 Show Windows' boot state, e.g. Normal, Safe mode, Windows PE 2017-10-19 Windows only
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums CapsLockIcon 1.01 CapsLock key indicator in the System Tray 2020-04-14 Windows only
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums CDEject 1.01 Eject all CDROMs 2016-11-12 Requires Windows Media Player in Windows, native "eject" command is used in Linux.
Windows code based on VBScript code posted by Christoph Fricke in the microsoft.public.de.german.scripting.wsh newsgroup
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ChineseYear 1.00 Get the Chinese name for the year, e.g. 2016 is the year of the Monkey 2016-11-02  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Chr 1.01 Get the ASCII character for the specified numeric value 2016-10-30  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums DHCPBackup 1.00 Backup daily DHCP logs 2007-08-30 "Third party" Windows-only script by Jason Carter, Marshall University Computing Services.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Disks 1.00 List physical harddisks and their manufacturer, model, size, bus type, physical location and more 2020-04-10 Windows only.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Drives 1.01 List available and/or used drive letters 2016-11-04 Useless on Linux, which doesn't work with drive letters.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums GetDotNETVersion 1.00 List the .NET Framework versions installed in Windows 2016-11-13 Windows-only.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums GetHDDStatus 2.03 Get the S.M.A.R.T. status for all local harddisks 2019-03-20 Uses WMI in Windows, or lshw, smartctl, df and notify-send in Linux.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums GetHDDStatusGUI 1.04 Get the S.M.A.R.T. status for all local harddisks 2020-06-09 Windows-only GUI version of GetHDDStatus.ps1
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums GetRes 2.00 Show screen resolution 2016-11-01 Uses WMI in Windows, or XRANDR in Linux.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums GetTitle 1.00 Read the console window title 2011-05-10  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums IsCDWriter 1.00 Check whether the specified drive is a CD/DVD writer or not 2017-08-15 Windows-only
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums LeapYear 1.00 Check if the specified year is a leap year 2006-10-25  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums LoginDialog 1.01 Present a login dialog and return username and password 2016-11-04 In Windows a GUI style dialog box is used, in Linux the prompt for (user name and) password is in the console.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums LoginDialogWinForm 1.00 Demo login dialog script using Windows Forms 2019-03-19 Windows only.
Built with PoshGUI Editor.
For demonstration purposes only, LoginDialog.ps1 provides a much better login dialog.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Memory 2.01 Display total and free amounts of physical memory 2016-11-01 Uses WMI in Windows, or /proc/meminfo in Linux.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums MonitorPing 1.00 Ping a device at a fixed interval and show the connection status in the Notification Area (a.k.a. System Tray) 2020-05-14  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums NumLockIcon 1.00 NumLock key indicator in the System Tray 2020-04-25 Windows only
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Ping 2.00 Ping multiple computers and return the combined results 2016-11-11  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums PowerShellComputerClass 1.00 Class that holds "all" hardware information for the local computer 2021-12-20 See the PowerShell Computer Class product page.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums PrintWord 1.00 Print a Word document 2020-04-21 Requires Word.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums PSVer 2.00 Display PowerShell version 2016-10-24  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ReadExcel 1.00 Read an Excel file and show all cells and content for every sheet 2020-04-16 Requires Excel.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Reboot 1.00 Reboot the computer immediately 2016-11-02 Uses shutdown -r in Linux, or WMI in Windows.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Restart_Ethernet 1.01 Restart Ethernet network adapter 2020-08-30 Requires elevated privileges to restart the network adapter.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Restart_PhysicalNetworkAdapters 1.01 Restart all physical network adapters 2020-09-02 Requires elevated privileges to restart the network adapter.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Show-Console 1.00 Cmdlet to manipulate the console window state, i.e. hide the console, minimize it, activate it, etc. 2021-12-17 Based on code by Hansson0728 on StackOverflow.com.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ShowCpuH 1.00 Display CPU details in an HTML page 2006-09-01 Generated by WMIGen.
Since the script uses WMI it is Windows-only.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ShowPRN 1.10 Display all printers 2006-09-10 Generated by WMIGen.
Since the script uses WMI it is Windows-only.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ShowPrnH 1.01 Display all printers in an HTML page 2006-08-31 Generated by WMIGen.
Since the script uses WMI it is Windows-only.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums ShutDown 1.00 Shutdown and power-off the computer 2016-11-02 Uses shutdown -P in Linux, or WMI in Windows.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Today 1.00 Display today's yesterday's and tomorrow's date in 2 formats 2006-07-05 This script combines the functions of my SortDate, Yesterday and Tomorrow scripts as available in other scripting languages.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums TxtComp 1.01 Compare two text files and display the differences 2016-11-01  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Week 1.00 Display current week number 2006-06-26  
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums WeerLive 1.00 Demo script using WeerLive.nl's API to get live Dutch weather data from the Dutch KNMI weather agancy. 2020-08-21 The author of this script is in no way associated with WeerLive.nl.
A basic understanding of the Dutch language is required to requist your personal WeerLive API key.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums Which 1.00 Locate the specified program file 2006-07-27 See my UNIX ports page.
Click the download icon to download the script Click the check mark icon to view the ZIP file's MD5 and SHA1 checksums WMIGen 10.0.15.6 Generate Batch, C, C++, C#, Delphi, F#, Java, JScript, KiXtart, Lua, Object Pascal, Object Rexx, Perl, PHP, PowerShell, Python, Ruby, Tcl, VB .NET and VBScript code for WMI queries 2023-02-25 WMIGen is a compiled Windows GUI program which generates WMI code to be used in PowerShell or other languages.

 


page last modified: 2023-05-27; loaded in 0.0306 seconds