PowerShell Logo

141 results found for the Scripting Techniques Category in about 0.151 seconds
Add a Line to the Beginning of a Text File and Simultaneously Delete the Last L


Administrative Privileges Check
PowerShell one-liner to check for admin rights.

Module manifest for Advanced Event 1 for 2010 Scripting Games

module for Advanced Event 1 for 2010 Scripting Games

Advanced PowerShell Event 10 for 2010 Scripting Games

Allow PowerShell V2 access to .NET 4.0 framework


Append a Blank Line and the Date and Time to a Text File


Arposh Windows System Administration tool 2.0.1
AWSA was built with the System Administrator in mind. Troubleshooting Windows issues requires a vast array of tools and knowledge. AWSA brings those tools together in one central location and adds additional functionality.

AST Module.


Automated Website Printing in IE using PowerShell
This script runs IE from PowerShell to load a website and using PDFCreator as default printer it prints the website as a PDF file. File name and location are configurable. Depending upon the website content the sleep time parameter adjustments may be needed.

Binary Clock V2.0
My second version of my original binary clock that looks more graphically pleasing than the original clock.

Browse .Net Framework Types Available to the Current PowerShell Session
Browse .Net Framework Types Available to the Current PowerShell Session

Capture the Windows PowerShell Console as Text


Change the Windows PowerShell Console Icon


Check for Caps Lock prior to credentials prompt
This sample script (by request) checks if the Caps Lock key is enabled prior to obtaining credentials from the user.  If it is enabled, it will loop and check every two seconds until the Caps Lock key is turned off.  Note that the method of detection does not always reflect accur

Global Function to add to Module or Profile - CLEAR Windows Event Logs

Demo script that illustrates displaying colorized output in the properties of a format-table command

Combine the contents of two text files
Combine the contents of 2 text files with equal lengths into a new file or interleave the contents of two text files into a new file. This is great for combining the contents of two files with commands into one with each line after the other.

Consultant's Yearly Salary Estimator
if you are a consultant like me, use this script to estimate your yearly salary. Configurable parameters are like time off days and pay rates. The time off dates can be specified in range such as "05/01/2011..05/31/2011".

Conversion Module Version 6
This module contains a number of functions that perform different types of numeric conversions ex. tons into pounds.

Convert a Here String into an Array
This takes a Here-String input and converts it to an array.

Convert a string size value into Bytes
This script can be used to pull data from a file that is a string value and then convert it into bytes to be used for sorting or adding other values together. Best if used as a function with other scripts.

Convert a WMI Date to a .NET DateTime Value Using Windows PowerShell


Convert an Image File to ASCII Art Using Windows PowerShell


Convert Binary Subnet Mask to Decimal
This script demonstrates using the System.Convert .NET Framework class to convert from a binary number, into decimal format. It uses  a counter variable to keep track of decimal placement. As each number passes over the pipeline, I store the converted value in the $a variable. I

Convert decimal subnet mask to binary format
ConvertDecimalSubnetMaskToBinary.ps1 demonstrates using theSystem.Convert .NET Framework class to convert from a decimal number, into binaryformat. It uses a counter variable, $i, to keep track of decimal placement. Aseach number passes over the pipeline, I store the converted va

Converting Bytes into to highest unit of size.
This can take the size of a disk or some other source that is usually given in Bytes when performing a WMI query and it will automatically determine the size (KB,MB,GB,TB,PB) and display the output.

Counting Objects from CSV file
This script will select a particular property column of a csv file and then will copy all the contents of that property column, and then group those objects by the unique value, and then count those unique objects. An alternative to Group-Object

Create an RTF document with Windows Powershell WITHOUT WORD
This script will create an RTF document on your workstation using Windows Powershell.   It is a very simple conceptual script that can be expanded for many purposes.In this sample script it will leverage four static variables as an example to populate a welcome letter for a new u

Create Your Own Help File for Cmdlets


Debug regex operation when matching any string


Export one or more PowerShell functions from memory to a file. Each function can be exported to its own .ps1 file or you can combine several functions and write them to a single file use -append.



Fast alternative to Get-Content
This little function can act as a full replacement for Get-Content.  I have called it 'rc', to mimic Get-Content's 'gc'.  It used the .NET io.file::ReadAllLines method, which is considerably faster, and can have a big impact when reading large text files. 

Find Remove VM Snapshots


Formatting Output of get-date
There are 133 different ways to display date/time using GetDateTimeFormats()

Generate Powershell WMI Class Scripts
This script generates a script for each of the WMI classes that will list the WMI class name and the properties.

