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 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.00 Display BIOS properties 2006-09-11 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 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 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 1.00 Get the SMART status for all local harddisks 2016-11-20 Uses WMI in Windows, or LSHW, SMARTCTL and DF 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 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 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 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 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 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 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 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 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 RC3 Generate Batch, C, C++, C#, Delphi, F#, Java, JScript, KiXtart, Lua, Object Pascal, Object Rexx, Perl, PowerShell, Python, Ruby, VB .NET and VBScript code for WMI queries 2016-11-01 WMIGen is a compiled Windows GUI program which generates WMI code to be used in PowerShell or other languages.

 


page last uploaded: 2016-11-04, 10:28