Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.



Windows PowerShell Read-Host

Windows PowerShell Read-Host (Input Box)Input Box Read-Host

When you need user input, then employ Read-Host with associated variables.  This is PowerShell's equivalent of MsgBox() in VBScript.

Windows PowerShell Read-Host Topics

 ♣

PowerShell Pre-requisites and Checklist

In the case of Windows 7 and Server 2008, you don't need to download any extra files, just 'Add Feature' Windows PowerShell.  However, for older operating systems, installing can be confusing because there are different versions of PowerShell for XP, Windows Server 2003 and Vista.  For such legacy systems only, you need to download PowerShell from Microsoft's site.

Once you have installed PowerShell 2.0, I recommend choosing the ISE (Integrated Scripting Engine) version, it will save you buying a text editor.

PowerShell Script To Generate an Input Box

# PowerShell Read-Host Input Box
Clear-Host
$YearCalc = Read-Host "When were you born?"
$Now = (Get-Date -uformat "%Y") -$YearCalc
$Maybe = $Now -1
Write-Host "You are $Maybe or $Now years old "

Input Box Read-Host

Note:  $YearCalc is the variable that holds the value you enter into the input box.

Note: I am sure that you can do better with the math and with the logic.

Guy Recommends: WMI Monitor and It's Free!Solarwinds Free WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, Solarwinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.  Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory or Exchange Server.

Download your free copy of WMI Monitor

Further Research on Read-Host

PowerShell's Read-Host Parameters

# PowerShell Read-Host Parameters
Clear-Host
Get-Help Read-Host -full

If you want a more secure input box, try -AsSecureString this will displays asterisks (****) in place of the characters that the user types in the box.   You could also experiment with -prompt.

Researching Similar PowerShell Cmdlets

# PowerShell Item Cmdlet Research
Clear-Host
Get-Command -noun Host

You may already know about Write-Host and Clear-Host (cls), but there is also Out-Host.  PowerShell -noun or -verb research always throws up at least one surprise.

Guy Recommends: A Free Wake-On-LAN UtilitySolarwinds Wake-On-LAN

Encouraging computers to sleep when not in use is a great idea - until you are away from your desk and need a file on that remote sleeping machine!

Wake-On-LAN really will save you that long walk to awaken a hibernating machine; however my reason for encouraging you to download this utility is just because it's so much fun sending those 'Magic Packets'.  As Wake-On-LAN (WOL) is free, see if I am right, and you get a kick from arousing those sleeping machines.  WOL also has business uses for example, wakening machines so that they can have their patches applied. 

Download your free copy of Wake-On-LAN

Summary of PowerShell Remove-Item

The syntax for Remove-Item is straightforward.  I urge you to take precautions because if you get the path wrong, the effect could be devastating, especially if you are gung-ho with the -force and the -recurse parameter.  For this reason I suggest that you check with Get-Item before you actually use Remove-Item, even then consider the -whatIf switch if there is any doubt.

If you like this page then please share it with your friends

 


See more Microsoft PowerShell output tutorials:

PShell Home  • Out-File  • Out-GridView  • -f format  • Files  • Pipe to file

Export-CSV  • Import-CSV  • Format-Table  • Format-List  • Read-Host  • Write-Host

ConvertTo-Html   • Windows PowerShell   • PowerShell 3.0 Redirection

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Custom Search

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.

Fortunately, Solarwinds have created the Free WMI Monitor so that you can actually see and understand these gems of performance information.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

 

Home Copyright © 1999-2012 Computer Performance LTD All rights reserved

Please report a broken link, or an error.