Get available WMI methods
Windows WMI Classes with MethodsThis script was used to aggregate a list of available WMI classes with Methods that are available to Powershell.  It is a helpful list to have when writing scripts and can even give you some ideas that you may not have thought of when managing your

Get Processes Write To Temp File and Delete Temp File
This script uses Get-Process cmdlet to get listing of processes. Writes results to a temporary text file and displays the text file. When the user closes notepad, the temporary text file is deleted.

Get sha1 checksum for file


Get WMI Class qualifiers function
WMI class qualifiers tell me if a class is dynamic or abstract. I use the dynamic classes for finding information about computers. Use of abstracts is seldom done by an IT Pro. Qualifiers also tell me if I can use the class to make updates on a system. I talk about WMI class qual

Get Writable WMI Properties for a class, Get Implemented WMI methods for a class
This is a modification to the script I uploaded back in March 2011. I am going to use this script in a HSGWMIModule I am creating on the TechNet Script Center Hey Scripting Guy! blog next week. The modifications I made to the previously mentioned script include the following: 1.

Get-ClipText Function
PowerShell function to get the text content from the Windows Clipboard or this is the "paste" option.

Gets the content of an INI file



This script retrieves a list of all machines on the current domain, pings the remote machine to validate its curren state, and, upon verification, enumerates the logged on users with the Win32_LoggedOnUser class.  When the results are output the Server and User values are returne

This script will use the SCHTASK utility to get scheduled task information and report on any non-successful tasks that have occurred within the past one day (by default).

Get-Services on thousands of computers in minutes...
Document service accounts with PowerShell, Excel and WMI. Series of scripts demonstrating optimization techniques. Go from documenting 50 computers in 90 minutes down to 42 seconds. Microsoft PFE Georges Maheu discusses these techniques in a series of “Hey Scripting Guy" blogs.

This script creates a new instance of the System.Net.WebClient class, calls the DownloadString() function, and, returns the results from the public automation page: http://automation.whatismyip.com/n09230945.asp. In this current version, the result is of type System.Object. To

This script returns a listing of implemented WMI methods and writable WMI Properties for all WMI classes in a particular WMI namespace. By default it searches the root/cimv2 namespace, but this is configurable.



This script will search all dynamic WMI classes in a particular WMI namespace (default is root\cimv2) for properties you can write to. It is a useful tool that simplifies finding this information. It is discussed in detail in Hey Scripting Guy article for March 11, 2011

This script gets all implemented methods and writable properties from all dynamic WMI classes in all WMI namespaces. It is useful to those who wish to explore WMI and look for things they can change. This script is discussed in March 13, 2011 Hey Scripting Guy! blog.

Graphical Trip cost calculator
Calculates the cost of a trip by accepting the miles, miles per gallon of vehicle, and cost of fuel.

GUI WMI Explorer and WMI Method Help Generator


Helpful Powershell Profile




This is just simple addon to ISE for PowerShell 3 CTP 1.It just uses currently edited file and invoke it with PowerShell V2. Can be used to have both great ISE experience and possibility to run scripts using v2 engine.Most of the time you won't need it (most of script from v2 wor

List a Cmdlet's Parameters in a Single clean column
This script simply pulls out the parameters a cmdlet has and just lists them in a single column.I find it helps me if I see a new cmdlet that has too many available parameters to figure out which ones I might need, that having them in a single column helps me figure them out quic

List local group members on a remote computer using WMI and PowerShell
This PowerShell function uses WMI to retrieve a list of local group members as an alternative to the ADSI method (using "WinNT://," etc.).

List the Properties of WMI Classes


List WMI Setting Information
Returns information about how WMI has been configured on a computer. This script requires both Windows PowerShell and the corresponding version of the .NET Framework. For more in

ListBox2.ps1 - PowerShell ListBox control
Illustrates reading a text file, and populating a list box. Talked about in Hey Scripting Guy blog 3/3/2010

ListBox3.ps1 PowerShell listbox and winform demo code
This script is discussed in Hey Scripting Guy on 3/4/2010

Load the New Server with Users Across all of the Storage Groups/Databases on th


Loading PowerShell module from NuGet package
ImportPSModule is a PowerShell module that enable anybody to import,load and registered PowerShell module from NuGet package. Using NuGet ensures that PowerShell module will benefit from package management system.

Lottery number generator


Manage PowerShell from Serial Port
Functions to manage PowerShell from Serial Port. It can be used to manage the basic PowerShell commands that are sent to the remote machine via a serial port.

Mask Command Line Passwords
Powershell version, functionally equivalent to the VBScript example at http://gallery.technet.microsoft.com/ScriptCenter/en-us/25ba8659-f76e-4654-b3e0-b1ee1efe20f7

