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 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 "
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!
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.
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.
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.
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
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.
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.