Mega Millions Jackpot Winner
This script demonstrates how to use a foreach loop on an array of numbers through the pipeline and then join them with a hyphen.Example Results.\Get-MegaMillionsWinner.ps146-1-52-45-32-30.\Get-MegaMillionsWinner.ps117-53-14-51-28-6.\Get-MegaMillionsWinner.ps16-46-39-14-18-29 Auth

Merge Two XML Files using MergeXml PowerShell Module


Mini Security Explorer
This script List all users with permission to folder and sub folders. Just run the script and input the folder path. e.g C:\

MiniCalc - A PowerShell Calculator with GUI
This script displays a simple calculator and echos the results back to the console.

My Profile.PS1
 This Script includes som fun items that i use in my personal powershell profile on my home desktop it integrates a few small functions that I use for fun such as pulling a quote off of an rss feed and reading it aloud with the systems voice api displaying weather information use

Number the Lines in a Text File


Write hash content to INI file

Pad a text list to make all items the same length


pathtype and pathsplit in one
Return if path is a file or folder and the separate parts of the path.

PowerGUI FunctionExplorer
This add-on provides an easy navigation through a treeview that displays all defined functions in all open documents. By double clicking on a function the PowerGUI jumps to the document and function. Also a "Go to Definition" function (F12) is available.

PowerShell - Accept User Input Using Visual Basic InputBox
PowerShell script to display an InputBox to accept user input.

PowerShell - Split large log and text files
This script prompts the user for a source log file and splits the file into equally sized smaller files so that it is manageable and readable using traditional text editors.Here is a blog on it: http://www.discoposse.com/index.php/2011/09/29/powershell-splitting-log-files/ The sc

Powershell Binary Clock


Powershell Checking for Snapins as Dependences
Checks for a Snapin in Powershell, Loads it or flags the error and warns user. Script does not run without Dependency loaded

PowerShell Console RSS Ticker


PowerShell Console Weather Ticker


PowerShell Conversion module
This module contains a number of useful functions that convert various units.

PowerShell file browser to demonstrate Windows Forms ListView control
This sample script has been created to demostrate the usage of Windows forms listview control in PowerShell

PowerShell Graphical List Box
Demonstrates using a list box control in PowerShell. Discussed in Hey Scripting Guy Blog on 3/2/2010

PowerShell help browser using Windows Forms and TreeView Control
This is a script example to demonstrate how Windows Forms and TreeView control can be used to create a PowerShell Help Browser.

PowerShell Quiz script
This script provides the ability to create a puzzle based upon Windows PowerShell cmdlet names. But it also has the ability to do a generic quiz based upon a text file. A sample text file is attached, and it consists of the form answer=question. This script is discussed in the He

Powershell Show-MsgBox Function
This Powershell advanced function will emulate the Visual Basic msgbox function. It takes five parameters: Prompt, Title, Icon, BoxType, and DefaultButton. Using these five parameters, and so you can customise the pop-up message to many different combinations.

Powershell: Customizable Custom Control for New-PSDrive


Profile script to store PowerShell ISE preferences
This script will take care of saving your ISE preferences such as color schemes, font styles, etc.

Provide a Yes/No Prompt in Windows PowerShell


This is a collection of functions that I wrote to enhance how I write PowerShell scripts and functions. They can be installed as menu items to make them easier to get at and use. I have a specific template that I follow when writing and these functions automate that somewhat.

Query Active Directory And Ping Computers
This Windows PowerShell script uses the ActiveDirectory module, see this Hey Scripting Guy! blog article for details about this module, to query for all comptuers the Active Directory. It then uses the Test-Connection Windows PowerShell cmdlet to send a ping to each computer that

randomly draw names out of a virtual "hat".
randomly draw names out of a virtual "hat".

Read a Text File All at Once


Read a Text File From the Bottom Up


Read the Oxford (en) Dictionary with PowerShell
The guys over at xdxf.revdanica.com kindly offer dictionaries (lots of languages) for free download. Fortunately they are in XML and PowerShell excels at that.

Registry file to Powershell execution policy to Remote Signed
So I have noticed that some OEM vendors out there are selling systems and are locking down powershell with the execution policy set a restricted. and as a normal user or admin you can't just go right out and run "set-executionpolicy remotesigned" to allow you to get in and play w

This script searches a folder for PowerShell scripts, and replaces all of the aliases in them with the full cmdlet name. It makes a backup copy of the script first.



Retrieve Information from Yahoo! Weather


Retrieve the Set-StrictMode setting


Roman Numeral Clock
Just something I was messing about with. Creating a Roman Numeral clock. It's cheap, It's console, It's geeky. Play with it :)

Sample PowerShell Profile
This Windows PowerShell Profile was developed during the week of 11/23/2009 as part of Profile week.

Scripting Guys Graphical PowerShell Clock
Creates a graphical clock. Discussed in 3/1/2010 Hey Scripting Guy article.

Scripting Guys WMI Helper Module Version 4
This module provides a number of useful WMI helper functions. The one added to todays module is a HasWMIValue filter. This filter is used to cause a WMI query to only return properties that contain a value. After importing the module, use it like this: gwmi win32_bios | HasWMiVal

Scripting Guys WMI helper module version 5
This is the fifth version of the Scripting Guys WMI helper module. Additions include a Get-WMIClassesAndQuery function that will take a wild card, return all non-abstract WMI classes and automatically query those classes. I also added an Out-TempFile function that accepts pipelin

Search and download scripts from TechNet Script Center repository
Lets you search and download scripts to local disk from techNet Script center

Send a HTML email report in a formatted table - Send-HtmlEmail
This will take any Object from the PowerShell interface, convert the object (table) into HTML and then send it by email.

Send script output as an email
insert into existing scripts to email the results

This is an example of how to use splatting to wrap many operations in a .NET object. Send-WebRequest wraps up the System.Net.WebClient class, and allows you to upload or download data, files, or strings to the web from PowerShell.

Set-PSConsole function


Show-MsgBox Function
Display a messagebox using .NET

ShowUI Text Converter


Simple random code generator


Sort With Custom List
Sort with custom list in PowerShell I've seen a couple of people try to do something like this but they didn't know what to call it. In Excel, it's called sorting with a custom list. I thought I'd make one for PowerShell.This comes in handy when you want to sort something but the

Sort with custom list and other stuff


I wanted to have a long pipeline with Sort-Object in the middle and perform that sort only when a condition is true, but still only have one pipeline. Not quite sure how else to do this.

Split Directory-Filename.PS1
Global function to split a Directory and Filename



Stop Watch using Events in Powershell
This is an alarm clock writted in Powershell using the posibility to subscribe scriptblocks to events. An instance of System.Timers.Timer is used to invoke a personalized action when the elapsed event is raised.

Test connection
This tiny little script was the beginning of my powerful Multi-Ping Tool written in powershell. its a basic call to a remote system useing the IP address of a system to test if a system is on or off line useing microsoft WMI. who knew something so simple could become so powerfull

This Advanced Function will look to see if the current user context running a command/script is an Administrator or not. If not, a menu is presented to the user to either continue or enter alternate credentials.

This Powershell Script will accept two date ranges and return true if the ranges overlap

This command invokes PSExec


Toggle the Get-Credential Prompt
Toggles the Get-Credential prompting method between console and CredUI.

Track Script Progress Using Internet Explorer


Use PowerShell to Automate Microsoft Visual Studio 2008
Automate Microsoft Visual Studio 2008 using the EnvDTE automation interface.

Using DataGrid control in Windows PowerShell
This is an exmple written to explain how to use DataGrid control to create GUI in PowerShell scripts.

Vacation Starter
This script creates a Out-Of-Office message based on the users input to be pasted into Outlook

Validate Xml against XSD Schema
This function will allow you to validate an XmlDocument object ([xml]) against a specified XSD schema. It returns an array of objects containing the line number, line position and reformatted error message.

Windows PowerShell ISE Profile And Modules


WMI Helper Module for Windows PowerShell Version 6
This is my last version of the Scripting Guy WMI Helper module. It is HSGWMImoduleV6. I added two tags to the comment based help that allow for easy querying of the functions. I divided them into three categories: meta, query, and helper. To find the functions using Get-Help, use

WMI Helper Module V2
This is version 2 of the WMI Helper Module I uploaded the other day. This new module, contains a new WMI function called Get-WMIKey. The Get-WMIKey function is useful if you want to use the [wmi] instance type accelerator because it must connect to a key property of a WMI class.

WMI helper module version 3
This is the third version of the Scripting Guy WMI helper module. In this version I add a function, Get-WMiKeyValue. This function will return key property values. These are the paths to instances of a WMI class. These paths are used when calling certain methods, or when setting

WMI Information Explorer
This script creates a GUI that allows you to view the WMI properties of any WMI class.

WPF Item Definitions
Provides a GUI that lists public WPF items and queries the definitions. Allows the user to easily view all WPF items and what you can do with them.

XML generator for Remote Outofmemory Testing
This powershell code generates 2 million records in a xml file that later is used to test remote outofmemory scenarios