PowerShell Studio - OCR
PowerShell Studio - OCR
A Comprehensive Guide
Jeff Holder
ISBN'-13:978-1542658010
ISBN'-10: 1542658012
Copyright 2016 - All rights reserved.
In no vvay is it legal to reproduce, duplicate, or transmit any part of this docume11t in either electronic means or in
printed format. Recording of this publication is strictly prohibited and any storage of this doctunent is not allowed
tutless with '.vritten permission fro1n the author. All rights reserved.
The information provided herein is stated to be truthful ru1d consistent, iI1 that any liability, in tem1s of inattention
or otherwise, by any usage or abuse of any policies, processes, or directions contained within is the solitary and utter
responsibility of the recipient reader. Under no circu111stances will any legal responsibility or bla1ne be held against
the publisher or author for any reparation, da1nages, or monetaiy loss due to the information herein, either directly
or indirectly.
The publisher and author disclaim any personal liability, directly or indirectly, for advice or information presented
within. Altl1ough the author and publisher have prepared this manuscript with utmost care and diligence and have
1nade every effort to ensure the accuracy and co1npleteness of the information contained within, vve assu1ne no
responsibility for errors, inaccuracies, omissions, or inconsistencies.
The information herein is offered for informational purposes solely, and is universal as so. The presentation of the
information is 'vithout contract or any type of guarantee assurance.
The trademarks that are used are vvithout any consent, and the publication of the trademark is ,;vithout permission or
backing by the tradernark ovvner. All traden1arks ru1d brru1ds vvitlrin tlris book are for clarifying purposes oruy and
are owned by the ovvners then1selves, 11ot affiliated vvith this document.
No warrai1ty 111ay be created or extended by sales or promotional inaterials. The advice ru1d strategies contained
herein may not be st1itable for every situation. This work is sold \.Vith the understanding that tl1e publisher is not
engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the
services of a competent professional person should be sought. Neither the publisher nor the author shall be liable
for dainages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or
a potential source of further info1mation does not 111ean that the author or tl1e publisher endorses the info1mation tl1e
organ.izatio11 or Web site 1nay provide or recommendations it may make. Further, readers should be aware that
Inten1et Web sites listed in this work may have changed or disappeared between \V hen this \;vork \.Vas \.Vritten and
when it is read.
orewor
Ma11y Pov,;erSl1ell scripters will tell yot1 that the idea of creating GUI applications for PowerShell
scripts is abStud and breaks the very essence of scripting. Ho,vever, you must keep in mind that
eve11 thou.g h yotrr scripts may see1n logical and easy to use to you, tl1ey n1ay not be quite so
understandable or so easy to use for many that are not fanliliar with the Po\\1erShell language, or
in positions outside of system adn1inistration.
The purpose of sc1ipting is to provide a n1ore efficient, robust, auto111ated, custornizable solution
to tl1e inany repeatable processes that are involved in Infonnation Technology every day. The
purpose of creating PowerSl1ell GUI applications is to take the same PowerShell scripts that you
or others have created and present thern in a very easy to use and understandable GUI application
that cai1 be quickly deployed and used by others 'vith i10 scripti11g experience at all. That saves
trai11ing costs, reduces hu1nan errors, increases productivity, and helps overall lo"ver overhead.
PowerShell scripting has beco1ne a required skillset for any Windows System Administrator. We
can do tilings more efficiently, n1ore reliably with repeatable results, and gained tremendously
more power over local and remote systems tllan ever in the past. However, tills has also shifted
a lot of responsibilities to Syste1ns Adnunistrators that in tl1e past were handled by Helpdesk
persom1el, because many did not u11derstand the use of Po,verShell sc1ipts, paraineter
require1nents, etc. This i1nbalance of workload caused Syste1n Administrators with scripting
eA']Jerience to find a \;vay to utilize tJ1e inuch-needed PowerShell scripts but also at the same time
to e1npower less teclulicaJ perso1n1el with the ability to use the numerous scripts t11at developers
vvere churning out. This has caused a sllift towards PowerShell GUI applications.
I have been extensively using PowerShell Studio for several years, and have developed inany enterprise level
applications, and hundreds of sniaJler applications for both corporate and govennnent agencies. When I first staited,
there \Vas very little training docu1nentation outside of SAPIEN Teclu1ologies, and even tl1ough tl1ey did a great job
documenting 1nany of the countless feat11res in PowerShell Studio it vvas cumberso1ne fi11ding the infonnation and
there ,;vas still some undocumented areas.
It wasn' t until I was deep into "vriting this book that I stepped back and realized just ho\ inuch of a challenge this
was going to be. I was far too deep into it to ttrrn around so the only tiling to do was to push forward because it is
'vhat I would have \vanted an author to do for i11e.
I wrote this to be the kind of book tl1at I "votlld have "vanted to read \Vl1en learning to use Po\>verShell Studio. I hope
you enjoy!
Acknowledgements
First and fore1nost, this book is dedicated to my wile, Kathleen, and my children: Haley,
Matthe"v. Aaron, Cassandra and Ca11dice. This book \vould never have been possible
\vithout my wues extraordiJ1ary patience, support and encourage1nent to follow my heart.
She kept me fed. clothed, managed our home, cared for our children, and worked a full-
time job as an Occupational Therapist helping others overco1ne life's challenges. Kathleen
is an a1nazing giving person, dedicated n1other to 011r children, and a loving and caring
wife. I couldn't think of another person that I would rather spe11d the rest of my life with
than n1y best friend.
My children a1e iny life. they are the reason I get up every day. They represent the future
and I kno\v the future \Yill be great 'vith them in it. A parent cannot express i11 words what
they feel for their children because it 111ns so much deeper t11an \vords could ever express.
We all vva11t to leave behind a legacy. and rny children arc 1ny greatest legacy. I could not
be 1nore proud of each one of then1. I thank 111y children for their sacrifice in tin1c a\vay
fro1n gan1es and playing to give Daddy the tin1e he needed to complete tllis book.
I would like to thank n1y father and 111y 1not11er. God rest her soul, for teaching ine the
fo11itude and resilience, and for raising nle -vvith the values of hard \VOrk and the i1nportance
of a strong fan1ily. They are both an inspiration to n1e every day. I \vould also like to thank
my sister Sru1di. she 11as al\vays inspired me to be strong, keep persevering in the hardest tin1es. to love life and be
tn1e to yourself.
I would like to thank t11e SAPIEN tea.in, Ferdinand Rios (CEO). David Corrales (Lead Engineer), and Alexander
Riedel (CTO). All of \Vho1n \Vere insllumental in revie,ving the 1naterial in Ulis book. I 'vould especial1y like to
thaJtk, David Co1TaJes, \Vho always took the ti1ne to a1lS\ver n1y inany questions, and never failed to offer n1e as
1nuch guidance as I needed on tllis quest. Special thanks as \Veil to Alexa11der Riedel, for taking the time when I first
started approaching this book to speak ' vith me on many occasions.
A special thanks to Don Jones. a legend in the Po,verShell conununity ru1d a superb aut11or in his O\Vll right. Don
revie"ved this book and provided his great teclurical insights, he \vas al,vays \villing to put on his author hat and give
ine constructive advice \Vhich \Vas instn1mental in helping get this book out the door! Don Jones is one of the \Vorld's
leading expe11 on the Microsoft business technology platforn1. He's the author of more thai1 45 books ai1d the
President/CEO of Po,verShell.org.
Thanks lo J11ne Blender. who didn' t even kno'v n1e when I first contacted her to ask for her expert opi1rion and
advise for tJlis book. She \vitJ1out hesitation gladly offered to review tl1e book for 1ne. For ai1yone that does not know
Jm1e Blender, she is a Microsoft MVP, a for1ner Senior Programming Writer at Microsoft Corporation \Vhere she
worked on tl1e Po,verShell Tea1n developing the help system and 'vriting the Get-help help topics for Po\verShell
1.0 to 3.0. Her other "vorks incl1tde writing content for t11e Azure Active Directory SDK, Azure Po~erShell Help.
Windo'~'S Driver Kits, Windo\vs Suppo1t Tools, ru1d Windo"vs Resol1rce Kits. Jtme currently 'vorks at SAPIEN as
a technology evangelist ru1d trail1er.
About the Author
Jeff Holder bas over three decades of eA'J)erience as a Senior Level Systems Ad1ninistrator specializing in
Virtualization and Remote System Mai1age111ent. Prior to that, Jeff proudly served in the U.S. Naval service aboard
the U.S.S. Le,;vis and Clark ai1d U.S .S. Pe11nsylvania Submarines, as a Navigation Electronics Technician. Over the
last 30 years, Jeff has achieved a broad range of experience. and filled ma11y roles as an Active Directory Architect,
V111ware Virtualization Specialist, Cisco Unified Communications System SME. PowerShell Script Developer, and
author of five technical and outdoor books.
In his free ti1ne, he enjoys spending time \.Vith his family and the outdoors. As an avid angler. he can regularly be
found in and around the lakes of Southern California, or hiking in the surrounding inountains. Jeff and Kathleen
have been married for 13 wonde1ful years, and have nvo children together, Haley and Matthew.
Contents
GETTING STARTED WITH POWERS HELL STU 010 ............................... 15
1.1 WHATS NEW IN POWERSHELL STUDIO 2017 ..................................... ............ ... ....................~ 16
1. 1. 1 Updated Control Helper Functions................................................................................... 16
1. 1.2 Updated Editor Font and Coloring Settings Dialog ..................................... ................. .. 16
1. 1.3 New Office 2016 Themes ...................... ............................................................................. 17
1. 1.4 Prima/Sense Performance Improvement ......................................................................... 18
1.2 REQUIREMENTS............................................................................................................................... 19
1.3 INSTA LL_ATION ......................................................................... ......................................................... 19
1.4 FIREWALL CONSIDERATIONS ........................................................................................................ 20
1.5 ACTIVATE YOUR LICENSE ..................................................................... ......................................... 21
1.6 DEACTIVATELICENSE .................................................................................................................... 21
1. 7 OPTIONS AND CUSTOMIZATION .................................................................................................. 24
1.7. 1 General Settings.............................................................. ........ ........ ..... .................... .... ....... 24
1.7.2 Backup Settings ..... ............................................................................... .. .. ........................ ... 26
1.7.3 Console Settings.... ......................... ........ ................................. ............. ............................... 27
1.7.4 Debugger Settings .............................................................................................................. 28
1.7.5 Designer Settings................................................................................................. ............. ... 29
1.7.6 Ed it or Settings .......................................................................... ............................................ 32
1.7.7 Assemblies Settings ............... ............................................................... ................. .............. 40
1.7.8 Formatting Settings ................................ .... ......................................................................... 40
1.7.9 Panel Settings ...................................................................................................................... 48
1.7. 10 PowerShell Settings ........................................................................................................... 49
1.7. 1 l Source Control Settings ....... .... ......................................................................................... 50
IND EX ....................................................................................... 54 7
Chapter 1
POWERSHELL SrUJDIO
Po,verShell Studio is a product of SAPIEN Technologies, Inc.. and is one of tlle most premier Integrated
De elopment Environments (IDE) designed for Windo,vs Po"verShell scripting. It combines the po,ver of a fully-
featured Windo,vs Po,verSlleU editor \.vilh a robust fean1re-rich GUI Designer, and U1e u1ost po,verful Sc1ipl
Debugger available today.
Fe\v \Vit:hin the Po,verShell co1mnunity have not heard the naines Don Jones. Jeff Hicks, Jason Helrnick, all of,vhich
\>Vere fom1er SAPIEN ernployees. David Corrales is currenUy the Lead Developer for SAPIEN a11d June Blender is
currently a SAPIEN technical trainer ai1d "''rote the original Po,verSbell help files \Vb.en she \vorked on the Windo,vs
PowerShell team. All legends with the PowerShell Comnu1nity, and they have all \Yorked to make Po"erShell
Studio what it is today. an amazing Integrated Development Environment. b1Ult by scripters fo r scripters!
That \.Vas almost l 1 years ago, and since that tin1e Po,verShell has contir1ued to evolve and gro\v into \.\bat today is
one of t11e most po,verful scripting languages used by System Adnunistrators. On August 20 16, Microsoft
announced that Po,verShell had gone open-source ai1d cross-platfonn \ith support for Windo\VS. OS X, CentOS.
and Ublffitu. It wasn't long after the source code for PowerShell 'vas published on GitHub, that PowerShell Core
was born \hich nms 011 .NET Core and " 'ill start shlppit1g \Vith 1Windows Seiver 2016 Nru10 Server.
Windo\vs Po,verShell has quickly over the years become the de-facto scripting language for Windo\VS system
inanagement among ad1ninistrators \vorld-\vide. Today, Po,verShell has become a must-kno,_.,. skillset. and is one of
the first skills that an employer looks for"\\hen filling any IT System Ad1ninistration position.
System Ad1ninistrators have been creating Po,verShell scripts for years and they proved to be very efficient, Yery
reliable, and provided consistent results. The only do";nside " as that many of the scripts were complex,, and \Vithout
scripting kno,vledge it \Vas difficult for other employees to use them. including IT Helpdesks.
Thankfully \Vith PowerShell St11dio, very po,:verful complex Po,verShell scripts can no\v be integrated \Vithin a user-
friendly GUI application that requires Little if any scripting kno,vJedge to use.
You can do,vnload a fully functional. 45-day free tiial by visiting SAPIEN Po,verShell Studio hon1e page. Current
licensed cost is $389 wiU1 co1rununity suppo11, an addjtional $99 gets you Premium Support (Direct tech11ical
support frorn SAPIEN 'viU1 a guaranteed response tin1e of 24 hours).
Whenever you see this icon in the book it means that SAPIEN has created a Spotlight article on their
0-.. \vebsite for the topic. look in the footnotes for reference to the page.
Upon activation of Po"1erSheJl Studio, you 'vill also receive access to lhe free con1pJin1ental)1 Productivity Pack
\vllich includes:
PowerRegEx: Po,..verRegEx allo,vs you lo export your expression for Po,~erShell use.
Po,verSbell HeJp: Get help for Po,verShell U1e \Vay it \Vas meant to be.
Po\l erShcU Profile Editor: is a dedicated tool for J.lllU1aging and editing PowerShell profiles.
1
PrimaJPad: single file, color coding editor for VB Script, Jscript, HTML. C++. C#, SQL and Po,verShell .
1 https://en.wikipedia.org/wiki/Windows_Server_2016# Nano_Server
16 I PowerShell Studio - A Comprehensive Guide
In the process of vvriting this book, SAPIEN released PowerShell Studio 2017, so I feel it is in1portant to point out
the nevv changes to you. SAPIEN doesn't wait to release major updates only once a year, instead they release the1n
as they are ready \Vhich gives you the ability to receive improvements and new feah1res withot1t having to wait
long pe1iods or purchase the latest major version release.
-~
-oop-Label
_ _ _ _ _.,, L
~-------
AaBbCcXxVyZz J
0( I ~ J
figure 1 - Font and Color Settings
PowerShell Studio - Introducing PowerShell Studio 17
..
-- - -- - -
JI
..... ....
... _
____________ ...................
-
... --
-------- .
I> -
~
.._
'ii
n - o -
-- ---... ~ ,. -
~-
,
Cl-
, "' "-
-
o-
-
.,_
.. ..
t
:)
. . ._....... --
.... ......
0--
--
-.
--
........
.........
WI b :ez a
-"""'
--C
......
--
.....
......... --_
-
~
..........
..................
-~
..._.._. .
- ....
............
~,_
._.
,. ,J_.__,
.,,,._...
'
.,,...
.,.~
- ..
''==
..,,,,...,
,,,_...._
..... --
..,.,,.........
.,.~
,,,,
.........
.....,:
., ____
,_...a..
,,,._
.,......
';.~~=~.~l"!;;':::::'.5 " - -
. ~ ....... ,........... ~
- ... ...... - .-.
Figure 2 - Office 2016 Colorful
- - r-
-- ,,_ _
_.._.
_
_ __ -
................................... .__ ,
--~..,_.~~ .......
--
..,,.,.......
...
..,,._.,_
~
..
,......................
.,....
.,.~
"':::::
,.,,
.r......
T
Pri1na1Sense response time vvith this release has been improved. You may notice the improvement \Vhen triggering
PrilnalSense for .NET Types or when using general code completion.
fAbandonedMutexExc,pt1on
~ AccessedlhroughProp,rtyAttribut'
4$ Accessibl'bjttt
AccessRul'
AccessRu1,1
AccessViolationE.xc,ption
.. Ac,Enumerator
C...... Action
C Action 1
-
::; Action 10
1.2 REQUIREMENTS
As with every software there are minilnum reco1nmended requirements for installing PowerShell Studio:
Windovvs Server 2008 R2 I Windows Server 2012 I Windows Server 2012 R2 or Windows 7 I Windows 8
I Windows 8.1 I Windovvs 10, 32-bit ai1d 64-bit versions are supported.
200MB free disk space
2GBRAM
Processor capable of running Windows 7
.NET Fra1nework 4.5
Visual Studio 2012 Runtime
These are the niinimum requirement recommendations, ho111ever siniply having the mininium does not niean
PowerShell Studio, or any soff:l11are for that niatter, will operate at its peak performance. I recommend a
niinimum ofat least J6GB ofRAM to prevent issues ltllith application freezing and out ofn2en2ory errors.
1.3 INSTALLATION
TYJ>ical
Reco1mnended for most users, it vvill install PowerShell Studio 2016, the component library, ScriptMerge
2016, the MS Chart Controls, the SAPIEN Docu1nent Explorer, and both the 32- and 64-bit versions of
Visual C++.
Custom
Tllis option alJows you to select whlch features to install. This option is recommended only for advanced
users since portions of Po,verShell Studio n1ay not be available if you do not select the appropriate
components at thls point.
Complete
Tllis option \Vill install all components, na1nely, PowerShell Studio 2016, the co1nponent library,
ScriptMerge 2016, the MS Chart Controls, the SAPIEN Document Explorer, and both the 32- and 64-bit
versions of Visual C++.
There have been instances 111here Jv!cAfee Anti-Virus produces a false positive for Trojan detection
specifzcallywith the.files (Win32.exe). These files can safely be excluded, and SAPIEN typically reports
these false positives to McAfee for updating their scanning engine and DAT files.
20 I PowerShell Studio - A Comprehensive Guide
PowerShell Studio can install a small service to support the Re1note Script Execution Engine. This can result in a
fire"vall ,;vanling as the service atte1npts to open the port it listens on. The ports are configurable in the options under
debugger.
PowerShell Studio occasionally atte1npts to access a text file located on the sapien.co1n web site. Tllis text file
contains the version nu1nber of the current version of PowerShell Studio; your firewall software 1nay wan1 you when
Po,;verShell Studio attempts to read this file for the first time. PowerShell Studio does not trans1nit any personally-
identifiable information when 1naking tllis check-its sole purpose is to notify you when updates are available.
Many people have asked me how ca11 they add tllis type of update checking into their own GUI application, this is
ho"v:
First, create an index.ht1nl file within a folder on your website. Inside the Index.htinl enter only your latest version
nu1nber for your application (ex. 2.2.1), or whatever specific wording you want to check for.
1 Try
2 {
3 # Reference the folder location of the index.html file on your webserver.
4 $URL= http://www.poshcamp.com/update/
5 # Here we issue a request to check the URL and read the content in the
index.html file.
6 $data= lnvoke-WebRequest -Uri $URL
7
8 If ($data -notmatch "2.2. 1")
9 {
10 # If the version number online does not match 2.2.1 then we can either
issue a Notifylcon, set a picture visible about update available, or any other process you would
like to execute here.
11 $update_pic.Visible =$tru e
12 }
13 else
14 {
15 # If the versions are the same then we do nothing, in this case I am
simply making sure my update picture is not visible.
16 $update_pic.Visible =$false
17 }
18 }
19 catch
20 {
21 # If the website is unavailable or there is not internet connection we can do
nothing or you can execute any process that you like here.
22 $update_pic.Visible = $false
23 }
PowerShell Studio - Introducing PowerShell Studio I 21
PovverShell Studio also accesses the Web to display its product registration page (after initial installation), and to
display Web pages "vhen you click on links in the Info Browser.
Eacl1 license allows nvo activations, this is great especially if you do a lot of work from home as "vell, because it
will allow you to have PowerShell Studio on both your 'vork co1nputer and ho111e computer.
You 1'11ill not need to enter the SAPIEN ID or PasStt1ord ifyou are doing an offline activation.
Offline Activation - If you are unable to activation your licensed copy of PowerShell Studio online, possibly due
to network restrictions, you can request an offline activation k~ey. Log in to your account on SAPIEN' s \Vebsite, go
to "My Account/Registered Products", on the right side of the page look for the link "Click to request an offline
key". You will need to fill out a standard contact form, along with an explanation of why you need to activate
offline.
M any governnient restrictions do not allow online application registering/licensing and require ofjline keys. The
process is very si'tnple, contact SAPIEN to request an of/line key, they norrnally resp onded liVithin nzinutes l11ith an
email and an offline activation key will show up l11ithin your Registered Software Subscriptions page. We could only
wish that M icrosoft 's Ojjline Activation could be so sin1ple.
Ok, you 're thinking "Why would you ever \ant to deactivate your license?" One such t:ilne 1night be if you've
gotten a ne"v co1nputer and you want to install your copy of Po"verShell Sn1dio. You would first need to deactivate
your license to do this.
REAL-WORLD SCENARIOS
1. Your company purchased several licenses and employees created th eir Ol-Vn accounts on SAPIEN and
activated licenses untler those accounts, but one or more of those team members are no longer vith the
company, can you reuse those activations? Yes, it is possible, you should send the license infonuation to
sales@.sapien.com and eA']Jlain your issue, they 'vill discuss yotu options witl1 you.
2. You had PolverShell Studio installed on your computer but the hard drive crashed anti you ctmnot deactivate
it? Contact support at SAPIEN, they will be able to reset one of your activations for you.
22 I PowerShell Studio - A Comprehensive Guide
1. Click on the License information in the top right of the Po,verShell Studio application.
Product 5<.wort
Ill iSJ Project Cl q x li S~t DaQe X
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
G"'""""' Cl q x
[ t)r.l
Ir p
~
Enter ~t to sear<ll
, [iii l <OITl'IY
b) Globols.psl
PowerShell
SAPI EN
2016
Bl
Bl
Morl'orm.psf
~.psf
fil Stor!IC>.pss
aa~~IJ
STU DION
Bl M alnForm.esf
.,,,.-... SAPIEN Savings For Military Personnel
Bi
&l
MainForm.psf
MalnForm.psf
-
11/13/2016
ii
iii
SAPIEN Information Center-Articles vou may
have missed
G
y l'I_,_
(ii Snit>Oe!S
Cl x
-
MainForm.psf 11/2/2016
Ent,., ll!Xt :o stard .. p
t1J About Tqxs Bl M alnForro.psf 4/12/2016 ii Are you SAPIEN MVP material? Aeply here!
v Mlsc
lrdJde
.e i'l
I
Core Cmde!S MainForm.psl 11/13/2016
.r;-.... Bl Fade In Form.pH ii
Are you headed to Microsoft Ignite 2016?
Mv SAPIEN license Is expiring. No, it's not!
'"--.nc!ExteF-
File Pa~ F:\SAPtEN',.,oae: Shel St
' r; Appx Bl Oemo-FolderTreeView.psf Nim! StarluP."'
> (; Si!STr.,,.r.r ~Keyboard Shortcuts in PowerShell Studio Refe-~Nam
r. OmCmde!S Bl M alnForm.psf
r; Oore<tAcce<.aen~.
r; ""' Enable WMI Explorer Remote Connection
' r.
Permissions
DmOlont
September Online Savings
r. Even tTr~t
r. llSAOmonm
' r.; International View all articles related to this product
license information x
If you have ao.rrent s.bsaipbon rurber, Qlellse entl!r or paste yru riformationll the lieldsbelow.
SAPIB'l ID: Cr~ale ocr:IU!t..
Password:
tntlSeno:
Nole: SAP!!;N ID Olld 1>4S$W01d are not re<>ed when en~ .., offtrie .node key.
![ De~alekense ]
Prior to version 5.3. 131 you could click on the "About" icon in the top right of the Po'\overShell Studio '\-Vindow.
PowerShel l Stud io - Introducing PowerShell Studio I 23
The "deactivate license " button and "copy info ,, button 111ere removed 1iVith the release ofversion 5.3. 131
1. Select your PowerShell Studio license fro1n the list of SAPIEN products. All SAJPIEN products that are
currently installed \vill be listed so be sure that you select the PowerShell Studio installation.
PowerShell
STUDIO..
2016
SAPIEN PowerShel Studio 2016 1hs product is licensed
Version 5. 2.129 Jeff
Copyright 2010-2016
---- ---
Select License
SAPIEN Tec:Mologies, Inc.
__ ... -
PowerSheJ Stuc:&o 2016 I _t: v- - Copy Info
ProductMty Pack 2016
SAPfEN Sofuvare Slite 2016 Trial Expred
\11/amuig: This computer program rs protected by copyright law and intemabonal treaties.
Unauthorized reproduction or distnbution of this program, or any porbon of 1t, may result in severe
dVi and 0'1mll'lal penalbes, and wil be proseruted to the
maxirrum extent possible under the law.
PowerShel Studio uses a subset of the \VIX Toolset to create MSI insta!er databases. The
complete \VIX Toolset rs open source and can be dov-.'nloaded from http://V\'ixtoolset.org.
,,- - - - - - L J
I
Deactivate LJCense OK
'
2. Click " Deactivate License". Now you are free to install and activate SAPIEN PowerShell Studio on
another co1nputer using your original license information.
Console
r Alow nU~ instances ~ Show the doa.ment selector when navigall"lg tabs
~~
Defa!At Fies Directory: C:';.Jsers\Jeff'4)ocunents\SAPIEN'PowerShel Stuclio\"ies I Q
Deraut Project Directory: C: VJsers \Jeff'4)ocunents\SAPiB"'fowerShel StudioV>ro.iects
I
Template Directory: C:VJsers\)eff\App()ata~oasmg\SAPiB"'fowerShel Stuclio 201J .J
I
It can take a lot of time to get your environrnenf..just the way that you like it, and it would be very
disheartening to have something happen and lose your configuration. The configuration A.ML files are
stored at the locations listed below; it is highly recommended that you keep a copy these files in a safe
place.
Load Settings - this can be used to loading a previously saved settings XML file. *You will need to restart the
application after loading the XML file(s).
26 I PowerShell Studio - A Comprehensive Guide
I-
Restore Points
v' Create a restore po11t as soon .-s a file is modified.
Ver~ecal
Panels
Q
When you close PowerShell Studio, restore points 1'vill be removed.
AaBbCCXXYyZZ
Ecitllf
Assel'rbM!s
Formattr.g
Panels
PowerShel
Sou'a Control
Font
Sets yotrr preferred font for the PowerShell console.
Test Color, Size, Bold, Italic
Configures the display properties of the PowerShell console.
Enable enhanced console input line
Creates a separate input box to type, instead of typing directly into the console.
!l!console Cl x
These settings configure the net\;vork ports that PowerShell Studio uses to connect to a remote installation of the
Remote Scripting Execution Engine. You inust use the same port nu1nbers on any computer that you want to support
t11e re1note execution. When deciding on which ports to use, it is important to consult your network and security
tea1ns, as they will be able to advise you which ports are safe to use and, if required, reconfigure any firewalls. Port
nu1nbers are specified in the registry on a machine that is running the RSEE service.
8adoJp
RSEERe~: '
9988 J:] RSEE S""9:
L 9987 tJ
1
E<lt<>r
FocmattJng
....
PrinlllS=e
P~s
PowerShel
S<lurce Centro!
"
The key is HKEY _LOCAL_MACHINE\Software\Policies\SAPIEN. The Value name is InPort (for the inco1ning
port) and OutPort (for the outgoing port). Note that these values are most easily configured by means of a Group
Policy Object (GPO), SAPIEN can provide a template (ADM file) that cai1 be imported into a GPO to configure
RSEE.
The Re1note Script Execution Engine (RSEE) is an enterprise-level remote script execution enviromnent. It
consists of two components: The client, which is built into PowerShell St11dio, and a remote service that must be
deployed to each co1nputer where you will re1notely run scripts. RSEE is capable of deploying a script fron1 within
Po,verShe11 Studio out to remote computers where the script is executed, and bringing the scripts' output and results
back to Po,verShell Studio for your review.
RSEE is a co111plex tool and it interacts closely \-Vith Windows' security subsyste1ns. RSEE is recom1nended for use
only by experienced Windows administrators \-vho fully understand service deploy1nent and management, cross-
co1nputer security and authentication and, in the case of do1nain environments, Group Policy objects and Active
Directory administration. Apart from the guidelines in this manual, SAPIEN Teclmologies cannot assist you \.Yith
security issues caused by improper configuration nor can we assist with Active Directory, Group Policy, or local
coinputer config11ration tasks. See section 1.7 for details on RSEE.
PowerShell Studio - Introducing PowerShell Studio I 29
Con.sole Control Setttigs
v Sync event names 'Nith control v InsertTOOO comments 11 new events
\21 Sync control names with text 0 Insert end of event comments
Designer .::J Automaticaly insert defatJt events ~Insert control helper fl.rictions
I Editor Export
;2] Embed recovery data 11 exported scripts -iY Enable PowerShel V2 assembly compatibility.
Assembles .
- Formattng
'
Source fies
- PnmalSense j
DefatJt action for SOtXce file loads:
Panels
-
PowerShel
Source Control
Layout Mode
Governs ho"v controls are aligned when added to a fonn.
o SnapLines
Allo\.vs you to precisely align controls. As you move a control around on a form, snap lines will
appear that show how the control aligns with its neighbors.
o Snap to Grid
Aligns controls to a grid overlaid on the fonn. You can increase or decrease the grid size to suit
your needs using the Grid Size.
o Insert
Will auton1atically recreate the event handler code.
o Remove
Will delete the event binding from the control properties.
Insert TODO comments in events
When enabled, Po,verShell Studio will add a comment to each event handler reminding you to provide
your code body.
Insert end of event comments
Adds a cormnent at the end of each event handler.
Insert control helper functions
Uncheck this option to prevent PowerShell Studio fro m inserting control helper functions into the script
Sync event names with control
Event handler names are generated using the pattern $<control name>_ <event name>. This option
ensures that when you rename a control its event handlers are also renained.
Sync control names \Vith text
Event handler names are generated using the pattern $<control name>_ <event name>. This option
ensures that when you rename a control its event handlers are also renained.
Automatically Insert Default Event
Many controls have a default event (click for a button, selected index changed for a Con1b0Box). This
option will ensure that the default event is always coru1ected to an event handler when you add a control
to a form.
Embed Recovery Data in Ex1lorted Scritlts
Enabling this option allows PowerShell Studio to add extra metadata to an exported script that allovvs it
to recreate the original project that was used to create the export. The recovery data is stored in multi-line
comment blocks in the exported script.
This also applies to recove1y of the original package script file (.pfs) \Vith its assembly references and
packager settings (excluding security information).
The data recovery feature also applies to projects as well. If all t.he vital information has not been altered
or removed, PowerShell Studio \Vill be able to recover the original project files fro1n the exported script.
PowerShel l Stud io - Introducing PowerShell Studio I 31
In the past if a user had exported a GUI script but had misplaced or lost the original form file (.pff) then
the form would to be recreated manually and event scripts pasted into the new form. This cm1 no"v be
avoided by enabling this feature.
[ Yes =i No
If the file contains recovery data, you will also get a second prompt asking if you vvish
to use the recovery data to reconstruct the original files.
Figure 17 - Recovery
Ths frle was elll)Olted ftOlll a SOU"Ce ~ bl.c ~ SOlJ'Ce fie v.as not f0!6ld
Do you wish to -d f the ~file?
Fie ~b'rlc
L1. Modf.ed ?
l.Dc:IJlion C Uses :b\Doc:uners\SAPIEtl\PoweShell S."Udo
2"'2\Plqects'a;>at
Ye. II No
I Sou"ce Conb"ol
Analysis
" Automaticaly analyze saipts on 1U1
23125 !G $buttonScanIPRange_Click = {~
231261 ~
23127 I I function Invoke- TSPingSweep~
23128 1$ > {~
23129 1 -~
231301 -- Param (~
~:~~~I
> -->[ para~eter (Mandatory= $true, ~
23133 1
--->
> --> > > Position = 0 ) ] ~
[ValidatePattern ( "\b\d{l, 3}\ . \d{l, 3}\. \d{l, 3}\. \d{l, 3}\b" ) ] ~
23134! --->[string ] $StartAddress ,~
23135 1 --->[ parameter (Ma ndatory = $true ,~
231361 ) >- > ) Po s ition = l ) ] ~
!
23137 1 ) ) - > [ValidatePattern ( "\b\d{l, 3}\ . \d{l, 3}\ . \d{l, 3}\. \d{l, 3}\b" ) ] ~
23138 ! ) >-[string]$EndAddress ,~
23139 1 ---[switch]$ResolveHost ,~
231401I
) - - > [switch)$ScanPort, ~
~~~!!I
[switch]$ResolveHost,
I
[switch]$ScanPort,
231261 GdItem
23127 1of2 Get Item (Path! <StringU> (Filttr <String>l (-lnclud <Stringll >) (Exclude <String[)>) (force} fCredontial <PSCredontial> J fUseT.. nsadion) fStroam <StringD>) f<CommonParamottrs> J
23128 Pross TAB to onttr paramoters.
23129 Pross Shift+ TAB to onttr mandatory parameters only.
"\31 , , ,
This will allow you to display and cycle through the co1mnand's parameter sets. Once you find the para1neter set
that you \!Vant you can press [TAB] to auto-insert them into the cofillnand.
PowerShell Studio - Introducing PowerShell Studio I 35
j i
!.................................................................................................................................................................................. ...................................................................................................................................................................................................................... ~...................................................................................................................!
Po"verShell Studio is very versatile when it comes to design customization, whether you like more traditional color
sty les or you have a unique flair of your own, it can be tailored to fit almost ai1yone's style. The Editor Font ai1d
Color Settings gives you the opportunity to show off your personal style by customizing the font and colors of
PowerShell Studio' s Editor.
, Number
Loop LabeJ
~~~~~~~~-v~
I AaBbCcXxYyZz
i
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
~ ~
If you are 1nore traditional or don't have the ti1ne to configure the Editor Font and Colors then you can select from
a preset list of the1nes, enabling you to quickly change the current color theme.
Syntax Colomg
Display ttems: Item foreground:
Aias
Code Sll!ppet F1eld
"l i- 192, o, o
If you spend hours staring at a co1nputer screen, you 1night find that the dark schen1e is much easier on your eyes.
~
2J128
2-!129 function Il"tvottTSP-tngs.e-cp
2Jll0 (
2StSJ
21112
' p.,.. (
231)) (PA<'611W-te (MAndatory Strue ,
nu Position >l
231)5 [valtd..t.l"P 4tt~Ml(.\b\d{1.J)\.\d(l.l)\.\d{l.J}\.\d{1.l)\b.)J
Zlll6 [ttrln1}SS t41"'t.Addre,.s,
2)1J7 c~ ra.-..ttf" (Mandatory Strue,
23111 Position 1)]
231)9 [Vall(latl!';i ("lb\d(l,))\.\d(l.l)\.\d(l,l)\.\d(l,l}lb")J
2314'0 [ strlllg]SfndAddl"'es,.
I (1wit<hJSRosolveHo,t,
""
21142
23141
[w!t<h]SScanPol"'t,
[int()JSPorts ... f( 21, 22, 21, S3, 69, 71. '8, 98, 118, tl9, 111, )89, 443, 445, 1080, 1431, 2001, 2M9, :9001, :9118, S222, '66?, 6868, 777?, 7811, SINO, 1S21, !J.06, :9189, S881~
2)144 [lnt)ST .t.eou"t 100
2J14S )
23146 ~11in
23147 (
21148 Spina '4.cwObJt Sy,.t.e-.Het, tlcC.Ol"'kinforNtion, Ptn1
2J149 )
2JJS.0 Pre<"'~
2l1Sl
2.31S2
lllSJ
' (
SrichtutboxS1.A4>?tndText("S<anning IP Ran~ 'n"')
Srlc;ht~bodl.Refl"'eSh()
2315-< [Syste..WindoMs.fOras.ApplicatlOft]:1Do.EYents()
2JJSS forc~c;h (S in (SStill"'tAckktts.Split( ... )[It} $!n6Addrtts.Split( ){t] ))
2s1se ) (
231S7 forcac
L, l-\.l c-. >
W hen you select a preset, the font and coloring settings are updated to the predefined preset. Silnply click the Apply
button and PowerShell Studio will use the ne' v coloril1g scheme. You ca11 also create your own presets and share
the1n with your colleagues if you wish. Si1nply configure the coloring setting and then press the Save As Preset ...
button. You will be presented vvith a Save As dialog.
,
Down-. ... r.i.- f)ll<
t; Otopt>o. (SAPUll.
.... C>.ctUlts
.._. RTAC6'W
~ s.ics {U:..pc) ..,
Give the preset a name and press the Save button. Now the preset will be displayed in tl1e drop-down list:
Ordct
~
~'fd\'lotd
Ooera:or
Y'ari-'11""'
1-&rb:r
SIMO u-oti
Co "ieilt
Fune \'IOI ~=
Poron:!=r
CO'l't'l\at'd As ?111an"eti!f
Codie Snooet f,ecf A4BbCcXxVyZ:
I fitJ'Wl'i:cd Reftf C"ICC
Type -
B.esCCfeOefaJts J
j i
!.................................................................................................................................................................................. ...................................................................................................................................................................................................................... ~...................................................................................................................!
You can quickly wrap selected text in the editor in brackets, quotes, braces, or parentheses, by using the shortcut
keys below.
1. 7. 7 Assemblies Settings
+ -
-----1 ran mscori:>, Version=4.0.0.0, Oibse=neutral, Pub&d<eyToken=bnaSc56.193'te089
Console tJil System, VerS10n=4.0.0.0, CUlbse=neutral, PubkKeyToken=bnaSc561934e089
tJil System.\ftftndows.Forms, Veroon=4.0.0.0, Culture=neutral, Pub6d<eyToken=bnaSc561934e089
Debugger tJil System.Data, Version=4.0.0.0, Culbse=neutral, Pubid<eyToken=bnaSc561934e089
tJil System.Drawv;g, Version=4.0.0.0, CUlture=neutral, Pubhd<eyToken=b03fSf7flldSOa3a
tJil System.Xml, Version=4.0.0.0, Culbse=neutral, Pubbd<eyToken=bnaSc561934e089
tJil System.Core, Version=4.0.0.0, CUlhxe=neutral, Pubid<eyToken=bnaSc561934e089
Assemblies
Formatting
Panels
PowerShel
Sotrce Control
These asse1nblies are used to prov ide Pri1nalSense support for Types and .NET objects. You can add assemblies to
the Default Asse1nblies to ensure that they are loaded every ti1ne PowerShell Studio is started.
Have you ever tried copying/pasting code from the Inten1et or a docu1nent but it never seems to indent correctly in
code editors? PowerShell Studio takes care of this for you by auto1natically formatting pasted code. You can even
custonrize the formatting to fit your own needs.
There are two sections in Fom1atting settings, the first options serve as triggers for auto fonnatting, these tell
PowerShell Sn1dio "when" to fonnat your script. The second set of options tell PowerShell Stl1dio "how" to fonnat
your scripts.
PowerShell Studio - Introducing PowerShell Studio I 41
General Tnggers
~ Automabcaly format statement on new ine Z Automaticaly format statement on ;
~ Automabcaly format completed blodc on} ~ Automabcaly format on paste
Console
Rl Automabcaly l'ldent new fines
Formatting
Debugger
../ Place open brace on a new line ~ Leave block on the same ine
Designer ~Place statement keyword on a new line D Insert new line after Parameter type
P' Insert new line after Parameter attribute ~ Automabcaly expand aSases
../ Align parameter arguments on &ne continue 0 Convert curly quotes to straight quotes
Assemb6es Parameter ine spacing (0 disabled):
L
Formatting Parameter blodc indent: [ 1 :1
Attribute parameter indent: [ 2 j ]V Arigo attribute parameters
Panels
PowerShel
Sotxce Control
Formatting Rules
The second set of options allows you to custo1nize the fonnatting rules of Po"verShell St11dio 2015.
Enabled Disabled
~ (" lue) I (S .. .&. ... e) (
( Out Dctoult 'Tr~c
Oot-Dcfnolt 'Tn:c' }
i el~e {
else Out Dcroult .olsc
( )
Out-Dc!ault 'Fcl~c
)
Figure 31 - Before
figure 32 - After
Enabled
-
,.. t
Disabled
-... ' .
Enabled
! ($v lu
Ou De ul 'T:n;c'
}
l~ (
out I>crault ' .. lsc'
}
Disabled
.,.
- ($valu
Ou Oct olt 'True'
) l (
Out- ult I: l '
44 I PowerShell Studio - A Comprehensive Guide
Before
se Para (
51 [ .. t (Position 1, ~ndatory = Strue)]{ ~li ( ol ) ]
SJ. [syst ,,... "'. 0 s.oa .... tion.C ing. JSC:hartCo'ltrol,
53 [Para .. ( Position 2, tandatory Strue)}
5 .: $XPoint~ ,
After
50f Param (
511 ( Para~eter ( Position = 1, Mandatory = $true)]
S2 i [Alias ( 'Control' )]
5 3i [System. \Jindo\'IS. Forms. DataVisualization. Charting. Chart ]
i
54 j $ChartControl ,
Before After
..,
.:9 ;i (
.m lo.tdllyC~1rt - 48
49
Sil
{
, Lol<lllyChrt
Por ( I
Sil Pa (
Sl [ (Posit ion 1, 144...Satory Svuc )) Sl (Por.o&e (Poltion I, x.ndotory Stt"U<"))
;,(. Sl [Alles( I ))
S2 [ >I (Sys te-.1111\dCo. o .oatavi~uli.ation.Chlrting.Chart )
S3
s.:
[Sy> ~ rOf"P'~ O.~eVi ul~ tlO<l.C .4' .ing.Ch1rt) S3
s SChor tCont rol ,
SChartContro1,
SS (Par t (Position 2, X.t>datory St rue) J SS
56 SXPoints, 56 [ P.r (Position 2, X.ndotory Struc))
5' (Pa r - (Posi tion 3, Kandatory Stru.-)) 57 SJCPoit1ts ,
58 SYPolnts, sa
59 (Pa (Position ' X.ndatory Sfalse) l S9 (Par (Position 3, x.ndatory Struc))
68 ( st ini; ) 68 SYPo!nH,
61 SXT!tl .-, 61
62 ( P (Position 5, ll.lndatory Sfohc) ) 62 (Par (Position , Xandatory Sfals.e))
61 [ st ini.J 63 [strina)
64 SYT!tl~ 64 SXTitt.-,
Indent 1
J~uncc1on V'~:-b-Neun (
Per
(
(Pa- ~c- (Ma~dat o:y ~t:-~e ,
POS1t10~ 0,
P.clpXc:s:saoc pr ctcr l '
) )
( Vcl1dat: .iot:.lullO:!:ttpt: () J
iS&::-l.nQ' )~Pa'!'aml
)
)
Indent 2
l'" unctl.on :~:-b-.~oun (
P4r
(
( Pc.a: "'tC!' (~c~d<tt O:-y
Posltl.o~ 0,
- -
c ....u-..
Enabled
P4r
(
( Pa!'~ e- (~a~d 4t o:y St- ,
Pos1t1on o,
!-!clp!~c:s:sac;c Por ctcr l '
))
r i1d te: t.: i10:.:r.pt c>i
(Strino JSPa'!'aml
)
46 I PowerShell Studio - A Comprehensive Guide
Disabled
!uncc1on ;e:b-.:cu~ ( ,.
Por
(
( Pa: ~ter (~o~d~to:y St:. ,
Pos1c1on o,
HclpXe33aoc 'Poraccccr l'
) )
( ..olldate.' t ullO.!:n:;pt ())
fSt:rl.nQ )SPa:::aml
)
~~~~~~~~~~~~~~~~~~~~~~-
< >
Enabled
if ($value) { Out-Default 'True' }
else { Out -OeLault 'False' }
Enabled
if ($value)
{
Out-Default 'True'
}
else
{
Out-Default 'False'
}
Enabled
Get- Process "ame 'PowerShell Studio'
Disabled
ps !lame 'PowerShell Studio'
Enabled
Out -Default "Curley Quotes"
Disabled
Out -Default "Curley Quotes"
48 I PowerShell Studio - A Comprehensive Guide
I Bad<up
L ResetQuickAccessToobar J
- Panel Layout
L.:._onsole ../ Automabcaly show output panels when text is displayed.
Panels
Snippet Browser
Show Schemas
This setting configures how the object browser displays schen1a information from SQL server. If it is
cleared, then the object browser will ignore schema infon11ation and display database tables, stored
procedures etc. in a silnple flat list. Enabling Shovv Sche1na \\1ill cause the object browser to display
database objects in their respective sche1nas.
Cache all fields
This setting will cache everything within the database browser, for quick loading of recently used
information. Checking this option will take 1nore tin1e to load because it is caching everything upon start-
up.
Custom Directory
Adds an eA1ra folder to the snippet browser panel. You can provide a network path here to create your
own shared snippet repository.
Assemblies Password: _J
Formatting Tme Stamp URL: [httP:fltmestamp.globalsign.com/S01Pts/tmstamp.dl ~
PnmalSense
External Signing Tool: [ ""]
(Using an external tool wi override all other settings.
Solxce Contr:;l
General Settings
I
../ Enable source control ~ Prompt for check Ill
I Providers
I
1
I
I
I
Foonattng
PnmalSense
I
i
I
Panels
I
i
I
I
I
I
2
Before configuring PowerShell Studio for source control, you must install your source control sofuvare's client.
Check the Enable Source Control checkbox to enable source control. Note that your somce control provider must
be displayed in tl1e Provider list; if it is no~ then source control is not properly installed and will not be available to
PowerShell Studio.
PowerShell Studio will auto111atically detect tl1e presence of the sotrrce control client and auton1atically display it in
the Providers list box. If your source control client does not appear in this box, tl1en shutdown Po"verShell Studio
and it should appear on restart, if it does not then this likely meru.1s that you do not have the source provider properly
installed and configured, or it is not a SSAPI-compat:ible client.
GIT Source Control does not have a SSAPl-cornp atible client and y ou nzust use custonz nienus to use GIT
ivith Po111erShell Studio, 111e discuss this further in 2.2.5.
After enabling sotrrce control, you can configure the options however you like, including pron1pting before checking
files out and automatic check-in options.
Automatic Check In
This controls check in behavio r ru.1d has follo\.ving two options:
o Disable automatic check in
Leaves you to decide when files should be checked in.
o Check in when a file is closed
Auto1nates the check iI1 process.
Chee){ Out On Edit
This co11trols check out behavior and has the follo,ving tvvo options:
o Automatically check out
PowerShell Studio 'vill check a file out as soon as you edit the file.
o Prompt for check out
Po\verShell Studio \Vill display a file chooser dialog in wllich you can choose the files you wish
to check out. The file you are curre11tly atte1nptiJ1g to edit \ill auton1atically be selected.
Providers
Displays the list of available sotrrce control providers and allo,vs the user to s\vitch between the1n.
52 I PowerShell Studio - A Comprehensive Guide
Chapter 2
'
..
11!81 =
PowerShell Studio - Basic Orientation I 55
BASIC ORIENTATION
You can't get somewhere if you don' t lrnow the way. Before we get down to the meat of building forms and
projects it is extremely important that you have a good tinderstanding of the layout PowerShell Studio, after all you
wouldn't go hiking out in the woods without knowing where you are going right? It is amazing how many users
hardly get past using the controls in the toolbox, wl1en there are so many great features that are being missed. This
book is going to take you tlrrough all of the1n!
Ok. so you 've fired up PovverShell Studio for the first time and you are staring at the screen wondering "Ok, ' vhere
do I start first?" . This book is a perfect start, so keep on reading! SAPIEN also did a great job adding a lot nlformation
right into PowerShell Studio \Vitl1 tl1e Docu1nent Explorer.
- 0 x
Smr&um
[ii t<oodv
~-''
i!i'j --.pc1
liill .,_.,.....,
rms...........
2018
Recently Opened
iJ ......
EiJ
Ml!inl'on.!kl!lf
Malnf9rm.oI ..... ii SAPIEN S..vtngs f0< Military Pe~onnel
SAPIEN ln(ormaHM Center- AnlcJes vau may
BJ Mainfom>.psf 11/13/2016 a !!.!.."" mlsst~
liappv ~taflaween from WIEN
Cii'J 1est.p<I ii
SAPIEN Sctlpt Pat:kattr u?sf.ates and rrew
p
iJ Mainf9nn.p~I U/2/2016
features.
En'erir lll:)t :0 ~Oldt
' E1J /ol>out TOfllC$ . /ill Malnl'ontt,psf
BJ Mainl'otm.psf
o/12/2016 ii Art you SAPIEN MVP materlf? Apply henil
v HIM:
e
,A
eot"t Oldct$
r. HodtJres I BJ Fjld~ In f!m!!Rlf ......
U/13/2016 Ar@ you headed rq Micro<olt Ignite 2016? "" \'dt' ~fb
Fk F~it: !C:\S.l:OtN'Pcoc91e1St
fiAl>'l'x
Bi Qgmo-fold!rTuVl~l!M!~f ...... Mv SAPIEN License I exolrlna. No, It's nGt!
t~ S:.n,ci.ro
r; !liUlransfl!:r
' r; Cir6det:s
r. OJ~teotr.:i..
SJ Malnform.psf ...". ii
New Keybo.ird Shortcuts In PoYA?IShefl Studio
2016 Re~et~N#ft
- - 1- 1-
-
r. In.ttrnellOnd
...-~
I l4YOU~
AsJtolayGUl
Vle.w all artJcles related U? thls oroduct
1. From Po\verShell St11dio, navigate to the Help tab on the top ribbon bar.
2. On the far left under the Product Support category, click Product Manual.
3. This will open the SAPIEN Docrunent Explorer.
The SAPIEN Document E~rploter is packed with a plethora of information including PowerShell c1ndlet definitions,
Modules PowerShell Studio manuals and guides, Training Videos, Links to online communities and other
resoltrces, and tbe latest articles.
One of the features of the Docunient Explorer that you 111ill find very useful is the ability to add your 0111n notes
directly within the Document Explorer.
56 I PowerShell Studio - A Comprehensive Guide
There are also hundreds of script samples for Po\verShell, VB Script, Po\verShell Studio GUis and more. This is a
great \vay to get your feet \.Vet in understanding ho\v PowerShell Sh1dio functions.
f Ii
Manuals
S ~ PowerShell Studio 2016
Installation
1
.~ Introduction All SAPIEN TectmoJogies software prooucts are do1m1oadable only. Once a customer
I ~ Getting Started registers or updates a product on my.sapien.com, the download screen appears. Tne
1i'J
Basic Orientation Installer sonware is saved as SPS155etup_xxx.exe to your default download folder. Upon
-s1
The Script Ed~or
f-1i'J
~ Running and Otbu99in9 Scripts
1 .
The GUI Oesigntt
$j Pow01Shll Studio Panes
execution. tne Installation wiZarel first cnecl<S several items sucn as avaJlable CllSK space anel
existence of previous builds. If tile environment Is adequate. tl'le installer will display the legal
aoreement wl'licl'l vou must acceot In order to orocee<l. At anv ooint In tl'le orocess. vou mav
v
1
~ Projocts
Advanced Features and Curtomization
Sourct Control lntogration
1i'J
Packa.ging Scripts
~1i'J Comparing and Muging Files with ScriptMorg
t ~ Th SAPIEN Document Exploror
1i'J
Th Romote Script Exe<ution Engine
~ The Snippet Editor
:ij SAPIEN Update Tool
~
1i'J
Keyboard Shortcuts
. (C) Quick Guides
@Shortcuts
~ 111! Videos
Iii Articles ...
~
Ho'v much space does the Document Explorer consume? Not as much as you nti.ght think. The software installer
contains about 99 files and consumes about 7.82 lvIB , we ll worth the small amount of space it consumes.
What if I want to remove the Document Explorer?
You can uninstall SAPIEN Document Explorer fro1n your con1puter by using the Add/Re1nove Prograin feature in
the Windo"v's Control Panel.
1. On the Start menu (for Windo\vs 8, right-click the screen's botto1n-left comer), click Control Panel, and
then, under Prograins, do one of the following:
o Windows Vista/7/8: Click Uninstall a Program.
o Windows XP: Click Add or Re1nove Prognuns.
2. When you find t11e prograin SAPIEN Document Explorer, click it, ru1d then do one of the following:
o Windows Vista/7/8: Click U niI1stall.
o Windo\vs XP: Click tl1e Remove or Change/Remove tab (to the right of the. progra1n).
3. Follo"v the prompts. A progress bar shows you how long it will take to remove SAPIEN Docu1nent
Explorer.
PowerShell Studio - Basic Orientation I 57
x
m
Settings 0
People 112 KB
Home Microsoft Corporation 11/4/2016
m
Microsoft Corporation 11/23/2016
System 112 MB
Power2Go
Cyberlink Corp. 12/15/2011
0
-
Display
B PowerlSO
Power Software Ltd
8.07 MB
9/22/2016
- Apps & features
-
::::. Default apps
Iii SAPIEN Document Explorer 2016 7.B2 MB
m
SAPIEN Technolog1es, Inc. 11/3/2016
m
SAPIEN Technologies, Inc. 11/3/2016
(') Power & sleep
SAPIEN PowerShell Studio 2016 74.7 MB
SAPIEN Technologies, Inc. 11/20/2016
= Storage
D SAPIEN ScriptMerge 2016
SAPIEN Technologies. Inc.
7.BO MB
11/3/2016
m.? Offiine maps
Q3
B SAPIEN Updates 484 KB
m
Tablet mode SAPIEN Technologies, Inc. 11/3/2016
The Ribbon Bar is located at the top and spans the entire width of PowerShell Studio, you will find seven tabs
located along the ribbon bar which \Ve will discuss in greater detail here.
c--
llll
- ...,_,,. OdOW DtdoY Toc;t SMeeeont'd riiilb 'flit'lt
a 'l.:i"9 ..... - . ......._ ~ -.. 1:i ll CJw . ...-~. .. - r:t .. li'f'tWM :.. .., QI- ~ ......
- -
~ I U fS nat ... V1\11'1 ..l> @t1m .,...._..
lt#l'IOOI ,..., II "-~ ~- .. a - ~ Wllllt " t~t~
....,.-'4
""" _ Ir
.. ~ .,,. ~ c.- . o-.
QlloCQP <J!O ll ~- ..._.
...I ., t ' ...
Contains the functions used 1nost often while scripting, it is the default tab in PowerShell Studio.
Paste: used for pasting code into the editor from Windows clipboard.
[~ Copy
L~ Copy HTML Copy: copies selected code to the Windo,vs clipboard.
Paste
~Cut
Copy HTML: copies selected code and fonnats it within HTML code. If you blog,
C pboard
this will quickly become your most used tool, it provides pe1fectly fonnatted HTML
including color coding and formatting.
Cut: copies the selected code to tl1e Windows clipboard and removes tl1e selected code from the editor.
58 I PowerShell Studio - A Comprehensive G uide
i
,., -
......... .................................................................,...._ ,,,,................................................................................ .. ................................,_ ,,,.................................................................................................,_,,,.................................................................,_ ,,................... ...............................................................,_,_ ,,,, ...............i
~.-- ~
Version and Platform : Po\verShell is available in both 32-bit and 64-bit platforms, you. can choose \vhich
Po,verShell versio11 is reqt1ired for your script ai1d platfonn require111ent. In tl1e exainple on the left PowerShell
version 5 ai1d 32-bit platfonn are selected.
Depending on the version of PowerSbell that you have itlStalled on your system that you are running PowerShell
Studio on are the versions that will show as choices. If you are miming Windows 10 you will likely notice that you
sl1ow VS (32 and 64) available, why not V3 or V4? That is because \vhen the PowerShell version is upgraded the
previous versions are uninstalled and i10 longer available.
~ Platform
in elevated mode. The Platform 1nenu provides elevated, and non-elevated,
n1odes for script execution.
rLocal f\1achine
Local Cache: refreshes the local cache of PowerShell cn1dlets and
nlodules. If you edit any 1nodules that yot1 have already loaded, like
ra vs - 32Bit \I rena1ning a function or editing the contents within a module, you should
refresh yotu local cache or the changes made to the module \ill not be
0 >=< available for use because once the mod1tle is loaded the locally cached copy
is used.
Local Machine IvI Edit Cache: add/remove 1nodules that are included it1 the cache proftle.
Once clicked a nevv \Vindo\i\1 will open showing all the current modules,
g vs - 32 Btt \I and \Vhetl1er they are part of the current cache profile. 1f you \Vant to add
a module to the current cache profile, check the box neA.1 to the desired
0 ~ n i +d f8 11! module, 1mcheck to remove from the current cache profile.
Ptatform
PowerShell Studio - Basic Orientation I 59
f.Y Powe.Shell Cache Editor x
~ter: local MclcHne v
---'
Cliche: Power5hel64VS v
I ~
~
MoQJe Version Oesa1>bon "
0 Ac:tiveOl'ecmry 1.0.0.0
E2l AwBad<9'0l.ndraslc 1.0.0.0
O~ocker 2.0.0.0
E2J Appx 2.0.0.0
0 AssignedAccess 1.0.0.0
0 AIVSPowerShel 3.1.qLO
0 AZ\xeRM.proNe o.o
0 BestPractices 1.0
0 &lgWafpaper 1.1.2
E2l Bitl.ocker 1.0.0.0
0 ElitsTransfer 1.0.0.0
E2J ElctsTransfer 2.0.0.0
Oar~ i.o.o.o
0 CinCtrdets 1.0.0.0
0 Olrix.common.Comm<lnds 1.3.0.0
0 Otrix.Common.GtoupPolicy l.S.O.O
0 Olrix.XenApp.Cornm<inds 6.5.0.0
0 Defender 1.0
E2J DrectAccessOentCo111p01 ients 1.0.0.0
0 Dism 2.0
0 Dism 3.0
0 DnsOent 1.0.0.0
0EventTr~t 1.0.0.0
n fU'ICtioosModUe 2 1.0.0.0 v
< >
-
Local Machine Iv I Import Remote Cache: Imports an Installed Module Set (IMS) exported
on another computer. One of the challenges you face while developing any
g vs - 32 Bit II
\I PowerShell script is that 1nodules that reside on your target platfonn are
not available on your local computer. See References section for details on
0 >e< G ~ ~:J Fe II exporting and importing reniote cache.
Platform ~
Local Mactune E dit Remote Connection : edit the remote cacihe 's connection settings.
These settings define the type of re1note co1mection you want to use, either
lg VS - 32 Bit \I Windows PowerShell Ren1oting or RSEE Remoting. Windows
PowerShell Re1noting 1nay require usenlalne/password credentials, RSEE
0 >e< G ~ +~
does not require credentials but the RSEE service must be rumling on the
Platform remote target syste1n. See the R eferences section for niore information.
Local Madtne Remote Console: this will open a re1note console to the selected
n1achine (requires Windows Remoting). This f eature will not work ifyou
Ef VS - 32 B1t \I
are using RSEE as a reniote connection type.
0 < G ~ +~ E6
Platform
rt
60 I PowerShell Studio - A Comprehensive Guide
; .-
~ ............................................................................................................................................................................................................................................................,........... ,........................................................................................,...................................................................................................,...............................................................t
~Debug .. ~ Step Into . Run (Ctrl+F5): Executes the current docu1nent or project and
I> ---t>
Run
Remote ... C=- Step Over
displays the results in the Output pane. Run creates a ne'v session
that never includes local artifacts, like your Windows PowerShell
Stop t StepOut profile, or session-specific items, like variables, and then runs the
script in the clean-slate session.
I> Run Ctrl+FS
Run in Console (Ctrl+Shift+F5): Executes the script or project in a
J
mt Run in Console Ctrl+F8
console session and displays the results in the Console pane. The Run
9...
.
-i Run Selection Shift+F8 in Console feature doesn't just run a script in the Console pane - it
~~ : Run Selection in Console F8
dot-sources it. Dot-sourcing adds the items in the script scope,
.J
including function, script-scoped variables, classes, and workflo,vs,
to the console, so they 're available even after the script completes.
Previe"' (Shift+F4)
Allows you to see how a form \Vill appear on the screen without the need to run any code.
DEBUGGING
Debug (FS): Debugs the current script or project.
~ Debug I:=. Step :nto ~un To Cursor Run Remotely (Ctrl+R): Uses PowerShell Remoting to
execute your script or project on another machine. Results
Run -~
I> Remote
Run Remo e1y
G- Step Over 11 Break
F6
will be displayed in the Output pane.
l:>: Run Remotely RSEE Shift+F6 Run Remotely RSEE (C.t rl+Shift+R): Uses the SAPIEN
__ Debug Remotely Ctrl+ F6 Remote Script Execution Engine to execute your file on
another inachine. See References section for more.
~-
GUI scripts cannot be run re1notely.
Debug Remotely (Ctrl+B): Debugs the current script or project on a re1note system. Results \Vill be displayed in
tl1e Output pane and Debug pane.
PowerShell Studio - Basic Orientation I 61
PowerShell Studio also offers the ability to debug a script in elevated mode by setting the appropriate platform
setting as described above. The script will run nom1ally with output, captured to the Output tab, until a breakpoint
is reached. A yellow arrow in the margin of the code \vindo\v indicates the next line of code that "vill be executed.
~ Step Into + Run To Cursor Step Into: executes the next statement and then stops.
Ste1> Out: Steps out of the current function; up one level if nested. If in the n1ain body, it continues to the end or
the next breakpoint. The skipped statements are executed, but not stepped through.
Run to Cursor: runs the script to the line containing the cursor.
BREAKPOINTS
Toggle Breakpoint F9 Breakpoints instruct the debugger to stop on a specified line
Enao1e I Disable Breakpoint Shift+ F9 of code. This allo"vs you time to revie"v \vhat the script is
doiI1g at that point. To set a breakpoint, place your cursor on
ft Delete All Breakpoints Ctrl + Shift+ F9 the desired line and either press F9 or choose the Toggle
0 Disable All Breakpoints Breakpoint button from the Break Points menu in the Debug
section of the Ho1ne ribbon tab.
Set Variable Breakpoint .. .
Active breakpoints are displayed as solid red circles in the
G Set Function Breakpoint .. . margin of the code editor \vindow . Disabled breakpoints are
I r:; Edit Breakpoints... displayed as red rings.
Once a breakpoint is set, you can disable or delete it by using the Breakpoints menu or pressing F9 to toggle through
the options. You can also right click on the code editor to access the Breakpoints menu.
TRACEPOINTS
llJ Toggle Tracepoint Ctrl + F9 A Tracepoint causes PowerShell Studio to \Vrite a 1nessage to
the debug windovv when a specific line of code is executed.
C Delete All Tracepoints Ctrl + Alt + F9
Tracepoints appear as solid blue circles in the code editor
margin:
62 I PowerShell Studio - A Comprehensive Guide
23188 1I Begin
23189 1~ {
231901 $ping = New-Object System. Net . Networkinforrriation.Pi ng
23191 1 }
23192 ~ Process
23193 1- {
:
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!~
~
alJ Find /Replace t:I Edit Parameters Find/Replace: as the name indicates this tools \Vill find and/or replace
text within the editor.
~ Format Script iJl1 Assemb es
O Functions -- ":=. '9:
Format Script used to beautify your script by fonnatting it to standard ~
script fonnatting. This will not expand aliases, if you \-Vant to expai1d all
Edit
aliases within your script; press [Ctrl + Shift+ A]. This will help you
elit11inate errors by good fonnatting, and makes your scripts more professional.
Edit Parameters: better known as the Parameter Builder, used to insert a ne\v para1neter block or edit existing
script paran1eters.
Those familiar with the Function Builder will recognize the sinlilarities between the two tools, except for the Name
portion of the builder. Othenvise the Parameter Builder ai1d the Function Builder share the same functionality .
PowerShell Studio - Basic Orientation I 63
Parameter Builder x
Hame: ? Parameter Sets: ?
'
OutputTviie
SynopslS: ? I
~arameter Edtor Test _]
Descnptlon: ?
Default Parameter Set: ?
L
Cmdlet Binding: ? Parameters: ?
!l.:J I
Parameter Set Filter: (Show All) I
Cnn '"'!>&"
Name Tviie Pos M
~
Posi~
S<.wort!Pagirig
' Name
Coop.ster
stnno
stmg
0 i'!'.i
'I'
0 j,.i
)(
)(
S<.wortsShoiJcl>rocess 0
Confrnnlmpact
Oetena ies whether p~ au:oma~v P<Ol11Dts u:;ers fur conmnabcn
befure nrnng the nsxbOl'I bv ~ the SConl'mPrefere>n shell
-.able lJr..e " " - the flTICton has a pe1'l\Clllel't ~ suet- a!: deleting
rl L
Output Type: ?
After entering your parameter information, click " OK", the resulting code will be inserted into the editor for you,
see below.
2 - <#
3 .SYNOPSIS
4 Parameter Editor Test
5
6 .DESCRIPTION
7 Used for deat0nstarting t he use of the Parameter Editor
8
9 . PARAMETER t~ame
10 A description of the Name parameter.
11
12 PARAMETER Cornputer
13 A description of the Computer parameter.
14
15 .EXAMPLE
16 PS C:\> -tlame 'Valuel' -Computer 'Value2'
17
18 . NOTES
19 Additional information about t he file.
20 #>
21 para11
22 (
23 [Para~eter(~landatory Strue)]
24 (str ing)$Name,
25 ( Parameter(Mandatory $true) ]
26 (str ing)SComputer
27 )
Para1neter options can be set by clicking on the options button for each parameter:
64 I PowerShell Studio - A Comprehensive Guide
Paramtttr Build~ x
fQme: ? Parameter Sets: ?
Synopsis:
------~
? t:
Oescnptlon: ?
Cmdlet 8111d1ng:
J ?
Default Parameter Set
Paran1eters:
?
?
I
--
~ Parameter Set filter. (Show All) I
onfi ~
Type Po< M
Parameter x
Parameter flame: ? Ahas: ?
J
Description: ? Default Value: ?
fy~ ? Validation: ?
Switch Parameter [ Add_ _
Parameter Set: ?
I Remove
[Settings:
[ Add
Rcr
?
...
v Misc
~
Mandatory True
Poslbon
Vallefr~
Vakiefr~yPropei
VaiJefromRemanngArQIJT
HelpMessage
A short descnpbon of the parameter
Figure 41 - Parameter
PowerShell Studio - Basic Orientation I 65
Comments and Regions: These tools are used to cormnent or unco1rnnent selected line of code, or perfonn region
functions as discussed below:
,' ~
I \
,'
I
I
. ' '
I
I
I
\
\
\
Comment L nes
Block Comment ' ''\ I
Uncomment L nea Region Functions
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................,
;.-
I NAVIGATION l
!t.......................... .. . ........ ..... .............. ......... ... ....... .. . ........ ..... ... ................ ....... ...... . .. . .. . ............ . ............ ........... ....... .. .. .... ........ .................. ........ . ...... .. . .. . ......................... ........... ...... . .. . ..... ... ..... .......................... . ......... .. . ....................... ..... ..... ... ...... . ........ ... . .... ............. ................... . ........ ................... ......... ... ...... .. .......... ............ ..,!
Previous Last Edit Previous Change: navigates to your previous change within the active
document.
@Next - ' Bookmark
1+ ~1 Go To Line
+-* 4 Previous Function : navigates to the previous function from the current
location in the active document.
NaVigabon
Previous Occurrence: navigates to the first previous occurrence matching the selected text in the active
documented.
Next Change: navigates to your next change from the current location within the active document.
Next Function: navigates to the next function declaration from the current location in the active docu1nent.
Next Occurrence: navigates to the next occurrence 1natching the selected text in the active docu1nent.
Go To Line: ju1nps to any specific line you enter within the current active document.
Last Edit: Goes to the position of the last edit that was 1nade to the current active docmnent.
Clear all Bookmarks: exactly as it says, it will clear all book1narks within the current active document.
Previous/Next Bookmark: jump backward and forward to the next book1nark in the active docu1nent.
66 I PowerShell Studio - A Comprehensive Guide
i
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
~ ~
-1 Package L:!J Bud all This section contains conunonly used deployment tools from building
packages, i.e .. EXE files, to creating installer files i.e .. MSI files, to deploy1nent
ifb Installer Glj CdnceJ b d methods such as CD/DVD or Email.
llY
::=;t
Deploy ...
Deploy
Build: this will create an executable (EXE) from the active document.
Build and Run : this does the same as Build and will rm1 the executable.
Run: this will nm the executable for the current active document.
Run
Settings Settings: this is pai1 of the Script Packager settings which are discussed in
greater detail in a later chapter.
U1 Package L:!J Buld aD Build: this will create an installer file (MSI) from the active doctunent.
Uninstall: uninstalls the application for the active document if installed and
Install
versions 1natch.
Settings: this is part of the MSI settings which are discussed in greater detail
~ Settings in a later chapter.
DeJlloy: deploys the files for tl1e active doct1ment and executes the associated
iP Package L!:J Buld a! co1nmands.
i~ Insta er ~ cancet ouild
,, Send To: sends a compressed archive of the deployment files for the active
CY Deploy ...
document to ai1 email recipient.
@. Deploy Ctrl+ Shift+ F7
H~l Send to ... Copy to CD/DVD: bums the deploy1nent files for the active document to a
CD/DVD.
(j Copy to CD/ DVD
ay Settings Setting: this is part of the Deployment Settings which are discussed in greater
detail in a later chapter.
PowerShell Studio - Basic Orientation I 67
iiJ Package tt:J Bud a!l Build all: builds the packager, MSI installer and runs the deploy
co1mnands.
~-
If;;, Insta er f;=j cancel b d
CY Deploy
Cancel build: cancels a running build co1nmand.
Deploy
68 I PowerShell Studio - A Comprehensive Guide
i
.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
~ ~
:) Start Page
Start Page: opens the SAPIEN Po\verShell Studio start page.
f~T Opbons
ITJ Panels O)ltions: opens the Po,verShell Studio options page.
I':. Call Stack Panels: There are 16 different panels to select from that will be used during fonn
II Console designer, scriptiJ1g, and debugging.
lllJlti-- Debug Panels that are highlighted in blue are currently being displayed already. Simply
click to display a pai1el, and click again to hide the pai1el.
[i] Debug Console
IA Find Results Keep in miJ.1d that it is best to only open the panels that you need at the tiine for
what you are working on, this will minimize clutter and 1nini.J.nize the ainoru1t of
I0 I Function Explorer men1oiy that is beiI1g used for each open pa11el.
~Help *The performance panel is available with version 5.3. 130 at1d later.
~ Object Browser
[] Output
I~ Performance
IBID Project
[Il Property
I~ Snippets
lt;'; JToolbox
ii Variables
60 Watch
-
!fli I) . g . ""' 0 "' ni
.. -
R
~ ~ ''
Pastie
Ooboo<d
l:Q"""
""C>""'
~
r:::;i
Pt~
-
GUI
-
gg 561 ..
)( Ocl<tt
&it
Todo
il -- . . . . . .
ScuttC>""'
s- -""' m
-':I _...,,,. .;. -
..... Y-
C,...,..,.
m"'""""'"
:O s.nToC>Od-
JI 5'n: To eon -
S:o
... .."""""""~
T~vr!'tal~e
lJ C.OIC< "'"""'""" ... ""'1 To "'""
lJ Ccnlc1 """""' 'la SmHo Bod<
[!]
>Dfly
PY'apefty Set
~ 0 .... -.nvs.1
fj; o ..,.eon... s.t
6] Cteott Form Tendb-tc
,........
~
"'...
At.ftrenct.
t<elp
The designer tab contains functions related to forms 1nat1ipulation and creation.
PowerShell Studio - Basic Orientation I 69
j i
!.................................................................................................................................................................................. ...................................................................................................................................................................................................................... ~...................................................................................................................!
Paste: this "vill past object(s) iI1 the Windows clipboard to the current form with the form
[~Copy
designer.
~ ~Cut
Paste
Copy: used to copy a selected object(s) within the form designer to the Windows clipboard.
C pboard
Cut: used to cut a selected object(s) from the current fonn "vithin tbe fonn designer to the
Windows clipboard.
: !
f..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................!
Preview GUI: allows you to preview the design of the GUI \Vithout runnit1g any scripts within the
GUI.
Preview
GUI
Preview
1.........."......"........"''.....................................................,.._..................................................-................................................................................................... t
It...............................
EDIT ...............................................................................................................................................................................................................................................................,_,,........................................................................................................................................................................................................!I
)( Deete Delete: deletes all selected controls on the active form. *Be careful with this one, luckily there
is an UNDO button!
Ecit
,.i ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................,i
IE- Align Lefts i"f Align Tops These tools are used for aligning two or inore controls on a fonn.
Alignment
70 I PowerShell Studio - A Comprehensive Guide
i
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
~ ~
r, These tools are stated to be used for resizing a control to its content. However, I've
r..J Size to Control
also noticed that it can be used to make one of inore controls all the sa1ne size. This
~ Size To Control \'Vidth depends on the order of the controls that you select.
20 Size To Control Height
Size
In this exa1nple, "ve select the smaller buttonl first, then the second button2.
Notice the first control selected is st1rrounded by a wbite box, and every
subsequent co11trol selected after it is surrounded by a black box.
0 0- -O
O btilonl 6
d= = o = o
btilon2
-,.'
~ --- ==
o9 Form ~I I~ Click "Size to Control" ai1d notice that button2 becomes the same size as
- buttonl .
0 0 .. 0
O btilonl o
0 QC 0
---
btilon2
-=
aO Form ~I ~ I~ In this exa1nple, you will notice that buttonl is larger in height than button2.
Here \Ve have selected button2 first and button I secondly.
- =.,
! -
bt.ttonl
By doing this "ve are saying basically that "ve want button I to be like button2.
We could do the reverse by selecting the controls in the reverse order.
= == l
PowerShell Studio - Basic Orientation I 71
aC Form ~I 9 I~ If we then click on " Size to control height", notice that buttonl is now the
------== same height as button2. We can do this san1e type ofma1lipulation with "Size
to control width" .
o- o- o
o btiton2 o
o o= o
L........................................................................................................................................................................................................................................................................~........................................................................................................................~...............................................................................................................J
11U Form
""'"'
I
- -
Ji
i
r............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
B Center Honzontafty u Bnng To Front These tools are used for marupulating one or more controls on the
active form.
E8 Center VerticaDy Send To Back
-,}
_.l Tab Order
Position
72 I PowerShell Studio - A Comprehensive Guide
Center Horizontally
- - - - ~00~
aO Form aO Form
-
btitonl r btitonl
Center Vertically
aO Form aO Form
----~-
r:EJOO~
btitonl
... btitonl
Bring to Front/Bring to Back: used to bring controls in front of or behind other controls.
Tab Order: Tab Order works to help you set tl1e order in which you cru.1 tab through the form elements. This means
tl1at when you are in the form and you hit the Tab key, each ele1nent will be highlighted in a certain order.
The Tab Order button is a toggle. That nleans that one click turns it on and another tunlS it off. To display the tab
order of the form ite1ns, si.J.nply click the Tab Order button and each element on tl1e for1n will show its tab order on
the left.
- 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 O O O O H O O O O O O O O O O O O O 0 0 0 0 0 0 0 0 0 0 0 0 0 . . . . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 O o o o O O O O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 O O H 0 0 0 0 0 0 0 0 0 0 0 0 0 OOOOO O O O O 0 0 0 0 0 0 O O O O O 0 0 0 0 0 0 0 0
al Fo m
llbutton2 ]
button1 ]
Notice the tab order itself is a zero-based array. Zero is the first tab, one is the second tab, and so on and so fortl1.
To change the tab order simply click on one of the ele1nents until the nmnber you want appears. You don't have to
click on the tab order nu1nber itself, just clicking anywhere on the ele1nent will suffice. Clicking on the ele111ent
PowerShell Studio - Basic Orientation I 73
siinply cycles through the available tab orders. As you click on the ele1nent, the number \vill increase. And once
you reach the end of the available tab orders it will start back at zero.
Tab order can also be set in the control properties for each control; however, tab order is much easier
set using the Tab Order control tool.
1..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................)
Apply Prope11y Set: this will show a predetermined preset list of styles that can be applied to the control selected.
The list "vill change depending on the control selected. As seen in the exa1nples on the next page; there different
property sets for buttons a11d text boxes.
Cancel Butto n
11] Converts the button to a Cancel button with OialogReslit.
OK Button
[i]_Converts the button to a OK Button with OialogResUt.
L Show p.-operty sets for same type only I Select J Cancel I
x
Select Property Sets:
p
Andtor All Sides
00 And'lors the control on al Sides.
Ifyou modify a property set after you have applied it to controls, you must reapply it to those controls.
Your changes will not be autoniatically applied.
Create Pro1>erty Set: You can create your own property sets that encapsulate local branding requirements
or other useful settings. To do this, first set all the control properties that you want to caph1re. Then select a control
and press the Create Property Set button on the Designer ribbon or press Ctrl+Shift+L.
Create Property Set x
Ten1plate Source: Select Properties:
Sbuttonl: System. Windows.Forms.Button [E 1.1:1 .~11.1. t ~ u
. Description:
0 Backgroundlmagelayout
[1 CausesVaidation
of the property set. 0 ContextMenuStrip
D arsor
v
Create I[ Cancel J
figure 44 - Create Property Set
When the " Create Property Set Ten1plate" dialog appears, select the properties that should be captured by tl1e
property set. Use the Limit to: selector to specify whether yo1rr new property set can be used vvith any control, or
only controls that are the sa1ne type as the source control. You nlust also add a description before you can save the
PowerShell Studio - Basic Orientation I 75
new property set. The next time you apply a property set, your new property set "vill appear in the list of possible
choices.
There is currently no way to alter a property set. They must be re-created and re-applied to the control.
Maybe this is a feature that will be included in a future version release.
Control Sets: In the saine way that property sets allow you to group together property settings for reuse, control
sets allow you to combine 1nultiple controls and script code into new custom controls that can be added to forms
just like standard controls.
Creating your own control sets is another great way to build reusable components for your scripting tasks.
Start by adding controls to a fonn, configuring their properties, and writing all the code required to inake your new
control set function correctly. Once done, select all the controls that are to be included in the control set and press
Ctrl+T or right click on the code editor pane ai1d choose Create Control Set.
Creator Name: ~
Company: [AAMs, Inc.
Control Set Description:
' lnsert a Chart that displays rurnng processes when a button is pressed.
Control Insertion:
Control Action
cancel _J Next
The Create Control Set dialog allows you to set the properties of your new custom control. On the General tab:
Control Icon
Choose the icon you would like to associate "vith you control when it is displayed in the toolbox.
Creator Name
Enter your name; tl1e default value for this field is taken from your SAPIEN license.
76 I PowerShell Studio - A Comprehensive Guide
Company
Enter your company name; the default value for this field is taken fro1n your SAPIEN license.
Control Set Description
Provide a description of your control set.
Control Insertion
If you have included any non-visual controls you can use the Control Insertion section to define what
happens whe11 your custon1 control is added to a fonn. You have three choices as described below.
a. Always add the non-visual control
If you add your ne\.v custom control to a fonn that already has a control called timerl on it
PowerShell studio will renrune the new timer and modify the code in your custom control to use
the ne"v naine.
b. Use existing type
If the destination form already has a control of the same type (Timer in the exa1nple) then
PowerShell Studio \.Vill not add a ne\.v control but rather 1nodify the code to refer to the existing
control.
c. Use existing type (match name)
If the destination fonn already has a control of the same type (Ti1ner in the exa1nple) and the
name 1natches tl1e nrune in your custo1n control PowerShell studio will behave as in b - i.e. use
the existing control. If the names do not match, then PowerShell Studio will add everything in
your custom control to the fonn i.e. it \.Vill behave as in a.
Wl1en you press Next you will be taken to tl1e Functions tab \here you can choose to include ru1y functions from
your code in the template.
-.,,,-,. -
,,.,,,.-,,,.. - -- - - - - - - - -- - - - - - - x
-~
General """""""
s.Ject ~ to !nci.de (Ml1cllons ~ n ......,ts wl be """"""bC211Y nck.dtd):
Functions:
PowerShell Studio will automatically include functions that are bound to events in the control. Click on Finish
ru1d give your Control Set a na1ne. It \ill now be added to the Toolbox.
If you include an entire form in a control set, PowerShell Studio will add an extra tab to the Create Control Set
dialog.
PowerShell Studio - Basic Orientation I 77
0
Accessibility
Accessibl eDescription
" 0Behavior
Load
0 AccessibleName
0 Accessibl eRole
Appearance
0 BackColor
0 Backgroundlrnage
0 Backgroundlrnagelayoul:
0 Cursor
0 Font
0 ForeColor
0 FormBord erStyle
0 RightToleft
0 RightToleftLayoul: ...,
-< > < >
Previous l
The container tab helps you to specify which form property values and event handlers should be included in the
control set. The next time you need to use your nevv control set, simply drag it fro111 the toolbox onto a fonn.
Create Form Template: PowerShell Studio co1nes with several pre-defined templates as shown below, hovvever if
none suit your needs, you can create your ovvn.
CC' r m T.,..,plt x
Preview: Templates:
[Er x - P]
fmptyform
@J Oceatos aner.>ty Fenn
LS0oct~ I c-e J
To create a ne'v fonn template, click on the " Create Form Template ' in the Te1nplates section of the ribbon bar.
Neh't you will be presented with the Create Fom1 Ten1plate dialog:
78 I PowerShell Studio - A Comprehensive Guide
,p C> El ~
Creator: !Jeff
Company:
Oesaiption:
r
b<.Clonl
ti..c!an3
Name
Give your template a naine.
Type
PowerShell Studio supports two types of te1nplate:
o Forni teniplates
o Grid templates
If your fonn does not include a D ataGridVievv control this option will not be available
Creator
Your name. This value is taken from the U senlafile set in the General tab of the Options dialog.
Company
Your company details. This value is taken fro1n the Organization set in the General tab of the Options
dialog.
Description
A description of the purpose of the template.
Target grid
This option only appears if you are creating a grid template. In cases where a form has more than one
grid, it allo,vs you to specify which grid auto generated code will use.
Fill in tl1e form and press Save. Your ne\\1 template will novv be sho,vn whenever you create a new form, just like
the standard templates.
PowerShell Studio - Basic Orientation I 79
j i
!.................................................................................................................................................................................. ...................................................................................................................................................................................................................... ~...................................................................................................................!
~
This is a great resource for finding all the properties associated with each control in PowerShell
Studio. When you install PowerShell Studio a PDF is saved at
Control
"C:\ProgramData\SAPIEN\Docu1nent EArplorer\Content\Quick Guides\WinFonns Control
Reference Reference for PowerShell.pdf', you click on the Control Reference button or you can access the
file directly.
Help
D
~ ""'
,. 0 6(') na ....
Export Exportto
=-+ Settings
~1 Btrnd &Run
Settings
'"'' Buid
Ccl insta ~
Settings
H~J Send to .. .
to Frie C pboard Run Q Urunsta (j Copy to CO/DVD
Export Padcager Insta er Deployment
The deploy tab contains tools to create packaged executables, MSI installers and deployment procedures.
: . :
i ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................J
i
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
~ ~
.. , ~d
PowerShell Studio makes it easy to customize the executable files that you create. If
you have never used the Script Packager in PowerShell Studio, when you click
i11 Build &Run Package, PowerShell Studio opens the Packager Settings window.
Settings
Run
Packager The Script Packager contains
? !f t pd
--~' SM'lef~V3Host(CCllMlll'(llne)
(0 ~~':Ion Wl!NPawerShel Vl~ (WlidDws.Pcns)
SAPl!N~V)Hos.t~
~---! Wlef~\IStUt(CO'!'fl'lll"d...,
: MC10Door"a WIEHF'OMrShdVS'10K~,.,....,
S'l'ffH~\tSH!nl~)
You will see a list of available script engines that you can choose fro1n, first follo\v by the Po\verShell version you
\VaJlt to require, then followed by the Fonns Engine; Conm1and Line, Windows Fonns, Windows.
Command Line: executes your script in a console windovv, output can be redirected.
PowerShell Studio - Basic Orientation I 81
Windolvs Form : PowerShell only engine for Windows Forms applications. Nonnal PowerShell output is
suppressed. All user interaction must occur within the foIID. *This is tl1e type that you 'ill most likely use the most.
Windows: Yotrr script is exectrted as a Windows application ' ithout a console. h1put and output is presented as
dialogs and message boxes and cannot be redirected.
Native Windovvs Platform, \Ve will go into more details on that target selection because it can be confusing.
(SAPIEN Teclu1ologies Inc., 2016) Choosing tllis build target will put all the files in a folder called bin\Jlny
platjornt. You will get a MyApp.exe, My Appx86.exe and My Appx64.exe. Additionally, .config files are generated
for each of the1n if you checked that option. The MyAppx86 and MyAppx64 files are your actual packaged script.
The My App.exe file is a starter applicatio11 that "vill execute the right package for the current platfo1m. For your
application to work, you must install or deploy all three files together. The starter application receives the same
icon, digital signature and manifest as the packaged files, so a shortcut to that file will create the same experience.
STA (Single Threaded Apa11111ent) and MTA (Multi-Threaded Apartinent) dete1mi11e ho\v a process 1nanages legacy
COM objects and their co1nn1unication \Vith inultiple threads. I \ Vill not go into the detail, but you need not concern
yourself witb the innervvorkings of COM objects, other than to remember that STA is required for some of the GUI
controls to ft1nction correctly.
The following controls require STA 111ode. Otherwise, they do not appear.
Folderl3rowserDialog
SaveFileDialog
OpenFileDialog
STA mode is 11ot somet11ing you nonually have to consider when vvriting scripts, but it is something that you sl1ould
be a\.vare of if you are creating GUis tools. Most GUis will run fine in MTA mode, but as a rule, you should always
run yom GUI scripts in STA
82 I PowerShell Studio - A Comprehensive Guide
You can make sure that your Windows Po\verShell scripts require STA when running. If you add the
following comment to your script, PowerShell Studio and PrimalScript run the script in STA mode: #
%ForceSTA% = True
OUTPUT SETTINGS
Script Packager - test.psf x
,----
'" SO'ipt Engne
~
Engne Settings
Output file: ltest .exe
D output Sett.lg$ Output fulder:
IconF4e:
0 Exea.ibo!l Restnctions
~ Generate .config fie :J Resolve and include external saipts
re Version Information
Manfest Qeabon
= &.lld Options
[En-bed a defaUt manfest
Custom Manifest: _______________, I,.
...___ ~J
Alternate Credentials
Usemame: Password:
Sigt'wlQ
Cerbficate:
~---------~ [Q]~
PassWOl'd:
_ .dl_ _ _ _ _ _ _ _ _~
Tmestamp URL: [ht:t;>:/{bmestamp.globalsql.com/sajpts/bmStamp
OK I[ Caned
Resolve and include external scripts: A great many users indicated that they dot source files \Vith coilllnon
functions. Since these are external to a packaged script, they needed to be deployed with the executable. That created
the need to create an installer for an otherwise simple application, required a review or change of script execution
policies and, finally, opened the application up for user intervention by editing the external script files.
So SAPIEN added an option to resolve dot sourced files \vhile packaging. If the option is enaJbled, the code of the
external scripts gets injected into the packaged script when building the executable.
PowerShell Studio - Basic Orientation I 83
Files specified '\-Vith or without single and double quotes are supported. Files that do not exist will issue a
warning. If you have a dot source staten1ent inside a co1n1nent block, the file will be inserted into the
com111ent block.
Using a line comment will prevent a file fro1n being resolved.
If you need to resolve only some but not all exten1al files, you can use a different case for the file
extension.
. ./include/lib.psl \Vill be resolved by the packager,
. ./include/lib.PSI will not be resolved.
Manifest Creation: Options for the 1nanifest file, including a custo1n 1nanifest.
(This is an executable manifest, not a Windows PowerShell 1nodule manifest.)
Alternate Credentials: Uses the credentials of the specified user to run the scripts in the executable file .
Signing: For script signing I recommend that you read "Script Signing Made Simple" by Jeffery Hicks. You will
find a link to it in your "Docmnent Explorer'' under Quick Guides.
EXECUTION RESTRICTIONS
I
MadWle~: I
Oomarl: I
-
I OK I Cancel ]
The execution restrictions allow you to li1nit the environment in "vhich the package runs including; operating
systems, specific username, MAC address, Machine na1ne or do1nain.
Each field accepts se1ni-colon separation so you can restrict to 1nore than one. For exa1nple; usema1nes
"John;Bill;Ton1" would require that the logged in user be one of those listed or the user would not be able to execute
tl1e package.
The sa1ne goes for MAC address, Machine name, and
Do1nain.
VERSION INFORMATION
ra VetSIOO Information
Company: ARMS, Inc.
=
I,_
Buid Options
Copyright:
Internal Name:
.---
I
Copyright (c} 2016 Al r9Jts reserved
Comnent:
L OK JI cancel
Most of these fields will not be a surprise if you have ever worked with any applications. The file version requires
a for1nat of x.x.x.x, this inean you must supply a four-digit version nu1nber such as; 2.2. 1.0
If you are familiar with Visual Basic, " Auto-incren1ent file version" vvill not be new to you. If you enable this
feature each ti1ne that you build your package it '1vill auto-increment the package version.
~
~
.,.
'W
Scripter on vacation!
86 I PowerShell Studio - A Comprehensive Guide
BUILD OPTIONS
Script Packager test.psf x
!Pre-build commands
I
Cl Output Settngs
0 ExeaJtion Restricbons
' ra v~ "'"""boo j
= &jc!Opbofls
-
Post-build commands
I
3
If you need a pre-processor for your script or you want to do son1ething to the final executable, add your co1nmands
here. They will be executed in the sequence defined and one after another rather than in parallel.
Build: 'Build' applies all your settings and creates the actual executable file. 'Run' executes that file. If you picked
.. ~ ~d a comn1and line engine, then the package is executed in a shell \vindow. Depending
.. on the file packaged, this is eitl1er a PowerShell console or a regular cn1d \Vindow. If
~1 &nd &Run you picked a for1n or Windovvs engine, the file is executed directly.
Settings
Run Build & Run : build and run the package.
Packager Run : this will run the current package.
. ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................,,
-
..lrtl Bukl MSI Settings: provides settings 11eeded to create Windows Installer files (MSI) for
your scripts, inodules or packaged executables.
C'rj Ins tan
Settings The SAPIEN MSI Wizard uses parts of the Wi.X Toolkit to create Windows Installers.
Q Unrtstal The complete WiX Toolkit can be found here http://,viJ\.1oolset.org/
Insta er
3
https://www.sapien.com/blog/2014/03/25/fro1n-script-to-server-deploying-solutions-with-primalscript-2014-part-l/
PowerShell Studio - Basic Orientation I 87
PRODUCT SETTINGS
.
OK Cancel
Product Name: this is the name that \vill be displayed in "Progra1ns and Feattrres" after installation.
Product Version : The version nmnber. You should incre1nent that number "v henever you create a new build of your
product. The installer will use that nmnber to detenni11e if the specific product version is already installed. If it is, it
will not install. If you created an MSI with a higher nu1nber, it "vill uninstall the old version and then install the
newer one. *Notice there is no auto-incrernent file version when creating a11 MSI, as there was with creating ai1
EXE.
Company Name: tllis is the name that will be displayed in "Prograins and Featt1res" after installation.
Product Type: Yotrr selection here, together with tl1e "64 Bit installer" and "Install for all users" options detemline
\V here your files are installed.
The following table sho\vs the locations for 64-bit OS with "Install for all users" selected
-----------------------------------------
PRODUCT TYPE 32 BIT 64 BIT
Windovvs Application C:\Program Files (x86)\Product C:\Progra1n Files\Program Name
Name
Script Application C:\Program Files (x86)\Product C:\Program Files\Product Na1ne
Na1ne
PowerShell Module %Windir%\SysWOW64\ %Windir%\Syste1n32\
WindowsPowerShell\vl .O\Modules\P WindowsPowerShell\v1.O\Modules\Product
roduct Naine Name
I
88 I PowerShell Studio - A Comprehensive G uide
The folloiving table shows the locations for a 64-bit OS w ith a current user only selected
PRODUCT TYPE
- -
I 32 BIT - -
64 BIT
Windows Application C:\Program Files (x86)\f>roduct C:\Program Files\Program Name
Name
Script Application o/oHomePatho/o\Script %I-IomePath%\Sc;ript Applications\Product
Apphcations\Product Name Na1ne
Product Icon : This icon file w ill be embedded in the MSI file and shown in "Programs and Features" with your
product.
64-Bit installer: Checking this option prevents installation on 32-bit OS. It also registers COM components as 64
bit co1nponents and changes some folder na1nes as indicated earlier.
Install for all users: This \Vill install the application and its shortcuts for all users on a system . In most cases this
option \:vill require administrative privileges. It also affects the install folder location for some product types.
Require Administrator: Checking this option will cause Windows Installer to prompt for elevation on Windo,vs
Vista or higher. The type of prompt depends on your local UAC (User Access Control) settings and the currently
logged on user.
Minimum PowerShell Version required: select the 1ninimum PowerShell version that your application requires
to run, any version less than that is detected a prompt to install the 1nini1nt1111 version will be displayed and the
installation aborted.
If you use an installer prograin such as InstallShield, you can include the files for the 1ninilnu1n PowerShell version
as a prerequisite. I have also used this to install required PowerShell Modules for applications.
4
Another rather interesting method is to create an Elevated manifest.exe which copies the modules to the correct
folder. In yourpri1nary exe or application (at the very first part of your code) make an " if (!(test-path $module_path)
{start elevated.exe }" . This \.viii prompt the user \.Vith an elevated message if they \Vant to install the 1nodule. Once
it's installed once, it will bypass the elevated install next time the app is ru11 because the test-path is true.
4
https://www.sapien.com/forums/viewtopic.php?t=7894
PowerShell Studio - Basic Orientation I 89
Files: These are the files that you installed. Arrange and name them exactly as you ' vai1t tl1em installed on the target
machine. Please make sure that you don' t have any stray temporary files in this folder, because anything here will
be included in the MSI file. If you have COM object DLLs, just place tl1em here as well. They will be recognized
as such and registration information will be extracted at build ti1ne.
Create Shortcut to : Select the file you want to create a shortcut to in the Windows Start 1nenu. Currently, you can
only select one file. Typically, this is your main executable or sc1ipt file. For PowerShell modules, you can link to
the help file for example.
MSI Name: The filename for your MSI. This only affects tl1e actual MSI file and not any of the internal names.
Out 1l ut Folder: This specifies the location where you want the MSI file to be created. Do not use the staging folder
for your software for this or your previous M SI file vvill be included in the next re-build. If you have not loaded a
wizard settings file fro1n someplace else, a .1nzw file with the same base na1ne as the MSI name you specified will
be created, tl1at file contains all the setting you entered into the wizard' s dialog.
Staging Folder: This is the location of all the files that you want installed.
90 I PowerShell Studio - A Comprehensive Guide
SIGNING
I OK I[ Cancel ]
Certificate: A certificate is either code signing certificate installed in your local store or a PFX file you specify in
this fields. You can browse for a PFX file using the file browse button or using the certificate button.
Pass,vord: If you specified a PFX file for code signing it may require the use of a password. If so, please enter it
here.
Timestam1> URL: This URL is used to create a time stamp for the signature used to sign the file. Logging the time
of signing allows you MSI file's signature to re111ain valid even after the certificate expired.
Use the Signing Wizard to sign the MSI file: If your certificate does not fit the above criteria or if you need to
sign \vith a different signature each time you are building an MSI, you can use the Microsoft Signing Wizard. Any
settings entered above will be ignored and the wizard \Viii guide you through the signing process.
Build : creates the MSI installer package based on the settings you configured.
U ninstall: this will uninstall the current package installed (if it inatches the same
Insta er
version).
PowerShell Studio - Basic Orientation I 91
j i
!.................................................................................................................................................................................. .................................................................................................. .................................................................................................................... ~......................................................................................... ..........................!
Deploy: creates the deployment based on the settings that you configured.
~.Deploy
lldl Send to ... Send To : sends a compressed archive of the deployment files for the active
Settings
(j Copy to CD/DVD
docrunent to an email recipient.
Deployment
Copy to CD/DVD : bun1s the deployment files for the active docu1nent to a
CD/DVD.
Main tile to deploy: There n1ust be at least one file to deploy, fro1n the dropdown box you \.viii notice in the example
there are four selections:
None: this is the default and you cannot deploy using this selection of course.
Source Scri1Jt: this is will use your existing script file to create the deploy1nent.
Packaged Executable: this \Vill only be listed in the dropdown if you have first used the Packager to build
an executable .EXE.
Installer File: this will only be listed in the dropdown if you have first used the Installer to build a Windows
h1staller file .MSI.
Additional Files: need to add files to your deploy1nent, drag and drop them into here.
De1>loy files to: this is the location that you want your deployment saved to.
92 I PowerShell Studio - A Comprehensive Guide
Additional Deployment Commands: For the additional deployment com1nands, you can add any co.rnmand line
tools you like or need. If, for example you need to also ftp your MSI file so1ne,vhere, this would be the place to
specify that command. These commands are executed in sequence, one at a time, so make sure you have no blocking
tools in there which 'vill potentially sit all night with a dialog up, waiting for your response.
rm [j ~ . fii 0 an nl ;
-;J Home
iji Fm il Faes.. .
~]! Compare Fies
Des9'ler Deploy
~ PowerShel ~Wnter
~ VerSIOO Recal
View
EiJ PowerRe<)Ex
ti Profile Ecilxlf
a PowetSJiel Console
a PowerShel ISE
Sign Script
. ~ Custom Tool ~ Analyze Scnpt E:3 PnmalXr-t. m WMl Explorer g/ Update-Help
Fie Analys!S SAPIEN Powe:rShel
The tools tab contains functions pertaining to files, script analysis, and links to external programs.
-...........................................................................-............................................-..................................................-............................................-....................................................................................................................................................................._............................................................................-.............,
'
FILE I
........................................................................................................................................................................................... ...............................................................................................................................................................................................................................................................................................................!
~
- llti F11d in Aes... Sign Scri1>t: This will sign the active docu1nent~ however, you first need to have
configured signing in the "Packager" settings or "Installer" settings. See page 79
~ Compare Fies ai1d 87. The dropdo\vn menu also give you the option to re1nove a sig11ature.
Slgn Soipt
... ~ Custom Tool ...
Find in Files: Ho'v 1nany ti1nes have you been \vorking on something and think
File
to yourself "I know I've \Vritten something like this before but can' t reme1nber
which file it is in. This tool provides the ability to search for a string within either the current document, all open
documents, the current directory, or any directory of your choice and its sub-directories if you opt to.
Find In Files x
Find what: [i#;iii,i!it,l!i!,ij:tiJ~%i!i;:,i,!,fj------------ijr.:v:ll
fr. [2J [ Find in Res j
[ Match case [ Mab:h whole word [ CanceJ _J
Find in: [ CUrrent Document
---------~"- ...1
C Search in subfolders
File types: -*.psf, *.pss, "'.psl, "'.psdl, *.psml, *.pff, *.pfs, *.p...
~
Match Case - this is used if you \Vant to 1natch the upper/lower case in your search
Match \vhole word - by default if you do not select this option tban eacl1 word in your search string \vill return
results. In the example above the 'vords "Find",, "this", and "string" \vould each return results. If you only want to
find the whole search string "Find this striJ1g", then check this box.
PowerShell Studio - Ba sic Orientation I 93
Find in - here you can select current document, all open documents, the curre11t directory, or any directory you
choose.
Search in subfolder - this does exactly as it says and will search all subfolders beneath the 1nain p ath.
File types-this will be enabled if you selected a specific folder in the 'Find in" option. It will search.all *.psf, *.pss.
*.psl , *.psdl, *.ps1nl, *.pff, *.pfs, *.pfproj, or any files.
Use - you can use either regular expressio1is or vvildcards in you search.
Com11are Files: This uses ScriptMerge to find the differences bet1;veen the active docu1nent and whatever file you
choose. W11en you click on 'Co1npare Files" yo11 \.vill be presented with a browse file window, select the file that
you want to compare \.Vit11 yotrr current active docu1nent in PowerShell Studio. Once you select the file ScriptMerge
will open and compare the two files, highlighti11g any difference, as see in the exa1uple belo\v.
.......,,
v-.nr; ~*Cl.lc~'">bur;c~_cu~.t :c/ tvt=t> _ __
St </Objtcu - <JOb;icC"'..>
i: t-~ <Ob]Kt typee'"Syoeco.w1noov . !'ont11.eu~t.c.t1, SY>t.cis... w...1.noowa. rouu. \ 'ua1ot11 . O.o <'0.b)Kt cw--..sy~t.a.. ll:ta.c>owa. rorsq.lu:c.on. Syt.,.:.w.1: J)OO'V1t. ronu, '.'e&11an.., .{).O
s' ; <Prope.r:.y e&:c.e:toee:1.0n>14S. i2</Propcrtv> <h'OP-t"t.\ c.e.me-1.oc..r;ic:n >li S. i2</ P:os:-ut:v>
lt:t <Pi:Cpctt:.v na111c-..~:ama >euUon.?</PrQJH:tty> <Property nurion-..~o" >but:.e.e,</~roperi.y>
SCi
S4i
tl4
tr
14
<P:opc:r:.y nemtW5Jzc>70. 1~F=O.Pe~ty>
<P::oP'U'tY utlletblr:a.tu>!</Ptci>c::.y>
<~r~y ~e rt'JCt. >bU::"t.0Da</PrC;>11nv>
~''
<Propc::t.y a~5iz c >1 0, 25</P:oprtY,
<Frcpe:rt.y n-...:TobtcdeJC>1</,rope:-t.v>
<Prope:~y n.aeToxc >~t.c.on2</Propercy>
<Pro~t.Y aucUii~:a.u.t.1S;y1cli&ckeolo:>Tru~/Er~rtv>
. SY?llOP'SD
....
f'
.. </ Ob)c o;;>
<C<idc>< I fa>AfJI.[
. SYltCi'S!S
se . o.i.sca1-n10H u
Sii Ut'd t o?" dtmon:.nuo t.hc use or the P.-.taaete.r !dtt.or u
> < >
The file on the left is the cu1Tent active docu1ne11t and the file on the right is the selected file to compare it against.
Ho\.v would yol1 like to 1nerge changes from one file to a11other file? Ho"v about line by line or all difference? This
is a hidden. gem in ScriptMerge that will save you countless hours trying to compare files and copy fu1es back and
fo1th between files.
Simply select tl1e liJ1e that you \.Vant to 01erge, th.en click either
the "Right" or "Left'" button to copy the line over to the other
file, or if you want to copy all the differences folrnd just click
either the "All Right" or "All Left" bt1tto1is. It could not be any
siiupler!
If you frequently compare the same two files, you can save yo1uself a lot of ti1ue by setting up a Scripftvierge Group.
94 I PowerShell Studio - A Comprehensive Guide
If you click on the File tab in the upper left, you will see a inenu vvith some other
cool features that allow you to also co1npare folders and compare groups.
You can also edit the color options for the compare tool by using the "Settings"
option at the botto1n of the "File" tab.
Custom Tool: this is another hidden gem that I think is frequently overlooked. There is a tre1nendous ntunber of
tools available in PowerShell Studio, but we all tend to \.Vant inore don't we. SAPIEN had the forethought to add a
great little feature to allow you to build your O\.vn custo1n tools, no\.Visn't that great!
You can run al1nost any conunand, including c1nd.exe co1nmands, Windo\.vs Po,:verShell coffilnands and scripts,
and coffilnands to executable files, like robocopy .exe, netstat.exe, and git.exe.
Cmd.exe: To n1n a cominand that's internal to cmd.exe, precede the command vvith ' c1nd' or 'c1nd.exe'.
Executables : To run a com1nand in an executable file, such as robocopy .exe, git.exe, or ipconfig.exe just
type the conunand \.Vith any valid switches.
PowerShell: To rm1 Po\.verShell cmdlets, functions, or scripts, precede the coffilnand with 'po,vershell'
or 'powershell .exe'. When ruru1ing scripts, be sure to include the full path to the script file. Also, verify
that your local execution policy permits you to n1n scripts.
PowerShell Studio - Basic Orientation I 95
In the co1n1nands, in addition to using valid paraineters, arguments, and switches, you can include variables for
values that PowerShell Studio resolves before it sends the conunand to the editor.
$Pro.i ectFolder$ Path to the current project directory. Valid only when a project is open.
$PowerShell$ PowerShell version number selected on the ribbon.
$Platform$ Current platfonn (x86 or x64).
$WinDir$ Path to the Windows directory (e.g. C:\Wi_ndows).
$WinSystem$ Path to the Windo,vs syste1n directory (e.g. C:\Windo,vs\Syste1n32).
$Sele.ction$ Currently selected content, if any. Might contain carriage return/ linefeed characters.
$File$ Full path to the current file, if any.
$FileName$ Name of the current file (no path).
$FileDir$ Path to the directory of the current file (no file na1ne).
$Dir$ Full path to PowerSI1ell Studio installation directory.
$Line$ Current line number in tl1e active file.
$Col$ Current column in the active file.
You can also prompt for one parameter value ai1d create a custo1n inenu specific to a directory. I'll sho\v you how
below, but keep these features in 1nind as you dreain up your custo1n tools.
To create a custom tool, start with a text file named Custo1nMenu.inf. Place the file in the PrograinData directory
for PowerShell Studio or PrimalScript.
For exa1nple:
[Menu]
l =Command Name l ;command line 1
2=Command Name 2;command line 2
[Application]
1=Comtnand Name 1;command line 1
2=Command Name 2;conunand line 2
You can add additional numbered command lines. The nu1nbers indicate a command line. They do not determine
the order of commands in the file. If the file contains multiple command lines with the same nu1nber, only the first
one witl1 each number is effective.
96 I PowerShell Studio - A Comprehensive Guide
Examples:
5
For each conunand, enter the conunand name, a semi-colon (;), and the conunand.
For exainple, this line creates a 'Run Get-Acl' co1nmand that runs the Get-Acl cmdlet on the current file ($File$),
then formats all properties of the output in a list.
-
A Find n Ft;es ..
In the [Menu] section, add conllllands that n1n and exit, like
a PowerShell cmdlet. The custom menu waits for the conunand
~ Compare Fies to co1nplete.
Sign Script In the [AJ>plication] section, add co1nrnands that don' t exit,
Custom Tool
like a conunand that displays a file or UI that you 1night vvant to
Run Get-Acl keep open. The custo1n 1nenu runs these co1nn1a11ds and exits
without waiting for them to complete.
Open CustomMenu.inf There is a [Commandline] section that you might hear about,
however it is the saine as using [Menu] .
For example, here a co1n1nand in the [Ap1>lication] section opens the current Custo1nMenu.inffile in Notepad,
and the Run Get-ACL conunand in the [Menu] section. As you can see from the screenshot of the menu
on the previous page, the [Menu] section and (Application] section are auton1atically separated by a
line .
[n1enu]
1=Run Get-Acl;povvershell Get-Acl -Path $File$ I Format-List -Property *
[Application]
l=Open CustomMenu.inf;Notepad 'C:\Progranillata\SAPIEN\PowerShell Studio 2016\CustoinMenu.inf'
5 https://www.sapien.com/blog/2016/05/23/add-custom-tools-to-the-menu/
PowerShell Studio - Basic Orientation I 97
To add a separator line wherever you want, to better organize your menu, enter a line
between two items and use a dash "-" character. Example;
[menu]
1=Run Get-Acl;powershell Get-Acl -Path $File$ I Format-List -Property *
2=Get User;powershell [Environment]::UserName
3=-
4=Get IPConfig;powershell Get-NetlPConfiguration
- A Find in Fies .. .
~~ Compare Fi!es
Sign Script
Custom Too! ...
Run Get-Acl
Get u~er
Get IPConfig
Open CustomMenu.inf
To create custo1n tools that appear only when the current file is stored in a specific directory, place a
CustornMenu.inf file in the specified directory.
L.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................l
Cbecl< Syntax: this nifty tool will run through your script a11d identify any syntax errors that
l]l Check Syntax
-
, ~ Venfy Scrrpt
it finds. I reco1m11end doing this after any inajor changes to a script.
, ~ Analyze Script Verify Script: instead of checking syntax this tool will check that 11ave all the required parts
to your script, i.e. if you have Import-1nodule state1nents it vvill verify that you have those
Analysis inodules available.
Analyze Script: this is a co1runu1Iity driven module called 6''PSScriptAnalyzer" . PSScriptAnalyzer provides script
analysis and checks for potential code defects in the scripts by applying a group of built-in or customized rules on
the scripts being analyzed. One of the things that you will notice that it does not like are Aliases, now I know this
will frustrate inany Po,verShell scripters because the 1nain consensus is to make your com1nand lines as short and
as efficient as possible. The upside is, to the beginner it inakes reading your code inuch easier if you use e:x.1Janded
cormnands.
6 https://www.powershellgallery.com/packages/PSScriptAnalyzer/l .8. l
98 I PowerShell Studio - A Comprehensive Guide
,. ..........................................................................................,,.,,.,, ..........................................................................................,,.,,.,, ......................................................................................., ., ., ........., _ ...............................................................................................................................................................................,,.,,.,,1
I,.,...........................................
;
SAPIEN..................................................................-................................................................................................ .. , _,,, ~,
i
..................................................................................................................,_ ............................................................................. ..._,.......................................................................................;
~
~ PMnalScnpt ~ PowerShel Help\'Inter BJ Po'lterRegEx These are weblinks to various SAPIEN products to
enl1ance your PovverSl1ell scripting.
~ Pr.malSQL ~ Version Reca~ fa Profi1e Editor
t:i PrimalXML ~ \A/MI Explorer
SAPIEN
7PrimaJScript: Pri1nalScript 20 16 is the next generation of our industry-leading Universal Sc1ipt Enviro1unent
(USE). As a syste1n, database or network achni11istrator, web developer or e11d-user developer, you need to vvork
with 1nultiple technologies, lai1guages a11d file formats at the sa1ne time.
8Prima1SQL: usiJ1g Pri1nalSQL you cai1 connect to any database: fro1n Microsoft SQL Server to Oracle to Microsoft
Access or even Microsoft Excel. PrimalSQL can be used to build rich and complex queries. Fro1n within the
application yo11 can test ai1d retine queries, export results or generate code snippets in a vaiiety of languages. Its
modern, strea1nlined interface makes PrilnalSQL easy to 1mderstand and use.
9PrimaJXML: a tool tl1at is specifically designed to edit, manipulate, and create XML files.
10
Po'\verShell HelpWriter: PowerShell Help Writer 20 16 is the pre1nier editor for Windovvs PowerShell XML help
files for all command types, including c1ndlets, functions, workflows and CIM collllnands.
11
VersionRecall: VersionRecall 2016 auto1nates the n1ost widely used manual process of creating backups and
1naintaining inultiple versions of your files.
12
WMI Ex1Jlorer: tl1e next generation tool for e>..]Jlo1ing the vast universe of the Windows Manage1nent
Instiun1entation database. The WMI database represents a huge repository of infonnation about yolu servers and
client 1nacl1ines \hich as a syste1n or nehvork administrator you need to utilize every day.
13
PowerRegEx: Po\;verRegEx is the tool that makes regular expression creation and discoverability easier, by
grouping regular expression constn1cts by category, providing construct descriptions a11d exan1ples.
Profile Editor: Po\.verShell's profiles inake setting up your \VOrk environment a bit easier, allowing you to pre-load
your 1nost co1nmon snap-ins or 1nodules, defil1e fimctions, set variables and whatever else you need on startup.
7https://www.sapien.com/software/primalscript
8 https://www.sapien.com/software/primalsq l
9
https://www.sapien.com/software/primalxml
10 https://www.sapien.com/software/powershell_helpwriter
11 https://www.sapien.com/software/versionrecall
12 https://www.sapien.com/software/wmiexplorer
13 https://www.sapien.com/software/prod uctivity_pack
PowerShell Studio - Basic Orientation I 99
j i
!.................................................................................................................................................................................. ...................................................................................................................................................................................................................... ~...................................................................................................................!
.. . . . . .
0%
Ex.
'https://technet.microsoft.co1n/en-us/library/jj657534.aspx' does not resolve to a container.
c
Create
G Restore
Cl Delete ~
VersiOORecal
[1- Submt Fie
CJ, Restore Fie ~
Lat..neh
, AddTo
~ Chedcin
~ Undo Chedc Out ~ Properbes
~Get latest ~Compare
~ Rewind Explorer (l0 Get Latest ~ ChedcOut ~ View 1-tistory Refresh
These controls are all based around providing a syste1n to restore your script back to a previous ti1ne, and providing
source control for yotrr scripts, especially when \.Vorking "vith other teain me1nbers on the same script.
100 I PowerShell Studio-A Comprehensive Guide
;
,.,.........,,,_,,,............................................................ ,_,,,.......................................................................................................................................................................................................................................................................................................................................,_,,,....................................................................................;
~
G Restore This reminds n1e of Microsoft Windows restore points. and it does si1nilar behavior but
0
Create
1 Delete
instead operates at a script level. This \vill help you recover fro1n shooting yourself in the
foot if you iajected mistakes or erroneous code into your scripts.
..._ Rev-.'ind
Create: before any
scripts updates I highly recotnmend that you get into the habit m~jor
Restore Points of creating a restore point, one day you will be tliaukful that yo11 did. Currently there
doesn't seem to be an indication that a restore poi.lit has been created. which can mislead you into thinking that
nothing happened. I would prefer some type of message or stah1s indicator that the restore point created successfully.
It will however if it is the first restore point you've created, enable the "Restore'' and "Delete" b1Itto11 which is at
least so1ne indicatiou, but after that it is hard to knovv subsequent restore points created successfully. Only the last
created restore point 111ill be kept, there is currently no restore point history.
Do you wish to restore this file? Restore: this will restore your script to the last restore point that you created.
You \Vill get a popup confirmation message before restoring.
test.psf
Delete: this will delete your last restore point.
14
Re,vind: this is used to restore your script back to the beginning of the
current session. Careful using th.is if you have been working on your script for quite a vvhile as it \Vill erase ALL
changes since the beg.inning of the current session.
Restore Points
V Create a restore po111t as soon as a file 1s modified.
15The simple and quick setup lets you select a folder that VersionRecall vvill 1nanage as well as a "backup location"
where your previous versions 'vill be stored (usually on an exten1al drive or network drive.) Fron1 that point on~
\vork as you usually do, saving the file locally, and wl1e11 you are ready, sin1ply subnlit the file using Version.Recall
E:x.rplorer or our Windovvs Explorer integration. Or, set VersionRecall up for autonlatic submission at a
predeternli.ned ti1ne.
You must have SAPIEN's Version.Recall installed on your system otherwise the controls in PowerShell Studio vvill
be disabled.
Unlike many other versio11 recall systems, SAPIEN's Version.Recall 11ever changes a file or its extension., so
restoring is very simple and as easy as opening an older version of the file, there is no cryptic fonnat. There are also
no locking 1nechanisn1S. so no check-in or check-out, which is good for a one or two-person tea1n.
14 https://www.youtube.com/watch?v=DsNCIEXSY6A
15 https://www.sapien .com/software/versionrecall
PowerShell Studio - Basic Orientatio n I 101
Version.Recall is in a11d of itself a full featured product separate from Po\;verShell Studio so we won't go into in-
depth detail here. If you 'vould like to k.no\ more abol1t Version.Recall visit
https ://w\.vw .sapien.com/software/versionrecall
VersionRecall Ex(llorer: this will launch the Version.Recall E>..1Jlorer with the
~ s bmJt
associated repository that corresponds to the active document.
Q, Restore F "'
VersronRec
Explorer ~ Get latest Submit File: submits the active file to the corresponding Version.Recall
repository.
VerS10nRecal
Restore File: ove1vvrites the active file with the latest with the latest version submitted to the correspo11ding
Version.Recall repository.
Get Latest: overwrites the active file with a newer version from the corresponding Version.Recall repository.
l .....................................................................................................-.................................................................._..,.................................................................................................._.............................................................................................................................~...................................................................................................................J
16
~Add To ... Version.Recall is a Source Control Provider. ~ Undo Check Out [B Properties
However, SAPIEN did not want it to intentionally
~ Check In ~ Get latest ~ Compare use any API especially not tl1e Microsoft SouTce
Launch
.., Checkout ~ ew History Refresh Control interface for several reasons. The specs for
the Microsoft Co11trol interface API can be changed
Source Control without notice and it is a very dated API which
causes excessive work on the part of the develop1nent team to confonn to its requirements.
To enable the Source Control tools, you must first have setup a source control provider, and enabled source control
in the PowerShell options u11der "Source Control" tab.
Settings
~ Enable source control ../ Prompt for check in
i
................................................................................................................................................................................................................................................................................................................................................................................................................................... ..................................................................................................i
~ ~ ~
17
GIT is a free open source distributed version control system designed to handle everything fro1n s1nall to very
large projects, ai1d is probably one of the 1nost \.Videly used version control systems \Vorldwide.
Currently the only support for GIT integration \ith PowerShell Studio is via the custom menu. Unfortunately, GIT
does not have an API. To use a source control solution with SAPIEN products it must have a MSSCCI provider,
there are a few MSSCAPI providers out there for GIT.
If you're using projects, you cru1 run a git add -u with the custom menu and it'll add just the modified files in your
repository to be co1nmitted.
11 https://git-scm.com/
PowerShell Studio - Basic Orientation I 103
The help tab contains links to check for updates, product inanual and references, samples, and external links to
support areas.
l".......................... .. . .......................................... ...... . .. . .. . ....... . ..... ..................... .............. ................................. ........... ......... . .. . ..... . .......... ................................ .... .................. .............. .............. ...... .. . .................................... ......... .... ................... .......... .............. .... .... .. . ..... ...... . ..................................... ................................................. .. . ..... .............. ....... ,
I ;
!t..........................
PRODUCT SUPPORT l
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................;
Control Reference: this open the WinForms Control Reference docu1nent, which contains all the controls in
PowerShell Studio along with their property functions. Very helpful guide that you \Vill reference frequently as you
learn PowerShell Studio. These are also listed in the back for this book in our reference section.
Samples: this opens Document Explorer to a list of all available sample scripts and forms. SAPIEN did an aweso1ne
job here providing users vvith a solid base of exai11ples to quickly learn from.
Batch Files
DOTNET
HTAs
PowerShell
Po,verShell Studio
Windovvs Script Host
104 I PowerShell Studio - A Comprehensive Guide
; :
!................................................................................................................................................................................................................................................................... .........................................................................................................................................................................................................................................................\
\AJeekly ~ Update Frequency: select 11ow often you ' vould like Po\verShell Studio to
ElJ Update+felp automatically check online for available updates.
Updates
Update-Hel1> : this checks online with Microsoft for updates to Windo,vs
PowerShell help content.
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................r
ONLINE i
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................:;
Online
L......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................J
This can be confusing for many and I have seen co1nplaints that it doesn't do anything, the issue is
usually that it is not being used correctly. The context help triggers on the caret position and not
actually the selection, so place your cursor at the beginni11g of the c1ndlet then click the Context Help
Context button. If help is available for the c1ndlet then it \viii either be displayed at the bottom of the screen in
Hefp the window belo"v your script, or if it is an online help resource your default browser \Vill open to
Help display the help page.
In the next screenshot, you can see the cursor at the beginning of the attribute "Para1neter" on line 23 . After clicking
the Context Help button the help information appeared in the \.Vindo\v belo"v.
The view tab contains several options for panel vie,ving \.Vith different areas of PowerShell Studio including; Output,
Editor, Designer, Debugging, Layouts, and others. It also includes buttons to display the Start page and Po\:verShell
Studio Options.
There are various layout templates that you select, such as; Defaltlt, Co11sole, Debug, Designer, Editor, and Editor
Only.
PowerShell Studio - Basic Orientation 105
-
fl ..l
.._
El
-w...
Gi O ot>'"
~ ..... b..t
- ..
E "" _.,., l '"-' ~ ;;i ' ";;] t:. t.Jw ID..-
~ ...... cn..o tt~
-.. ..- "~o.ra.._ ~ ".uo.-.c.
:::
- .....
.... -.
.:......
-
S'l'"-
......
'~
': .Gr'J( lllll ...
------------- ----
ii
..
11
1,
WY'!! ,.,. .,_._,,....,,..,._, ,.,. ..,._, ftf 1to. -
. ~llilti"""!
\'""' rf!HIW'
...U!
:: /II ....sc..-tao\ I~
""11111t'rt~t-
.-f ,.,._ r~ ~-.:..,. .
,.lh
.
"'wd.rtlr.., ,.._. ~- ...,._, .....
u. ~t
tt: ">Ct\ ....,. ''It\~' o(fl'Oilt ' v.l""-l'
...::'" ...
),.):
""D
it~ l ~tl~ t >owt t!lie hie
21 ~......
,,;
,.. (
!ttt<~ {l".-14.1 '0l'J
,.....: ,.....,
'"
..;
,,,
.. -.. - -....... A
.,.
,,.. JN'a~ ..,
= .-..~ re,.._. ~o.o.. " Mr...,._,s ., ,..,~~ ..,. . . tlt ':".t~ ._.
iI)_ ........ c.... ..
.t
. ., .. - .. J c.""'- C" ......... .... 611 .... 7"
; y ""--"'
.... "" '-... "'~ a.,., .._
v O ..
.... ...... =-- "~""'"
-~ - - .,~~
,....,_
~1 rr-c
;
~
!
...."
1) ..........
'" \
HI flO'l ff
It UrillL~l '"''~l#o ~ 1H t lt.f,
lt' ,...,.. .
1:: (
>, d,,.. ("'-lr..., l ttw),
.. tu-,"f_Jvs-.,
~ (1Jr-~ (...,_,.tooy l tn.it)j
..'1.- ,,... (lt;'"' '~t.,.
i_.U (
...,
.. 9'f000l ~tll.Uc ,...,.. Wtl"OU l!ICt'C
"
" '.
,....... _...... _________________ ~'
- ,~---
-- --
Cl f)t.i O ..,n.
.....,.... ,..._ ..., '- .. r_.,,
r..._ ., r a... ., "' ..... ~
- ~
... .. ~
, __ .
............... :m ... (....
"
If x
0
-
., y
;:::; .... ....._:...~
=....,.... .,. .".... .,
\lw
!, .......... ..,, ... ~ "' ...... ~
111..-1,
= ,...,_ Ii: ~.;;..I Q..~ ... . c-L
., ": ,........,.._ ..
- -
v il --.r- .;
~
... o . "'" i.~~
,,..
-.."'"''"" .--
J ..J ~
-
v- =
i...
..:..I'
l
.
1
'
' .ot'I(
...
~-
11'1J{W
....... f.....- . . _-....... ~ ,,,.. -
praNttf',
1 1. ,_ ,_ tlt-- - c
-
11
1: ,__,.If. 1"""'1-
,, .. G.ut-if>l'- f ,..., C...,...t ..r- ,...,._, ..,
'"' ~'
~lt~ ~r~t.L"
,.
1
JI
"'
;! t "
..a...t. t.h# JI.kl,
"
:..i
J
d - .. (............,.. ,,,_,J
(1 'f!fJf;"'"'" '
.........
\ ,,. ...,.. lt.... )
(~to!')'
"'
A
..'.
.;'", " itrl1'<J j(e"""~e...
'ft:'#i ....
''--~(
-
ti
M a'TOOO t.,.it.U U.U ..... C...t,..1' kf"'C
" ,,..
,~.. .., . ....
,,. l
"
L
<I
.l
..
"'
-
. -
.
......
.,,_
"'
,,
.>:I ...
= ...J
.._
C Clrl O ..,no
~ ~ t~
,, ..,,....
- ......... W.F trfr:)f "'1:
E ~',.... .n1""~'-. ..; :E ~ ., ai ..... ~ :J t-.....
~
'.:. G.-1 )(.....;
~~...,o..,., !r~ W ...
v o .....
)ct..c ~ .~
......
,....,. v ~OoJt.t"- ..; ....u.,.,.
....."'"-
, .., 61~
- ......
e
' ,\,,(llP) I~
".,..-t...,. r.itt,,.,. , ,...,,
'
.,.t.UIUTt, Kac
,. I. 4tter1-~ ot tlloO ~ 0..1'. .Uf'
"
i: """"""Cl ~~,
l.
&l
I
,,
Sf
4 fttoCrt1Kt0"1 fl( t."
'AN'M t
II-.. c \>
C~tr
..,._ v.1-i
N'Vtr
.,~,. 'ti11_.1
,. ..
)1
",.
1VUI
\ J1'....,!'"~Q"l'l('J!tot)' Stn.t-))
" ..
,. tt-"1-"tl Pl..u.
r. .....,......<~to-~ ~n- . )l
a ..,,,.i""Cl~t-
P'
..
.,,.._
~ . . . . . . . . . ,. ._ fO
:ti . , ....... _, ....... ,
n-
O c.ttwA.Ji-O ,. TC001 fIU.111,-. ""- t41'1t,._h, -.....
o tcv..n.A..-; IL
ft ra'I~
O c.n-
;._...
E:l>lt!M
"
.--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~....,
>
Cl
~ -
; r.....wkl.
; .......... Cl
;~
.
; ..__
L2
,_
_; ,......,,.,
>~.MO"
,_
;....
,,_ ~
,..,
V ,,.-...-.ca ... ~ .... 0io..q " '"""._... 0 ~ r.i 'C\.A;l..t f"'-llnW\:lr
I U.... ltJD ..1,.,.: >. NUW IJ'T4 lN lJ C. l ;"">) )
If none of the predefined layouts work for you, then you can also create and save your own custo1n layout that fits
your own needs.
PowerShell Studio - Basic Orientation I 107
2.3 PANES
~ Function Explorer
2.3.2 Console Pane
fQ Help
~ Object Browser The console pane is an instance of Po,verShell hosted in the PowerShell Studio IDE.
There is a platfonn selector at the top which allows you to switch between 32-bit
[] Output
and 64-bit PowerShell instances. One tiring to keep in inind is that you do not type
~ Performance conunands on the coffilnand line as you inight be accusto1ned, you type the1n in the
Input Box and press enter, this sends the co1ruru1nd to the shell. If you like you can
~ Project also disable the input box in the Console Tab of the Po\.verShell Studio Options.
[I! Property
Right clicking i.J.1 the
~l
11coosoi. c "
Snippets Console window will !,,,....--,:~~------------------.
Copy
Copy highlighted text to the clipboard.
Paste
Copy the contents of the clipboard into the
console.
Restart Shell
Restart the shell. This will erase all work done in
tl1e current shell.
Figure 65 - Console
2.3.3 Debug Pane
The Debug output pane shows you messages written to the debug strea1n - by Write-Debug, for exan1ple. It also
records messages created by tracepoints in your code.
108 I PowerShell St udio -A Comprehensive Guide
fill Output o x
>>Debugging (MainForm.psf) Script ...
>> Platform: VS 32Bit (STA) (Forced)
ERROR: Exception calling "Save" \'iith "l" argument(s): "Access to the path 'C: \ path.xml' is denied."
Mainform.psf (1173, 4): ERROR: At line: 1173 char: 4
ERROR: + $PathFile .Save($Path)
Find ... Ctrl + F Copy (Ctrl+C): Copy highlighted teA1 to the clipboard
Select All Ctrl +A Find (Ctrl+F): Search the text in the debug output windo\v
Clear Ctrl + E Select All (Ctrl+A): Select all the text in the debug output windo\v
Clear (Ctrl+E): Clear the debug output window
With the Debug Console, you ca11 interact with the RunSpace while at a breakpoint. Tl1e console allo,vs y ou to fllll
co111lllands, like call function, or cllallge variables to make debugging scripts easier. You can also simply
experiment with what-if scenarios.
PowerShell Studio - Basic Orientation I 109
27
28!
\~rite -Output
CJ x
.
>> $sOS
Version 10.0.14393
-
~ ~~ I
Ii] Debug Console ":!. Stack ~ \~atdi ii Variables
In the example, you can see that we set a breakpoint at line 27, we can then query the contents of the variable $sOS
within the debug console to ensure that the contents are as expected. This is a great tool for debugging your script
commands and functions.
Debugging
110 I PowerShell Studio - A Comprehensive Guide
When you do a search within Po,;verShell Stl1dio, whether it be a "find in files" or a " find all references", the results
will be displayed in the Find Results Pane.
Mi Rnd Results CJ x
C: \ Users\ Jeff\ Documents\ SAPIEN\ PO\ierShell Studio\ Files\ test.psf (22, 2) : $forml_Load={
Total References: 1
This is an example of a "Find All References" search for the tenn $fornzl _load- { within a test script, as you can
see there is only one results, if there were more tha n one $fonn_load statements then we would have a proble1n.
Mi Find Results CJ x
C: \ Users\ Jeff\ Documents\ SAPIEN\ PO\ier Shell Studio\ Files\ test . psf (22, 2): $forml_Load={
Total References: 1
I I!~ Copy Ctrl + C
Copy HTML Ctrl + Shift+ C
Marie as Visited
Right-click within the Find Results pane to display the sub1nenu; Copy, Copy HTML, Find (finds with the find
results ... nifty huh!), Select All, Clear, and Mark as Visited.
PowerShell Studio - Basic Orientation I 111
The function eArplorer "vill display will display all functions and events within the current script. This a very useful
tool for fiI1diI1g a specific function within particularly large scripts. If you work with scripts in the thousands of lines
of code, this can save you countless hours.
Figure 68 - Functions
112 I PowerShell Studio -A Comprehensive Guide
18869 <# Edit: opens the Function Builder for the
18870 .SYNOPSIS
18871 A brief description of t he Updat e-Log function. selected function.
18872
18873 .DESCRIPTION
18874
1887S
A detailed description of t he Update-Log f unction . Copy: copies the function definition to the
18876 .PARAMETER logstring clipboard
18877 A description of the l ogstri ng para.m eter.
18878
18879 .EXAMPLE
18880 PS C:\> Update -Log -logstring 'Valuel'
Rename: renames the selected function and
18881 updates the references in the script or project to
18882 . NOTES
18883 Addit ional inf ormation about the f unction.
reflect the change.
18884 #>
1888S Function Update- Log
18886 - {
188871 Param ([st r ing]$1ogstring)
18888 $currentdir "c:\Program Files\ARMS\sccm"
18889 $logstring "$(Get -Date -Forra~ 'yyyy-11'1-dd HH:an:ss' ) : $logstring'n"
18890 $sccm_status .AppendText($logstring) $logstring
18891 Add -content Sl ogFile a.ue $logstring
188921 $sccm_status .Refresh()
18893 $progressbar_sccmhealth. ReFresh()
18894 [System.Windows . Forms.Application] : :DoEvents()
1889S }
0 x
Ne me
WNte-Outpul
Synopsis
Sends the specified objecls to the next command in the popehne II the command 1s lhe last command in the pipeline. the
ob1ects are displayed in the console
Syntax
Write-Output (lnputObJect) <PSObJ"CtU> [NoEnumerate) [<CommonParame1ers>]
Detailed Description
The Wme-Oulput crndlel sends the specified ob1ect down the popel1ne to the next command ~the command 1s the last
command in lhe ppeline, lhe object is displayed on the console
Wnte-OUlput sends objecls down lhe primary popehne. also known as the output stream or the "success pipehne To send
error objects down the em>r pipeline, use Write-Error
This cmdlel Is typocally used in scripts to display strings and other ObJ8CtS on the console Howeo.-er. because the default
beha'llor 1s to d1Splay the objects at the end of a pipehne. it is generally not necessary to use the cmdlel For example. get
ptocess I wnte.output" 1s equMllent to "getptocess.
Parameters
4nput0bject <PSObjecl[)>
Specifies lhe obiects to send down the ptpelme. Enter a variable that contains the objects. or
type a command or exptessoon lhat gets lhe objects
Required true
Posilion: 1
0eraul1 value:
Accept pipeline input true (6yValue)
~cept wildcard characters false
If PowerShell Studio is configured to use external help, the help will be displayed m the SAPIEN Docu1nent
Explorer.
PowerShell Studio - Basic Orientation I 113
To ensure that help items will show up in the Help Pane, you must configure two options as follo"vs:
Source Control
Analysis
v Aulllln!lbcaly analyze sa~ts on~
Change Execubon ~
Ecitor
PFX C~bficate: []
Password: ~==================~
http://llf'OeStamp.olobalsqi.eotn/saf)tsfr:ms~.cl
l Source Con1rol
The code generators provide a default connection string that you \.Vill need to edit to reflect your environment.
Tb.is pane displays normal script output. One of the things I like best is that if an error is output from your script
you can doubl e-click on the message and be taken directly to the appropriate file in the code editor.
[]output Cl x
>> Running (test.psf ) Script ...
>> Building ( test . psf) ...
>> Platform: VS 32Bit (STA) ( Forced)
Copy (Ctrl+C)
Copy highlighted text to the clipboard.
Copy HTML (Ctrl+Shift+C)
Copied highlight code, including color coding and formatting.
Find (Ctrl+F)
Search the text in the output vvindow.
Select All (Ctr l+A)
Select all the text in the output \vindow.
Clear (Ctrl+E) A. B
Clear the output vvindow. ~~=+-
~ Performance CJ x
1 1
0.9 0.9
0.8 0.8
0.7 0.7
Q)
Ol 3:
jg 0.6 0.6 <D
cQ) 3
0
u
L.
Q)
o.s '
0.5 -< -
,.... CPU 1
0....
:J 0.4
0....
u
~ r 0.4
::J
3:
OJ
~Memory
0.3 0.3
0.2 0.2
0.1 i 0.1
0 0
0 0.2 0.4 0.6 0.8 1
Time
fl) Console ~ Debug MJ Fm Re5Uts @Help D output I~ Performance
As of version 5.3. 130 there is now the capability to track in real-time the CPU and Memory utilization of your
scripts.
PowerShell Studio - Basic Orientation I 117
The project folders reflect the folder structure of the project files. Therefore, if you previously organized your project
files in folders witb.i11 the project's directory, those folders will auto1natically be displayed in the Project Pane once
the project is loaded.
-
53 Project CJ x
The four icons at the top are as follows fro1n left to right:
~r. l lirii
Enter tevt tn -=-,.~ch ... p
A ra ARMS
~ Ne'v File: this opens the ne\v file dialog \vhere you can choose the
type of file (.psf or .ps l ) to add.
~ Globals.psl
Add New File x
rlijj Malnform.psf
File Types
rlijj Processes.psf
rm startup.pss tpi j
Form
Creates a new GUJ based ~t (.psf)
fJ J PowcrSheO Script
Creates a new PowerShell Scnpt (.ps 1)
r Add Existing File: this \Vill open a Windows Explorer so you can select a file(s) to add to the current project.
You can add the follovving files types:
You can also drag\drop from any Windows Explorer window directly to the Project Pane to add file(s). You will
get a confirmation screen whether y ou want to copy the file to the project directory. If you choose " No" then tl1e
file w ill still be added to the project but the file will not be copied to the project folder.
By default, I like to copy any file(s) or folder(s) tl1at I include in a project to the project folder also.
@Project 0 x
t'J r. .. rii
E"' 'P XI~ rch... P
.. l]j ARMS
bJ G1obals.ps I
Cl ~\'board Sho<tcuts.pdf
B} Man'orm.psf
mu Processes.psf
rllJ Startup.pss
"
r;- Open You can also select any file(s) or folder(s) directly w ithin the Project Pane and
tV Rename re1nove or delete tl1em. When you right-click on a file or folder in the Project Pane
you \Vill see a 1nenu with several selections, the two we address here are;
~ Debug Script File
t> Run Script File
n Run Script in Console Remove: this will ren1ove the selected file(s) or folder(s) fro1n the current project,
~ Preview Form ho\vever it w ill leave the physical file(s) or folder(s) intact on disk .
Remove
x Delete Delete: tltis \vill re1nove the selected file(s) or folder(s) fro1n tl1e current project,
AND will MOVE tlle file(s) or folder(s) to Recycle Bin.
New Folder: this will create a new folder that you na1ne \-vitltin yotrr current project folder.
Open Project Folder: tltis will launch a Windows Explorer windo\v displaying your current project folder.
PowerShell Studio - Basic Orientation I 119
This pane displays all tl1e properties available to the currently selected control, object, or fom1 in the form editor or
project panel.
ly Properties JJ ~ Form Properties: the screenshot to the left is an exa1nple of the properties pane
~ sforml: System.~Tindows.Forms.~
for a form object. Form properties contain the follovving sections:
Text You can right-click on any property to getMSDN online help about that option,
The text associated with the control. or you can press F 1 after selecting the property .
120 I PowerShell St udio -A Comprehensive Guide
The left two buttons allow you to switch behveen viewing properties grouped into functional groups or simply listed
alphabetically.
The right hvo buttons This pair of buttons allows you to switch between looking at the properties an object supports
or the events it can trigger.
PowerShell Studio - Basic Orientation I 121
~ Snippets 0 x If you are not fainiliar with snippets, these are small pieces of reusable
code that can be easily inserted into scripts, snippets can be full
functions or simple one line staten1ents. The snippets pane contains
~ rii ~ various snippets that can be used within your scripts to complete many
Enter te>t to search... P comn1on tasks. The default snippets are contained in the
~~~~~~~~--~
"""
Tlus will re-scan the snippet folder and refresh the s11ippet pane.
lf <OO>HOO" o0o0oOOHOoooo<00>0.. .... ................................. ... .... ,,,,,.. ...... ........................ .......... ........ .... ................ ........... ............,,,,,,,. ,... ... ..... .................... ..................... ...... ............. ............ ........... ........... .... ... ... ............ ..
0000>ooo 00000~000 000 00o o < oo ooooooooo ~
!,............................................................................................................................................................................................................................................................................................................................................................................................
:
SNIPPET EDITOR
.............................................................................................................
~
i ~
:
The Snippet Editor will launch \vhen you edit an existing snippet or create a new snippet i11 PowerShell Studio. It is
a self-contained progra1n, and it supports multiple progra1nming languages. Snippets are reusable blocks of code
that you can add to your PovverShell scripts, thus saving you time and reducing errors . S11ippets can include
placeholders, and PowerShell Studio will pro1npt you to supply values for these when the snippet is used.
When you first click to create a new snippet, you will get a popup windows asking you to name the snippet file, by
default the snippet will be saved at~ %ProgranzData%\SAPIEN\Po111erShell Studio 2016\Snippets\
122 I PowerShell Studio -A Comprehensive Guide
ng S PIEN\Use Sn1pptts J>owuShel ut sn pp et Snippet Editor x
;:; Flit Edit Vltw He,lp
::
[)esa\:>tion:
:==============================~
Author: ~ff
~U:U.:
Language: Power
_ Shel
.__I _ _ ___,v I Type:
+ -
~ URL
If you choose Surrounds with or Both, you must include the placeholder $selected$
so1newhere in your snippet code body, othervvise you may ovenvrite user code vvhen your
snippet is used .
PowerShell Studio - Basic Orientation I 123
mg\SAPIEN\User Snippets Po erShel test sn ppet - Sn ppet Editor - ::J x
m File Edit View Help
1;1 D ~Ill Jb ~ I! el T .
..
Variables ... q. x
.-----------------------------
Title: Dowhlle
Variables
Shortcut: DoWhile
~LRL:
language: I.....Po_v._erShel
_ _ _ _ I ___.v Type: Both
ldo {
2 SselededS
3I
4 Sends
5 ) w!'llle (Scoodi>onS)
+-
Assembly URL
References: This section helps Po\verShell Studio to understa11d any dependencies that your snippet has. The
assemblies you list here will be loaded into PowerShell Studio when you use the snippet.
Variable Details: This section is used to configure placeholder variables used in a snippet. Placeholder variables
are added to a snippet when you-right click on the snippet code editor and choose Add Variable.
Once you have given the variable naine it will appear in the snippet as $<variable 113Jne>$ (e.g.
$co1nputerName$) and you can configure the variable properties.
ID
The variable's na1ne.
Default
A default value if required.
Function
Not used in PowerShell snippets.
124 I PowerShell Studio -A Comprehensive Guide
Tytle
Not used in PowerShell snippets.
Kind
Not used in PowerShell snippets.
Editable
Not used in PowerShell snippets.
ToolTip
Provides some text eA.'Plaining the purpose of the variable. This helps the snippet user understand
how to complete the snippet. PowerShell Sh1dio will display these tooltips as the user navigates
bet,veen the placeholders in the PowerShell Studio code editor.
$selected$
Allo\.vs you to 1nerge code from the code editor into your snippet when it is used.
$end$
Specifies where the cursor should be placed when a snippet is inserted into the code editor.
--
PowerShell Studio - Basic Orientation 125
r CCToolbox The toolbox pane is one of the most used panes when using the form designer, this is
-
' x
.- c : where all the control objects are located that you will use to create functioning GUI
p forms .
~ <Pointer>
@Sutton
The toolbox pane consists of three tabs:
IiiChart
0 Oled<Sox
[f~ Ched<ed.istSox
Controls:
ti1I ColotOialog
~ ComboBox T11ese are all the GUI controls that you can add to your form.
~ ContextMeruS!rl>
6J DataGnd
{iJ OataGnc!View Control Sets:
ifl DateT11ieP.dcer These are custo1n controls that you can drag and drop fro1n the Toolbox Panel into the
OolMri.JpOown
designer like a11y other ordinary fonn co11trol. They are 111ade up of either single or
9 EtrO!Provide.r
~ FieSystemWatdler multiple controls with predefined property values, event handlers, and functions.
iFj Ro~ayoutPanel
taJ FolderBrowserO!alog
.al FolderSrowserModemOlalog Select:
J3 FontDlalog Tl1is is a list of every control in your fonnat for easy selection.
LI G<oupSox
HetiProV!der
< ~ HSaolJBar We will briefly discuss each control here and its basic function, in later chapters \Ve
r;J !magel.Ast provide much more in-depth functionality and examples of each control.
A Label
A Lnl<1.abel
a. lrstSox
H! lrstvlew
SAPIE1V has created excellent Spotlights on nzany of the controls, where available we
H
[!;) MaskedTextSox will provide the reference.
~~ MenuS!rl>
~ MonthCalenclar
3 Nobfyicon
D Nl.mencUpOown
1ll OpenFikOialog .............................................................................................................................................................................................................................................................................................................................................................................................,
D Panel
Plc:tl..reBox
CONTROL OBJECTS - BASIC OVERVIEW
.........................................................................................................................................................................................., ..........................................................................................................................,..,. ........................................................,
I
@D ProgressBar
@D ProgressBOveriay
~ Prope<tyGnd
)Button
0 Radoeutton 18
BUTTON - Creates a clickable button. Used to initiate or end an action.
A RJdlTextaox
.fl SaveReOialog
rn ~tcontaM"
..,. ~tter
Chart
19
L Statusaar CHART - Creates a chart with several different chart types available.
b StatusS!rl>
LI TabControl ~ CheckBox
f;1 Tablelayootpanel
2
@; Textf!ox CHECKBOX - Creates a windows checkbox control \vhich represents a true/false
@rmer condition
[[!! Too16ar
[[!! ToolS!rl> g: ChedcedlistBox
l.i,. ToorTip
0-- Tr ackaar
-!.:-_ CHECKLISTBOX - Creates a multiple item list check box. allows you to list a
TreeView
VS<ro!IBar
~ Web&owser
20 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-checkbox-control
126 I PowerShell Studio-A Comprehensive Guide
collection of items, each ,;yith its own checkbox.
; ColorDialog
COLORDIALOG - Creates a color picker vvhich allows the form user to select a choice of colors for the form.
~: ComboBox
11
COMBOBOX - Creates a dropdo,vn sty le box for multiple items. The item list can be either static or
dynamically built.
- ContextMenuS tnp
11
CONTEXTMENUSTRIP - Creates a men11 of com1nands in a right-click conte>..'t menlt. For your convenience,
when you drop a Contex~enuStrip in the designer, PowerShell Studio will autornatically assign the
ContextMenuStrip to any control you drop it on. To 1nanually assign a ContextMenuSuip to a control you need to
set the control's ContextlvlenuStrip property to the desired Contex.1MenuStrip control.
DataGnd
DATAGRID - Creates a nice grid style table for displaying data, like ho,;v excel spreadsheet style looks.
:nDataGrid is outdated and it is recommended that you use DataGridView instead because of its enhanced
features. DataGrid is retained for back\.vards compatibility.
DataGridView
DATAGRIDVIEW - DataGridVie';v is the ne'1vest grid style data table.
DateTrne?icker
DATETIMEPICKER - Creates a visual cale11dar date picker. You can select long or short dates, time, or create
your own custom for1nat.
~
.., DomainUpDO'A'n
DOMAINUPDOWN - This control at first seems misleading because it makes you think it only have something
to do vvith network domains, but that is not the case. This will create a list type control 'iV ith up/down controls.
In1agine a dropdo'1vn box ,;vhere instead you click and up or do'\ivn selector. This is used on a fonn where you need
to present 1nultiple items but you have liinited area on the form.
ErrorProVtder
14
ERRORPROVIDER - Use the ErrorProvider if you want to notify tJ1e user that there is an input error by
flasl1ing an icon next to the input control. You can use a single ErrorProvider for multiple controls. In the case
where you '1Vish to display different icons or styles, you will need to use multiple ErrorProvider controls.
6fJ FileSystem~Jatcher
FILESYSTEMW ATCHER - This is used to watch a specific directory or file; any changes will raise an event.
This is not a visible control that is added to the fo1ID, you can think of it as an Event Control.
21 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-combobox-contro l
22 http://info.sapien.com/index.php/guis/gui-contro ls/spotlight-on-the-contextmenustrip-contro l
23 https://msdn.m icrosoft.com/en-us/library/msl 71628(v=vs.11 O) .aspx
24 http://info.sapien .com/index.php/guis/gui-controls/spotlight-on-the-errorprovider-control
PowerShell Studio - Basic Orientation I 127
S:ZO: Flol/\'layoutpanel
FLOWLAYOUTPANEL - This is used to create an area on the form tl1at you want to automatically control tl1e
aligrunent and flow of controls. The options for flow direction are "Left to Right", "Right to Left", "Top Do"vn",
and "Bottom Up"
- FolderBrowse.rDtalog
FOLDERBROWSERDIALOG - This is used to pron1pt the user to select a folder.
- FolderBrowserMode.mDlalog
25
FOLDERBROWSERMODERNDIALOG- This uses the 1nodem version of the folder browser dialog that is
available in the later versions of Wit1dows.
= Fontoialog
26
FONTDIALOG - This control prompts the user to choose a font fro1n ainong tl1ose installed on the local
computer.
rxv
L- GroupBox
GROUPBOX - This creates an area on the fonn to allow you to group different controls together for better
design flow "vithitl your form.
~ HelpProv1der
27
HELPPROVIDER - allows you to setup a popup or online help for a control on a form.
~. > HScroDBar
28
HSCROLLBAR- this control represents a standard Windo"vs horizontal scroll bar which can be used to raises
events that 1nanipulate other controls.
~ lmagel.Jst
29
IMAGELIST - Use tl1e I1nageList to store a group of i1nages tl1at can be accessed by other controls, such as the
ListView, TreeView, TabControl, or Toolbar.
25 http://info.sapien.com/index.php/guis/gui-controls/the-folderbrowsermoderndialog-control
26 https://msdn.microsoft.com/en-us/libra ry/System.Windows.Forms.FontDialog.aspx
27 https://msdn.microsoft.com/en-us/libra ry/System.Windows.Forms.HelpProvider.aspx
28 https://msdn.microsoft.com/en-us/library/System.Windows.Forms.HScrollBar.aspx
29 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-imagelist-control
128 I PowerShell Studio -A Comprehensive Guide
A Label
30
LABEL - Creates a clickable text box. Use a label to display text strings. Allows only one line of text, no wrap,
and no multiple lines.
A Linld..abel
LINKLABEL - same as a LABEL control except the tex.1 is a clickable hyperlink.
=: ListBox
LISTBOX - creates a box for displaying a list of selectable items. This can be manually populated or dyruunically
populated .
t ~-
.) .ii "
Listview
31
LISTVIEW - The ListView is a hybrid display. It is tnore co1nplex than a ListBox, but also can display data like
a grid. A ListView control allows you to display a list of ite1ns with item text and, optionally, an icon to identify
the type of item. For example, you could use the ListView to display icons in a similar fashion to the Window' s
File Explorer.
....
1-1 MaskedTextBox
32
MASKEDTEXTBOX - Use the MaskedTextBox to distinguish between proper and i1nproper user input. By
using a mask, you can specify the fonnat of the input without custom validation.
[:- MenuStrip
MENUSTRIP - used to create a clickable, expanding inenu bar within your GUI for1n. You are probably most
fa1niliar with seeing tlris displayed at the top of applications.
a
...;...
MonthCalendar
MONTHCALENDAR - used to create a calendar style selectable date control, this is nonnally used for actions
tl1at can be triggered by a specific selected date.
:!!!I Notifylcon
33
NOTIFYICON - Use the NotifyIcon control, to alert users of special events, such as when a task is co1npleted.
30 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-label-control
31 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-listview-control
32 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-maskedtextbox-control
33 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-notifyicon-control
PowerShell Studio - Basic Orientation I 129
: NumeridJpDO!/\'n
NUMERICUPDOWN - this control is very si1nilar in appearance to the DOMAIN UPDOWN control we
discussed earlier but supports customizable numerical lists.
~ OpenFiJeDtalog
OPENFILEDIALOG - Displays a standard dialog box that pro1npts the user to open a file .
0 Panel
PANEL - creates a panel that you can customize by color, border, and background. Typically used to group
specific controls within a form for designability .
0
PKtureBox
PICTUREBOX - used to insert your own graphic in your fonn. Accepts follo\ving file ty pes; .bmp, .gif, .jpg,
.jpeg, .png, .ico, .emf, and .\vmf
ITID ProgressBar
34
PROGRESSBAR - Use a ProgressBar when you need to show the user that progress is being made in some
operation, sucl1 as copying files.
ITID ProgressBarOverlay
PROGRESSBAROVERLAY - This progress control functions exactly like the typical progress bar, with the
added ability of displaying a text percentage over the progress bar.
~ PropertyGrid
PROPERTY GRID - Provides a user interface for browsing the properties of an object.
@ Rad10Button
35
RADIOBUTTON - Use a radio button when you want to present users \Vith 1nultiple cl1oices, but only allow
thetn to select one option. Radio buttons behave like a CheckBox Control, except tl1at they work in cottjunction
with other radio buttons.
34 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-progressbar- control
35 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-radiobutton-control
130 I PowerShell Studio -A Comprehensive Guide
~A RKhTextBox
RICHTEXTBOX - creates a Windows rich text box which supports multiple lines, and font customization.
= SaveFdeOialog
[I) SpbtContainer
SPLITCONTAINER - creates a design area that is divided in two by a sizable bar, either horizontal or vertical.
+I+ SpUtter
SPLITTER - Represents a splitter control that enables the user to resize docked controls. This is superseded by
SPLITCONTAINER and is available only for back"vard compatibility reasons.
b:_ StatusBar
36
STATUSBAR - Use the StatusBar control, to display status information to the user. The StalusBar can also be
used for user interaction but typically plays an infonnative roll.
L StatusStnp
37
STATUSSTRIP - Use the StatusStrip control, to display status infon1-iation to the user. The StatusStrip serves as
a replace1nent to the StatusBa.r and offers inore support for user interaction than the StatusBar by allowing you to
add buttons, progress bars, and other controls.
LI TabControf
38
TABCONTROL - Use the TabControl when you \vi.sh to present a series of related controls that a.re separated
into individual pages which can be selected by a tab.
fo Tablelayoutpanel
TABLELAYOUTP ANEL - Represents a panel that dynainically lays out its contents in a grid co1nposed of ro\vs
and colu1nns.
36 http://into.sapien.com/index.php/guis/gui-controls/spotlight-on-the-statusbar-control
37 http://into.sapien.com/index.php/guis/gui-controls/spotlight-on-the-statusstrip-control
38 http://into.sapien.com/index.php/guis/gui-controls/spotlight-on-the-tabcontrol
PowerShell Studio - Basic Orientation I 131
1sbi1 TextBox
39
TEXTBOX - Creates a teA't box for displaying text and collecting user input in teA't format.
G rimer
40
TIMER - Creates a timer that raises an event at intervals that you specify. Use the Timer event when you need
to run code repeatedly at a specified interval. For exa1nple, you can use a Timer control to check the status of a
process once every second.
~ TootBar
TOOLBAR - Represents a Windows toolbar. Replaced by TOOLBARSTRIP, and is retained for backward
compatibility.
~ ToolStnp
TOOLS TRIP - Provides a container for Windows toolbar objects.
~ Toofrip
41
TOOLTIP - Represents a small rectangular pop-up vvindow that typically displays help for the feature. The
tooltip appears when the mouse hovers over the control.
Q- TrackBar
., _
42
-
! ::- TreeView
TREEVIEW - Displays a hierarchical collection of labeled ite1ns, each of which is represented by a TreeNode.
~ VScrol!Bar
VSCROLLBAR- creates a standard Windows vertical scroll bar.
39 http://info.sapien .com/index.php/guis/gui-controls/spotlight-on-the-textbox-control
40 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-timer-control
41 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-tooltip-control
42 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-controls-the-treeview-control
132 I PowerShell Studio -A Comprehensive Guide
WEBBROWSER - Enables tl1e user to navigate Web pages inside your fonn.
-
,,..................................................................................................................................................................................................................................._,,................................................................................. ........................................................................................................................................................................................................................................ ..
@ BUTTON-MENU BUTTON
Inserts a button that displays an ite111 configurable expandable menu.
~ COMBOBOX - COUNTRIES
Inserts a combo box containing all world countries.
-a:
FORM - JOB TRACKER
Adds the framework to 1nanage jobs in a GUI, \<vhich are used to create responsive forms.
r.=JTEXTBOX-VALIDATEBIRIBDAY
Inserts a 1nasked textbox that validates birthdate entry.
~ TEXTBOX - VALIDATE IP
Inserts a 1nasked textbox that validates IP address entry.
r;_ TEXTBOX-VALIDATEPHONE
Inserts a 1nasked textbox that validates US telephone number entry. Mask is (999) 000-0000.
~I TEXTBOX - WATERMARK - Inserts a text box with a light gray "vatermark when the textbox is not
currently selected and the user has not typed any input.
134 I PowerShell Studio -A Comprehensive Guide
Office Life
-
-
Chapter 3
Form
I SCCM Gert -Oiock I oz I Rerww SCCM c..i I or. Ent4r COllllJIUt.er n.... l >
Complete SCCM 01en1 He ant! Check BenewSCCM Ce!l!fica!e ,..
111oo1,....,.awnel"''"'e-d>Od< onlhe SCCMO... Tho !ool ,........,., an frwllldceolic:Memlhe _ _.,_a,_
1 0 - . .. r<q..nd Ml'lllCel ... n.mrig """'1cMebe muodbylhe Sile S..-. In ""'*lc:ert6c:i<elsonedlhe.,..
2.0-. -dV/Mlw1-1 r d - - - l h l l . . . t ..... an SCCMd<ttiobowme-
3 0 - . DCOM Id lo ONlllod
4 0-.lhlll!Md<l<--15'%
5 0 - . SCCM CMllateolat.......,, ....s.- .,.::hiig [~SCCMO... l oz
I
k
Sl!e Seiver Sile Code
, .. a- Ta.I< 5-enot Oll
Unjn313Mnsta8 SCCM Clienl ' - - - - -...- ......
Clean SCCM Task Sequences Thishn:uon ... _ . . , _ l h e SCCJI den RICHTEXT
- - - Han!lr'llSCCMTaolc~can-llC>oeo*".a-110""'ll-SCCMl.ll>dltea0tWSUS eatofal 1 AeancoPodloallylOlhe_e_llion.
This1ool ... doar"'f laoi< _,.,,.,..lhll moyhoYelaledlatone,_ at onolhet. ~- SCCM _,., US a 2.0e.irw..,lludc~onlhe- BOX
cllance IO.....,. l>U!l"'!I \Jl>dales 3 ~lhean'O!t SCCMd<rt.lhonlM>!Ulslhelllest SCCMdenlOll-nro
4 The repootayla..tlul .-.d VII!! ~lapedooned
I~ SCCMO..~ I 01';.
1 """'''--.; ~.. I or.
SCCM Cfien1 Beoair M1SSJOQ UQdajes
Tholool"'1-lhe SCCM0...10 pofomi . _ n- aa 7......,.........., onlhe "'1'W1
a.t..-..Y"'ll>e--.lhl ISIO-lhe tali<fnwwniumgll>e ,_,,_.,..., ThisMclion...tdoc>laylllhe-\Jl>daleaon -..
..
l'Jt-Toolo iii fftShnTodo !I-~ !i) U.VU.....aSollwn ~ """-~
ll SCCMa...Toolt .!!. wsus....... "'....,.....,..,. ii;l)os- .... ... ~.. P "'-Todo 1!11 _T.... -...,r.... ~ ""'T""' 9 """""T"" .a \Joe(T.... o-..
wsus~
~!rid lnsclll()ptlons
0 l<c<fyb<t... - ...........
@ lu.odo1rioact1Ncd'rd~
o ,.,,,....,,..,_....,_
VSUS
& .. -....
S.t"V'9.1" fl'_...
J
Por~
._@
s30_ __,
t
:s- "' :l t""' r.., :
0 1o1.o~...........,
,
hlt-.IMt.x~~?
- ""''*"'On U-l
~t~ . . . . .. ~-----~
............
Q i*'ltUMl'IOdtao.~toM;Q't
y., . Sidt 0 ........ 111... - ..
NoclyustrkCOft:Sl'.att.._ 15~
Lon,d>d,.... w--.. u ..- , _,.. How <I?., lo c:hocik (or"~ l.Odll:?
Oofo.A 6mn oa - - @E...,.22""' 0C....,.Holn
~. """" :, 1Solocr ""' :
Vtmon 2:.2.1
Every GUI application shottld start with a good foundation and \Ve11 planned design layout; this will save you
countless hours of re-work later. You should al"vays consider "vho will be using the form, what are their needs,
and \Vhat are their skill levels. Will your fonn be fixed or "vill it be sizable? Is there a maxi1num resolution
constraint that you need to adhere to? Do your research no\v and save a lot of headaches down the road after
you've deployed your forms.
If a floor is the foundation to a home, then tl1e fonn is the foundation for all applications. Before you start building
your nlasterpiece it is important that you understand what exactly a fonn is and \<V hat are tl1e different fonn templates,
and when to use which each one depending on the tasks that you want to accomplish \Vith your ne'v form.
This 1nay sound daunting, but SAPIEN has pre-built many cominon form templates already for you! And \<Ve will
get into that in just a moment.
138 I PowerShell Studio - A Comprehensive Guide
New PowerShell Script Ne'v PowerShell Scri1>t - tlris is used if you \.Vant to create a simple
Creates a new PowerShel Scnpt (.ps 1). PowerShell script without a GUI. You will notice with this type there is
no "Designer" tab and all controls in the toolbox are greyed out.
New Form
Creates a new GUI based scnpt (.psf).
New Form - this will launch a dialog ':vindow to select the specific form
te1nplate that you want to use. There are 11 different fon11 templates, and
New Project
Pro,JeCts are used to work VYlth nUl:iple one empty form to choose from.
files.
New Form Project We'll be discussing Projects ai1d Modules in the next section, for now
Creates a new GUI based project. we will focus on the form because this is the foundation of al1nost
eve:rytlring that you ':vill do in Po,verShell Studio. We also ':vill provide
New Module Project several tips when it comes to dealing with 1nodules, and ' vhen they
Creates a new PowerShd ~t modlJe
project. should be used and 'vhen you are better off living without them.
New Module From Functions
Creates a script mocUe by selecting
fmcbons from eX1sting ~ts.
New Module From Help File 3.1.1 Blocked Forms
Creates a script modU.e by denvrig
functions from a Pov.erShel help file.
If you have ever gotten a form from a friend, co-\vorker or downloaded
011e fro1n the Internet you have probably been frustrated 'vith the form
being blocked. This is a prevent an unknown file that did not originate
from your co111puter from being
executed ':vithout your kno,:vledge. ! Unblock file
You probably also noticed a yellow triangle next to the open fonn name on the
file tab. If you know for certain that the file is safe, silnply right-click on tl1e file na1ne on the tab, and select Unblock
File. Iffor some reason after doing that it doesn't seem to unblock the file, you nzay need to right-click a second
time and select "Reload Document".
Willie it is i111possible to create, predefined te1nplates packaged with PowerShell St11dio that can fit every scenario
or every user need, SAPIEN has done a great job putting together some co1nmon starting point te111plates.
There are 11 different form templates available for you to choose from, 12 if you include the Empty Form template.
Form te1nplates give you a quick starting point \.vhen creating a new fonn or project.
Thankfully SAPIEN had the forethought to provide the ability, if the predefined templates do not meet your needs,
to create and save your own templates.
PowerShell Studio - Form Design and Projects I 139
You can also choose from 7 different border styles for your form to give it that unique look and feel.
None
Yes, you are not seeing things, literally! There is no way to close
the fonn \Vithout killing the running process. Useful if you are
building an application that users should not be able to exit out
of, like a Kiosk.
t1J Form 0 x
Fixed Single
This border style provides a nice clean crisp style, with Title Bar,
Icon, and Control Box.
Form 0 x
Fixed Dialog
Can you spot the difference? There is no icon, other than that it
is basically the sa1ne as the Fixed Single and Fixed 3D styles.
140 I PowerShell St udio -A Comprehensive Guide
Pi Form D X Sizable
This sty le adds the size control in the lower right corner of the
fonn, allo"ving users to resize your form. This is tricky unless
you've designed your form correctly this can thrO\ all your
form controls out of alig1unent, and your design \ill look very
.... unappealing .
...........
...........
........
...
Form
Empty form
$ti j Creates an Empty Form
Generates a basic 300x300 pixel bla1lk form. Once you have become proficient at creating GUI forms this will most
likely be the default type that you will choose.
1';0000000 0000 . . . . 0 0 0 0 0 0 0 0 0 0 0 0 U 0 0 0 0 0 0 0 o 0 o 0 0 0 0 00 . . . . . . . . . . U o 0 0 0 0 0 o 0 OOH000000 0 0 o 0 0 0 0 0 n o O o O o o o 0 0 0 0 0 0 o o ooOoOo000000o00 00oo 000000 00000 0 0 0 0 .... 0 0 0 0 0 0 0 0 0 0 0 o 0 Uo 00000o0000000000000 ... 0000000000o00o0000H0000000oOoo0.000000000000000000000000o00000o0o00000 0000
While it might seem like the least interesting template you would use, it will become the 1nost used starting point
for your GUI forms that you build in the future. As you advance in your knowledge of Po"verShell Studio it is likely
that you will create your own te1nplates, a11d we cover that in this chapter as "vell.
All fonns contain the basic Windows Fon11 design area with Title Bar, Icon, and Control Box (Minimize, Maximize,
Close). You can remove the Control Box completely, or you can remove only the Minilnize or Maxi1nize buttons,
or both.
142 I PowerShell St udio -A Comprehensive Guide
Generates a 290 x 291-pixel fixed form, with no minimize or maxi1nize buttons. A basic button, labeled "OK" is
also created.
Notice the "O" in "OK" is underlined. This is acco1nplished by enabling the !Text &OKJ
"U seMnemonic" button property and assigning "&OK" as tl1e button text. This is TextA5gn tliddleeenter
TextlmageRela Overlay
probably more familiar described as a Hotkey. In this example, you could click the
( UseMnemonc True J
"OK" button with your mouse or press ALT+O on the keyboard. UseVISUalSty!eE True
UseWaitaxsor False
Form ~
I QK
There is no code generated with this template except for the standard fonn_load event.
PowerShell Studio - Form Design and Projects I 143
Generates an Explorer style layout \ith 43TreeVie\ and 44ListVie"v controls. This can be used to create your own
custom tree in the TreeVie\ on the left, with nodes and subnodes. Each node or sub nodes can be configured to
display a collection of items in the ListView on the right.
aC Form
This ten1plate generates the default event code for the TreeView control (AfterSelect). W11en a node is selected in
the TreeView, the code you place in the AfterSelect event will be executed.
43 http://info.sapien.com/index.php/guis/gui-controls/spotlight-on-controls-the-treeview-control
44 info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-listview-control
144 I PowerShell St udio -A Comprehensive Guide
Generates a form that can be useful for many different search and results projects including installed software
searches. The template uses the following form controls: Textbox, Button, and DataGridVievv.
Qu~ry
;:::::-::::==-~-===---=:::::==-=-=--==-~--=-=-=:--=-==-=--==-::::=-=-===-==-==-=-==-=-==-=~.-
~~~
............
:! !:
Search i
........ .
--------- ..
I
---------------------~-----------._ _________________ __________________......._____
'"' ~,..---------
- I
..--
I
: I
! I
i !
I I
: ;
l t
: I
I t
i ;
. : t
I
i
r I
i I
..
I
l
I'
't
.i:, t
I'
:t
.:
:
i
'
: t
i: t
t
; f
: I
i !
l !
ll Ii
.
t___ ........................._.,,,_...______________........,__________-..-________. -------- ---------------------.. - ......---.. . . . . . . -- ___________ ;
'
I
'~""'
"
""""'""'
"""""'
""'
-=.-...,""'"-"'-""'
'""'
--""'
-"""
-=-.,,..
.-=.=""'
,...,,__.,...
__..,...
-= - """'
= -"""-.,...
-"- .,..,..,.,.,,."--~
"'""' "' - --=-,......,.,
-=-=""'
--"""""'""'
-==-"""
--""'
-"""-"""
-..=.=-==
-="""
==
---""'-,....,-.,.,....,,.
--=""'
""'
--""'
-'""'
~
figure 81 - Grid Job Template
This is an easy te1nplate to start out "vith when leanling how to i1nple1nentjobs into your forms. Once the form is
created simply switch to the code editor and go to the $buttonStartJob_Click event and enter the code that you
'v ish to nm.
146 I PowerShell St udio -A Comprehensive Guide
au Grid Search
------------------- [ ~arch
This will "vork fine witl1 data collection that is not time consmning or syste1ns that have a fast response tune, however
if the query takes more than a fe,v seconds the GUI "vill freeze and display a (not responding) message in the title
bar. This can confuse users into thinking that the application has hung. You should use Jobs if you have issues with
this happening.
PowerShell Studio - Form Design a nd Projec ts I 147
Grid Template
Creates a form with a grid.
Generates a fonn that consists of a basic form with a Data ViewGrid control and two button controls (Load and
Exit). U nlike the Grid Search and Full Grid Search templates, it does not provide search capability within the
DataVie\vGrid, but it is a basic starting point.
oO Grid
("
. . - J
Beginners of PowerShell Studio will fiI1d this is a great example for learning the basics of working vvith a
D ataGridVievv. For an in-depth look at DataGridView controls, read the Deep Dive chapter on controls.
148 I PowerShell Studio -A Comprehensive Guide
r-tenu Template
Creates a layout with a Menu
agJ Form
File Edit Help
I
j
!
-~
-----
----
--.- ---_.----...- -- ---
....... ... ....... . .. ...... ............. -
----
-----
-
-----
-----
- --
-
. --------~------------ -- - - - - --
.................. ...-. _______________.... ... .. ---
----
-------
----
-
----
--
~
---
Figure 84 - Menu Template
Each 1nenu ite1n is customizable and can consist of several sub-ite1ns. You can configure Hotkeys and Icons for
each menu ite1n .
PowerShell Stu dio - Form Design a nd Projec ts I 149
Generates a form "vith Tab Controls and Navigation Buttons, like the one shown belo"v.
...--. -- -....... - ------. --. - ............... --. ---..-.- ---- ---------. - ....-..............- ---. -. ..............-- ----..--- -............ - --- ..-. - ......... ..... --...........
.-- .._
oSJ Form
tabpage 1 tabpage2
Tabs are easiest to understand when we think of the1n in the context being like the tabs 'vithin your Internet Bro"vser.
They allo\v you separate controls into separate pages within the same for1n, this not only allows us to organize
different fonn functions but also to add 1nuch more controls to a single form tl1an otherwise would not be possible.
The navigation buttons in this example is used to move back and forth benveen the tab pages, rather than clicking
the tabs tl1emselves.
150 I PowerShell Studio -A Comprehensive Guide
.I I
I
!
!
i
I
I
I
I
1.
!
11
Ii
1I
I
[ 1.oad ] [ ~ J [ ~ J
!.....................................--
Figure 86 - Text Box Template
In tllis example, several events and a function named "load-text" are created. The load-text function is executed
'vhen you click the Load button. The example command within the load-te:x.1 function is "$richtextboxl.Text = Get-
Process I Out-String" \vllich will quecy the local syste1n for all nmning process a11d output the list to the text box.
The Copy button silnply uses a click event and executes a series of co1nmands:
$richtextbox 1. SelectAll() #Selects all the text
$richtextboxl .Copy() #Copies selected text to clipboard
$richtextboxl.Select(O,O)~ #Unselects all the text
PowerShell Stu dio - Form Design a nd Projec ts I 151
Generates a fonn essentially the same as the previous Text Box te111plate ho\vever it also includes search capabilities
within the results.
[ load J [ Copy J
Figure 87 - Text Box with Search Template
The only difference in this te1nplate versus the standard Text Box form is the addition of the "FindTe:x.1" function
which is used to search the text box that was popttlated by the Load-Text function. This is a good example of how
to implement search capabilities into your forms .
152 I PowerShell St udio -A Comprehensive Guide
Wizard Template
Creates a wizard styfe form Nith navigation buttons.
Wizard
--
Step 1 Step 2 Step 3
-----------------------------------------------------------------------------------------------------------------------------
Enter Name:
I
I
I
Essentially this fonn works by not allowing you to proceed to the next tab (step) until the requirement in the current
tab (step) is fulfilled. Once you proceed to the next step it will however let you go back to the previous completed
step . This is a prime example of utilizing validation.
PowerShell Studio - Form Design and Projects I 153
The great thing about \vorking in an IDE is the flexibility that is available 1vhen designing forms, and PowerShell
Studio excels when it co1nes to fonn design. So, before you create your form let's go over all the prope1ties that are
available for you to custo1nize your fonns.
You've undoubtedly hear the word "forn1" and "control'>used separately a lot, however keep il1 ntind that
"for1ns" are a type of control too (form control).
We will break the properties up into inanageable po1tions for explanation purposes.
3.3.1 Accessibility
Cursor - there are ma11y selections to choose fro1n which 'vill determine the display type of the cursor as it moves
witltin the form boundaries during execution. Below is a small sample of the cursors that are available.
NOTE: Keep in mind when choosing fonts, if you use fonts not installed on all other syste1ns that 1night use your
form and a inissing font is encountered then the font will change to the default font Windows chooses, this could
154 I PowerShell Studio - A Comprehensive Guide
drastically change the intended look of your fonn. I recommend that you al\vays use standard fonts, or at least the
fonts that you k11ovv are installed on all the systenlS that inight use your fonns.
ForeColor - determines the default text color for the fo11n, you can choose from system, web, or custom colors.
Colors, it's a personal thing!
FonnBorderStyle - changes the form appearance and behavior of the border and title bar. There are seven style to
choose from; None, FixedSingle, Fixed3D, FixedDialog, Sizable, FixedToolWindow, and SizabledToolWindo\v.
Styles inay react differently also depending on the flavor of Microsoft Windo\vs that the form is executing
on, for example the same style may look differently on a Windo,vs 7 computer than a Windovvs 10
coinputer.
RightToLeft - indicates should the component draw from right-to-left for RTL languages. There are three choices;
No, Yes and Inherit. 45The most widespread RTL languages are Persian, Arabic and Hebrew.
RightToLeftLayout - [True/False] indicates \vhether the control layout is right-to-left when the "RightToLeft"
property is set to YES.
Text - the text shown on the form title bar. Doesn' t appear to be a character limit so it will run off the title bar if
you enter too many.
UseWaitCursor - [True/False] deternlines the cursor property of the form and its cllild controls. If set to True, tl1e
Wait Cursor will be displayed, and the fonn vvill be unusable until the WaitCursor is set to False.
This is typically alvvays set at "False" in the properties and changed within the script code using
"$FormName.UseWaitCursor = $true" to turn on the Wait Cursor if there is a process executing that you \Vant the
user to \vait on before continuing to use the form, then issue a "$FormName. Use Ttf!aitCursor = $false" to tum off
the Wait Cursor.
~ My form - [J x
45 https://en.wikipedia.org/wiki/Right-to-left
PowerShell Studio - Form Design and Projects I 155
3.3.3 Behavior
AllowDro1> - [Tn1e/False] determines whether data that the user drags and drops onto it \ill be accepted. Keep in
inind that AllowDrop requires STA (Single Threaded Apartment) n1ode to ftmction properly, we discussed STA
mode in the Script Engine Settings options.
Auto Validate - this will determine whether controls on the fom1 \.ill automatically be validated, if the control
supports validation, when focus changes. There are four options; Inherit, Disable, EnablePreventFocusChange, and
EnableAllo\vFocusChange.
ContextMenuStrip - this will display the selected shortcut 1nenu when the
user right-clicks the fonn. You inust first add a ContextMenuStrip control, (none)
from the Toolbox Pane, to the form before this can be used. If you have inore contextmenustrip 1
than one ContextMenuStrip control with your fonn, the dropdown selector -,00 -te_xtm_en_us_tr-ip-2----'-----~
will allow you to select \.vhich ContextMenuSt:Iip to use.
DoubleBuffered - [True/False] indicates \Vbeth.e r tl1e controls that support it on the form \Vill be double buffered.
This is often used to prevent flickering lvhen scrolling through large amounts o_f data in a DataGridT'ieH1 or other
controls. Double buffering uses a memory buffer to address the flicker problems associated with inultiple paint
operations. Whe11 double buffering is enabled, all paint operations are first rendered to a memory buffer instead of
the dra\.vit1g surface on the screen.
Enabled - [True/False] this detemrine if the fo1m is enabled for use or not. If you set this to False for a form, the
fo1m will not run and \Vill error out \Vith ERROR: Exception calling "Shoi11Dialog" lrVith "O" argurnent(s) : ''Forms
that are not enabled cannot be displa_yed as a nzodal dialog box. S'et the jorn1's enabled property to true before
calling sho111D;a/og."
lmeMode - "6deternlines the Input Metl1od Editor for the fo1111 \vhen selected. An IME is a progra111 that enables
users to enter co1nplex characters and symbols, such as Japanese Kanji characters, using a sta11dard keyboard.
3.3.4 Data
DataBindings - DataBinding ca11 be ve1y con1plex under tJ1e hood, but ttltimately it 1nakes tllings easier for the
sc1ipter/developer by preventing 1nanual ma1lipulation of controls. Tllis is normally used iii conjunction with
forms and specific controls that accept databinding, such as Te>..1box or DataViewGrid. It can be used to bind to an
external source such as a SQL database table.
3.3.5 Design
v Design (Name) - this is the name used in the script code to identify the object, in
{Name) formMy'form
locked False
this case the form. If you change the object ruune PowerShell Studio will
v Focus automatically update the name throughout all the sc1ipt code for you.
CausesVafidabon True
v Layout
Loc.k ed - [True/False] locks the object fron1 being n1oved or resized. This
AutoScaleMode Font
AutoScrol False has no locking effecting on a fonn itself.
> AutoScrolMargil 0, 0
> AutoScrollMinSlze 0,0
AutoSlze
AutoSizeMode
False
GrowOnly
3.3.6 Focus
> Locabon 0, 0
) Maxm.imSize 0, 0
CausesValidation - [Tn1e/False] determines if the component raises
> MinimumSize 0,0
validation events.
) Paddrlg 0, 0, 0, 0
) Size 555, 454
Star!Posrtion \~rndowsOefaultl.oca tion A validatio11 event is so1netbing that typically is niggered to execute Ji
WndowState Normal
v M""tsc
certain event occurs. For insta11ce, you nlight have a piece of code that you
AcceptSutton (none) \Vant to run if a form " closing" event happens, or you might want to trigger
CancelButton (none) a validation event if a specific control has focus or loses focus (meaning
KeyPreview False
v
the mouse moves onto (focus) or away fro1n (lose focus) the specific
Window Style
ControlBox True control.
Helpautton False
) Icon ~ (Icon) There are also two events associated with validation, validating and
lsMdiCon~ False
ManMenuSbip (none)
validated, which is covered in a later chapter.
MaxirnreBox True
MinimlzeBox True
Opaoty 100/o 3.3. 7 Layout
ShowIcon True
ShowlnTaskbar True
SizeQipStyle Auto
AutoScaleMode - deternlines how the fonn or con.trol will scale when
TopMost False
TransparencyKey D either screen resolution or fonts change. T11ere are four options; None,
Font, Dpi, Inherit.
Most business applications should use the Font automatic scaling mode. The Dpi scaling 1node is useful for graphics-
based applications and is co1npatible \-Vith the default scaling used by the .NET Compact Frainework. This is
typically because Auto Scaling by Font is used when you have a user that inight have bad eyesight ai1d that user
11eeds to increase font sized, you wouldl1' t want to manually control resizing of every child co11trol. Ho\vever, Auto
Scaling affects ALL controls, even controls that do not display fonts sucl1 as picture box controls.
PowerShell Studio - Form Design and Projects I 157
47
Scaling by Font is useful if you \Vant to have a control or form stretch or shrink per the size of the fonts in the
operating system, and should be used when the absolute size of the control or fonn does not n1atter. Scaling by Dpi
is useful when you want to size a control or form relative to the screen. For exan1ple, you inay want to use dots per
inch (DPI) sca1ing on a control displaying a chart or otl1er graphic so that it always occupies a certain percentage of
the screen.
automatically appear when the control elements are larger than "
the visible area.
L In both examples when the control "butto11l " touches the right or botto1n of the
>
form and you continue to shrink the form, the button will not go off the forn1,
but rather will begin to 1nove with the fo11n, staying against the side or bottom until resized to normal size.
AutoScroUMargin - [Width/Height] determines the 1nargin around a control during auto scroll. This is set in pixels.
AutoScroUMinSize - [Width/Height] detennines the Ininim1un logical size for the auto scroll region. Tllis is set in
pixels.
AutoSize - [True/False] determines if a control will automatically size itself to fit its contents.
For example, using a button control, in tllis case "buttonl" and tl1e button text is changed "vitlrin the script code
results would be as f ollo\vs:
$buttonl .Text = 'The button will auto size to fit '
115' My Form 0 x fl9 MyForm 0 x
AutoSizemocle - [GrowOnly/Grow And Shrink] deten1lines is a control can only grow to fit its contents or if it can
also shrink to fit its contents. AutoSize nzust be set to "True "
In this example, \!Ve have a button control, buttonl, \!Vith default text of "My First Button", within the script code we
change the button text to "Button".
You can see that with GrowOnly the button stays relatively the sa1ne size when we reduce the size of its contents,
ho"vever, with GrowAndShrink the button size \vill also shrink when the contents are reduced.
I Button I
GrowOnly
'00 My Form 0 x
I Button I
GrowAnd Sh rink
Location - [X,Y] this is the X,Y coordinates of the control relative to the upper-left of the container. (X) is the
distance fro1n the left border of the display area and second nu1nber (Y) is the distance from the upper border of the
display area. For this property to have any effect on a form, you must also set the "StartPosition" property of the
form to Manual.
MaximumSize - [Width/Height] determines the maxiinu1n size the form can be resized to. You 1nust be using a
FonnBorderStyle that allows resizing, such as "Sizable" and "SizableToolWindow", or this will have no effect on
the form.
MinimumSize - [Width/Height] determines the minimum that a form can be resized to. The same requirements for
FonnBorderStyle that applied to MaximumSize also apply to this property.
Padding - detennines the INTERIOR spacing within a control; ~ My Form 0 x
left, right, top, bottom. If all sides will be the same, then you
only need to specify the padding value in the "ALL" property .
Do not confuse this \Vith space around outside of the control. In
the example on the right, the dark gray area is a large button,
the padding is for the interior text nanie of the button, not My First Button
StartPosition - detemlines the starting position of the fonn when it first appears after execution~ there are five
positions ~ Manual, CenterScreen, WindowsDefaultLocation, WindowsDefaultBounds, and CenterParent
CenterParent The form is centered \vithin the bounds of its parent form.
CenterScreen The form is centered on the current display, and 11as the dimensions
specified in the form's size.
Manual The position of the form is determined by the Location property.
Win clo,vsDefaultBounds The fom1 is positioned at the Windo\VS default location and has the
bounds detennined by Windo,vs default.
Winclo,vsDefaultLocation The form is positioned at the Windows default location and has the
dimensions specified in the fonn's size.
Winclo,vState - [Normal/Minimized/Maximized] determines the initial visual state of the fonn upon execution.
3.3.8 Misc
AcceotButton - by selecting a button control on your form, if a user hits tl1e enter" key on the board it will react
as if the selected button \as "clicked".
CancelButton - by selecting a button control on your form, if a user hits the "esc" key 011 the board it \Vill react as
if the selected button was "clicked''.
48
KeyPreview - [Tn1e/False] detennines \Vhether keyboard events for controls on the fonn are registered vvith the
form. This property was inherited from back in the Visual Basic 6 days \Vhen you needed Key Preview to implement
short-but keys, however th.is isn't needed anymore in Windows Fonns. The whole point of Key Preview is to allo\.v
tl1e UI to respond to a sho1tcut keystroke. Normally keyboard messages are sent to the control that has focus. Setting
tltis to True doesn't cause any proble1ns, if the fonn's Key Down event will n1n, however it doesn't have any affect
if tl1ere is no code associated \Vith it.
ControlBox - [Tn1e/False] deter1nines if the form has a Control/system inenu box, this consists of the Minimize,
maxi1nize, and Close buttons, as well as the fonn icon.
48 https://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview{v=vs. l l 0) .aspx
160 I PowerShell Studio - A Comprehensive Guide
HelnButton - [True/False] detennines \Vhether the form has a Help button on the caption bar. Both MaxilnizeBox
and MinimizeBox properties inust both be set to "FALSE" for this to work properly . This \Vilt display a s1nall (?)
mark button to the left of the (X) close button in the caption bar.
You can use a HelpRequested event handler like the one above to executes specific code if the (?) Help button is
clicked.
YProperties JJ x To easily add the HelpRequested event code to your for1n follo'v these
steps.
w sformMyForm: System.Windows.F. ~
I~ '.El ( J 1. With the Form selected in the Desigi1er Pane, click on tl1e
~ ""'------ l'I
Mou~apnre<
"Lightiring Bolt" in the Fonn Properties Pane, tl1is \Vill switch to the
MouseCkk available events view for tl1e fonn.
MouseDoubleO
Resize8eg11
2. Double-Click on the HelpRequested event, this \vill auto1natically add
ResizeEnd the event code \Vithin the script editor.
Scrol
v Appe.a rance 3. To switch back to the Form Properties, si1nply click the u:1 Properties
Pant
v Behavior Icon to the left of the Lightning Bolt (events).
OlangeUICue.s
ControlAdded Icon - detennines the Icon (.iso) ilnage that is displayed at the far-left
Contr~emove
FormOosed
con1er of the caption bar of the form.
FormOosing
HelpButtonCkl<
HelpRequested formMyform_Hel1
~
lnputlanguage
lnputlanguage
load formMyform_loa>
?
x
QueryAcces:sib
IsMidContainer - [True/False] determines if the fonn is a MDI container. A multiple document interface (MDI)
is a GUI in which multiple \Vindows reside under a single parent \Vindow. This allo,vs you to create an application
that maintains n1ultiple fonns \Vitlrin a single container form. Some exa1nples of MDI are Microsoft Excel and
Microsoft Word.
In the example belo\v I have created a si1nple form (Test_MDIFom1.psf) \Vith an object name of (fonnl).
IsMidContainer is set to True, and a MenuStrip (1nenustripl) has been added, \:vith a menu ite1n of (Forms) and a
child item of (Child Form).
11...J Form Event code ($childToolStripMenuiten1) was generated for the child menu item (Child
Fonn) by double-clicking on the menu ite1n within the desig11er.
Forms
Child Form
PowerShell Stu dio - Form Design a nd Projec ts I 161
71? $childToolStripMenuitem_Click={
8~ $child = NeH-Object System. Hindows.Forms.Form
9~ $child .MOIPar ent = $forml
10; $child . Text='Child Form'
11 ~ $child . Show()
12 ~ }
The results are shovvn below, a child fonn is novv sho\.vn within a parent form:
09 Form 0 x
Forms
-- - --
aSJ Child Form
---- 300~
!
I
I
I
In this example, there are two child forms, one is open and the other is 1ninimized within the parent fonn.
a9 Form 0 x
Forms
Even though several years ago, MDI was all the rage and every developer vvas using it, Tabs are the preferred
inethod today. There are still some specific uses for MDI so it has been included here to demoinstrate that you can
build the1n with Po,verShell Studio.
PowerShell Studio doesn't support MDI because it doesn't work well in PowerShell
due to the nature of the code. This doesn't mean it can't be done, but it will require
manual coding.
You can use another psf to design the chi ld form, but you must modify the exported
code because it generates a function that returns the form's DialogResult, which will
not work for MDI. Therefore, you would have to modify the code by:
1. Making sure the form variables do not go out of scope. Use script scope and
make sure you don't use the same names across forms.
2. Change the Form's ShowDialog() method call to Show()
3. Pass the MDI parent to script so you can assign it to the form.
Interesting enough, you can also use this method to display multiple forms at the
same time (non-modally).
The obvious downside is that after making changes to the GUI in the designer, you
must repeat the steps above. The manual manipulate is the reason we don't
encourage people to go this route.
MainMenuStrip - if you have added a 1nenustrip control to your fonn it will be selectable. This specifies which
menustrip will be the primary for the form. This used for keyboard activation and automatic 1nerging in MDI.
MaximizeBox - [True/False] determines if a Maximize control is presented on the form caption bar.
MinimizeBox - [True/False] determines if a Mini1nize control is presented on the form caption bar.
Opacitv - [Oo/o-100%] determine the transparency (opacity) of the fonn.
Sho'v Icon - determines if an icon is displayed in the far-left of the title bar.
ShowlnTaskbar - [True/False] detennines if the form "\vhen executing will appear in the Windo,vs Taskbar.
SizeGripStyle - [Auto/Sho,v/Hide] determines if the sizing grip will show on the form.
TopMost - [True/False] if set to True the form will always be displayed above other windows that do not have
this property set. Normally this is set to False to avoid user frustration.
PowerShell Studio - Form Design a nd Projec ts I 163
TransnarencyKev- sets the color that will appear as transparent when painted onto the fonn. Default is white.
In this section, we will walk through the process of creating your first fonn, configuring fonn properties, adding
controls, events and script code to 1nake a functional fonn. Jfyou have already installed PowerShell Studio you can
perform these steps as we go.
D
,. Nl'W
Open
~
~
@j
New PowerShell Script
Creares a new PO\\erShel Scr1lt (.psl).
New Form
-b3
Cr~tes a new GUJ based SCJ'1)t (.psf).
Open Project
~. Save As
ra New Form ProJect
Creares a new GUI based pro)t.
Ed Save All
ra New Module Project
Creates a new PowerShel saipt mocUe
pro)Kt.
Create Template...
@
-.:-
Print ~ ra New Module From Help File
Cr~tes a S0'1Pt mocUe by denvng
fi..ncbons from a Powe-Shel help fie.
Oose
Close Pr0Ject
OpllOnS x Eiat
Figure 90 - New Form
After selecting "New Form" you will be presented with the fo r1n selection dialog
Empty form
~ Creates an Errc>ty Fonn
ifo 1
Dialog Style Template
Creates a fixed border f'orm that has no minmze 0< maxm.ze buttons
-.-
.....
~~
.., 1::
Soll~Ccrwof
- - .= m..... ""'
~ ....,,-
m., .... c.-< lf~H(lrllQl'lt.ll~
f...-...-i-.
@c.....-
11 .. !!J ~1 ::::.':.7'
-
A 'i"' 6
0
Ii~
x
- -
ill ""T Slit 0 c.cnim
=.i ...
... ("""' t) s...o...._.._ _,.,, 51 Tab Order-
iJy
A'Ol)ertyStl Uitre.afonnT~
Con11al
Re!tf~
t: fji ~
----------------------------.., :lJv Properties
~t: s~.Wrrdows.Fotta.F... v
x
~--
~ ............""'111
---- - -
Tt form
:3J rcidufllo;c$1U().!oo
ill 'ofdw'&o '10dtiO.-OO
...........
UWW!Onor Fehie
."9owOtCC>
-
f'altc
id3 FOtlOaloo '1t.110Vlicltll: ~roa..c
1" - Coo<ax"""'51~
-..... ~f&fecF-tibe:
.J-
t.> HScto&tr
A .-
a-
,.,..
[~IA-
- - - - ---- -
- - 1- t - - - 1 L)ycut; Aull! Li.raut >. I - 'v NUM I W I \Jlie: 6 Col: I Ow: I 11
To change the default text "Fonn" at the top of your new fonn, in the properties panel under " Appearance" change
the property "Text" to whatever you vvish. In Fig. 4 the nanze was changed to "My F orm ".
- 0 x
q 0
rl C<n _....,
A
El
l'
c:no00ox
fdol
x
ill Aq\8ollomc
~ """'
~
!'! c.n...
= ~To~Ntd:tl
QI ""
--------------------------~ y ~ope~
5':e
- ~----
Sooo-'OQ
11 Cont<' vnatv
Poollion
E::f TobOrdor
......
fj~ o-..to ConvolS.t
Pl'-iys.1 lf;l ereatefarmT..O.te
T..0.:.S
Conol
Refmnc<
Hol:>
x I
i m c:iii.. 1 ~ ..) $lolnftyf'ouu: Svs:ttm.Wlndows.F. v
"
If
@~-
.. Owt
l
IS
v Accessibility
A--.0
i El
D~
Cheddlox
v
., l':Mv
-DcfaUt
Appear.&~
~ Cdoto.aloo D eono1
BilclcCo1o<
~ c.mbc8ox llad<v....-0 o->
! Contex""""5lre> ~Tl<
/;:lOotoGrd ea- DcfaUt
.,J OotoGn!Mew > ftont Mlaosoft ~Senf.
OoteT- for.colo! Convo!T<XI
o
o~
- f"""8an:lorSt~ St:able
RJ\tltToleft Ho
z;l 1'4eSys...,Watr:het Rlcihllal.tuy , ....
,,. fbwlll'f'Ol,ltP~ Tat Hyfonn
o
__
Ust\Vaitanor Fake
;.I) Fdde8tGSEiC
'ill - .........
;.i3 Fcnll>olog
-""""" AJo.<l<op , ....
--
AutoV*bbe ENblt?reventfoaJst
w \,rOlllllox
ConW<tMenUSt 0-) ,.,,.
.J-
~--
A Lob.i
a.-
NiCled
"""'"'loo-
TM
~ ldlllo
- - 1- + - ....,..,..
----
"""' ,.,.... >. I '. ' ,, NUM I UlNI 1....: 6 Cd: I Ow: I
The form background color, background image, default font settings ai1d form border st:y le can. all be set within the
fonn properties. You can also resize the fonn by using your mouse to hold down and drag eitl1er the right iniddle,
PowerShell Studio - Form Design and Projects I 165
lower right comer, or bottom of the form. In Fig. 7 you can see we have changed the background image and we
have enlarged the size ofthe form.
;n test.psf x
~~~~~~~~~~~~~~~~~~~~~~~~
Y Properties q. x
v Accessibility
~
AccessOleNam<
Ac=sb!eRole Oefadt
v Appearance
Bod<Color D Conlrcl
> Backgo'CUldlma Sy stem.Draw
~Tile
Orsor OefaUt
v Font l>'ocroo>oft sans Serif,
Name l!fil Maosoft Sans
Sue 8.25
Bold FoiSe:
GciOlal'~I 1
GGVerbcall False
Italic Faioc
S!nkl!OUt F~
~False
For~ Conlrorrext
Forrri!orderStyl Sizable
Rlghtroleft
- '- . ""
Bad<9roundlma.g e
No
-. v
What are fonn projects? Si1nple question, with a relatively 1nore complex ans\ver! At the ground level, we can say
that form projects are a collection of 1nultiple forms into a single GUI application vvith more than one windovv.
Not to be confused with an MDI fortn which can contain several child for1ns within the parent fonn. In a fonn
project, we call this 1nodal windows, where one form can open another form, and that form can open another form,
and so on. Each new fon11 opened by a previous form is called a "child" and if that "child" form opens another fonn
then it becorn.e s a " parent" fonn as well as a "child" of its parent. Confused yet?
( PARENT
] CHILD/PARENT CHILD
In a 1nodal window structure when a clrild form is opened the parent form beco1nes disabled until the child form is
closed, this is a means of passing control fro1n the parent to the child, then back to the parent when the child closes.
The 1nethod (ShowDialog) is used \.vhen opening a child form, and when the child form closes it returns the
(DialogResult) back to the pare11t, the Dialog Result tells which button on the child form \vas used to close the form.
166 I PowerShell Studio - A Comprehensive Guide
Fie
-- - - -~
To create a nevv Form Project, click on File > New > Ne'v Form Project
0 N""'
-- ~
N....., Pe>wr$hell 5<ript
--
Creates new Powe<Shd Scre>t (.psi}.
Open N ~ro; d
~
New Form
~iesanewGU!b3<edr0t (.psf).
Proiect Types:
Opn Projt Since vve are creating a forn1
project that will consist of ra FormProj~
R~ SavAs
~ New Form Project
Lfi'a
Cr"'oanr>" GU!ba<edpr~
multiple forms, select the ra Multi-Form Proj ect
CreateslXO)ert "'' "'"Opie - lJsod to a ...... oal>tappjcabon.
-..!:- Close
Another 'vay is to click on
x
Proiect Types:
Select "Multi-Form Project", give your project a na1ne and click
"Create". Lm Empty Project
Creros"" enoty project. used to a .... ~ opp1c:a.,....
Lm MultlForm Project
Crtco prO)<ct ,.;in ""Opie IO<ms. u-..ed to="'. ''"t IQPlfcalfon.
0 New
' ~
New PowerShell Script
Crea~~ a new PowerShd Saipt (.psl).
Pfoiect-: My Proiect
J
- loal1101>: C:'j.Jsers\le~1$\SAl'lfN~ Sludoo'l'ro)Oc Sn>wse
Open
~
New Form fV,Create Pro)OCI Folder
Creates a new GUI based ~t (.psf).
Ii Open Project
NewProj~
~. ~veAs
Ci
New Form Project
Creates a oew GUI based pro)ect.
No\v, Po\verShell Studio, will create four files and open thetn in
the editor:
~ SaveAJI
era New Module Project
Creates a new Powe-Shel SCll)t module
project.
~ Create Template... MainFor1n.psf
5J Create File Group...
era Nw Module From Functions
Creates a SQ1>1 modtk by selecting
~ns from elCistwlQ saipts. ChildForm.psf
@I Print era New Module From Help File
Creates a SCl1)t module by detl\/11g Globals.psl
fu:ictions from a Powe<Shel ~ ffe.
Startup.pss
~
Close
Close Project
When you run, debug or Name
Options x ExitJ
package the project into an l!J ChildForm.psf
executable (.exe) or h) Globals.ps1
Microsoft installer file (.msl), all four files and any other (.psf) files that you ffl MainForm.psf
1night have added to the project are all combined into one single (.psl) file! [i My Form Project.psproj
Including all the code that you \Vrite into your forms and code thatPowerShell 0 My Form Project.psprojs
Studio generates to make the GUI application work. By doing this PowerShell
ID] Startup.pss
Studio makes it easy to share variables among forms.
PowerShell Studio - Form Design and Projects I 167
If you would like to see all the code generated and added to the single .psi file you can go to the Deploy Tab, ai1d
click "Export to File", this will export your entire project into one single .psi file which you can open with any
editor to view the contents.
There are several different regions that are created within the script file \Vhen it is generated. If you haven't looked
I suggest that you do it when you get a chance, there is so1ne great infonnation to gain as to how your application
is being generated by Po\verShell Studio.
Assemblies - these co1nmands load the asse1nblies that you used in the Syste1n.Windo'1vs.Fonns
l #---------------------------------
2 #region Import the Assemblies
3 #-----------------------
4 [void ] [reflection.assembly]::Load ('System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c56 l 934e089')
5 [void] [reflection.assembly]::Load ('System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c56 l 934e089')
6 [void] [reflection.assembly]::Load ('System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f 7fl l d50a3a')
7 [void] [reflection.assembly]::Load ('System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7fl l d50a3a')
8 #endregion Import Assemblies
Form Objects - these co1nmands create all the objects you used in your forms.
l #-----------------------------------------
2 #region Generated Form Objects
3 #-------------------------------- ------------
4 [System.Windows.Forms.Application] ::EnableVisualStyles()
5 $MainForm = New-Object 'Sys tem.Windows.Forms.Form'
6 $1abe1Domain = New-Object 'System.Windows.Forms. Label'
7 $Domain = New-Object 'System. Windows.Forms.T extBox'
8 $statusstrip l = New-Object 'System.Windows.Forms.StatusStrip'
Recovery Data - this is used to recover .psffiles if they are deleted or lost, inake sure yo1L don't make any
changes here!
User Generated Script- this is your code that you vvrote into the fonns.
1 #----------------------
2 # User Generated Script
3 #----------------------
4 $ErrorActionPreference ='Stop'
5 $0nLoadFormEvent = {
6 Check to ensure application is run as administrator, if not shut it down.#>
7 If (-NOT
([Security.Princ ipal. Windows Prin c ipal] [Security.Principal. Windowsldentity] ::GetCurrent()) .lslnRole ([
Security.Principal.WindowsBuiltlnRole] "Administrator"))
Control Properties - these are settings that are taken fron1 the properties of the controls on your fonns.
1 #
2 # richtextbox73
3 #
4 $richtextbox73.BackColor = 'WhiteSmoke'
5 $richtextbox73.BorderStyle ='None'
1 $richtextbox73.Font = 'Mic rosoft Sans Serif, 8.25pt'
2 $richtextbox73.Location = '539, 495'
3 $richtextbox73.Name = 'richtextbox73'
4 $richtextbox73.Read0nly =$True
5 $richtextbox73.Size = '297, 92'
6 $richtextbox73.Tablndex = 89
7 $richtextbox73.TabStop =$False
The (.psproj) file contains a list of all the reference functions, which are used vvhen calling a form. The default file
contains:
l <Projec t>
2 <Version>2.0</ Version>
3 <File lD>d4947ad8-d846-445a-8 l 68-273a2a772acf</File lD>
4 <Files>
5 <File Build="O">Sta rtup .pss</File>
6 <File ReferenceFunction="Show -Main Form_p sf" Build="O">M ainForm .psf</File>
7 <File Refe re nce f unc tio n="lnvoke-G lo bal_psl" Build="O"
Shared="Tru e">Globals.p sl </File>
8 <File Reference Fun ctio n="Sh ow-C hild Form_psf" Bu ild="O">C h ild Fo rm. psf </ File>
9 </Files>
l 0 </Project>
Globals.psl - th.is contains global variables, functions, and other values that are shared among the mttltiple fonns
in your project.
Nfake sure under the p roperties for Globals.psi, in the Misc. section, set Build to "Include", and Command Ext to
"True", or it i11ill not i11ork properly and the functions i11ill not be accessible.
Let's look at an example of a functio11 in the Globals.psi accessible from other forms in the project. By default,
' vhen you created a ne'v fonn project the Globals.psl file vvas generated auto1natically and SAPIEN populated it
with a couple of examples for you. The function "Get-ScriptDirectory" is defined in the Globals. psl file. If you are
in a11otl1er form and you start typing "Get-ScriptDirectory" you will notice a pop-out tl1at \ivill give you infonnation
on the function, including its location in the GJobals.psl file.
l
2iG $MainForm_ Load={
3 j #TOOO : Initial ize Form Cont rol s her e
41 get-scriptdirectoryj
5
6
n
function get-scriptdirectory
Get-ScriptDirectory returns the proper location of the script.
7 jD Output Type: System.String
8
~I
I
1 Source File:~ Globals.ps1
Startu p.oss - this is where you can pass paraineters to the application ''before" it loads. Adding a Parani block
to the Startup.pss file allows y ot1 to provide startup parameters to yot1r proj ect vvhen it iuns. The runtime
behavior depends on 11ow t11e project is started. If you start youT project from the console, tbe11 you provide
parameter values on the co1nmand line, separated by spaces. If you are starting a Forms project, then
PowerShell Studio will pro1npt you for the paran1eter values. If you package a project into an EXE file,
the11 you mt1st always provide startup paraineters on the command line. You can also add Param blocks
to fonns and scripts i11 your project, as long as their Co1nmand Extension property is not set to true.
Si1nply add a Param block to the beginning of the file and provide parameter values \iVhen you invoke
the file .
170 I PowerShell Studio - A Comprehensive Guide
Lefs e>.'J)lore the different types of scopes as related to PovverShell and how scopes are used to isolate a script's
modifications. When we are talkil1g about Po,verShell, a ''scope" refers to the current environment in which a script
or command shell is n1nning. Scopes can be used to protect certain objects from being unintentionally modified by
scripts or other functions, unless explicitly told to do so.
The follo\ving are protected frorn modification by cornmands run from another scope:
Variables
Aliases
Functions
PSDrives
Ne\v scopes are created \vben a script is executed or ' :vhen a ne\.v sessio11 or instance of PovverShell is created. There
are some scopes that have a special meaning:
Global Scope - is the scope created when PowerShell starts, and includes variables, aliases, functions, and
PSDrives that are built into PowerShell as \Veil as ones made by your PowerSbell profile.
Local Scope - refers to whatever the current scope is. When PowerShell is started, it refers to the Global
scope, when you execute a script it refers to the Script Scope internal to the nUUling script.
ScriJlt ScOJle - created \vhen a script runs. Tl1e only conuna11ds that operate \Vithin this scope are those
conunands within the script.
Private Scopes - can be defined within the current scope to prevent con1111ands in other scopes from being
able to read or modify items you do not want thern to have access to.
As vve mentioned, co111lllai1ds executed within one scope does not affect items in a11other scope unless we
specifically tell them to do so. As an example, if \e create a variable named $ThisVar in the Global Scope and a
script executes which nms a co1nmand to change the value of $ThisVar. A copy of $ThisVar ' vill be created in the
Script Scope and the value altered. If I checked the value of $ThisVar fron1 within the script, it vvould appear that
the value had been changed, hovvever once the script bas ended and you check the value in $This Var you \Vill notice
tbat the value is the same.
Why is that? Because remember within a script you are using the Script Scope, and a Global Scope variable \.Vill not
be affected frorn a script corrnnand UNLESS you explicitly request it. To cha11ge a Global Scope variable fro111
witllin the .Local Scope (remember ,;vhen a sc1ipt is executing the Local Scope refers to the Script Scope), you only
need to add the scope name at the start of the variable name, and put a colon betvveen the scope and variable na1ne.
$global:ThisVar
$script:Th is Var
$1ocal:ThisVar
This comruand within a script would change the Global Scope variable $ThisVarvalue:
It is very colTilnon for a parent form to collect data fro1n a child form, and PowerShell Studio handles this remarkably
well.
For exa1nple, a main fonn opens a child fonn where a user inputs data into a text box and clicks OK on the child
form, which closes the clrild fonn and control is returned to the parent fonn. But you need the data that the user
entered (text property value) of the Text Box.
When you add the reference function for the child form (Call-ChildForm_psf) to the MainForm.psf script,
PowerShell Studio will automatically 1nake the values of the control properties of the child form available to the
inainfonn.
You can create a script-scoped variable in a child fonn, for exainple to create a script-scoped variable for the text in
a Textbox, you can use something like: $script:ChildForm_Text = $textbox.text.trimO
49
June Blender of SAPIEN has written an excellent article on Multi-Form Projects which
includes a great explanation ofScript-Scopes and Return Variables.
Collection Projects were introduced with Po,verShell Studio 2014, and allowed you to create a new project to keep
track of groups of files, including psl script files.
x
Project Types:
Collection Project
lrr I Creates a project that alows you to group files.
Empty Project
j !liJ Creates an empty project. Used to create a script appkabon.
I 1 Form Project
I Vi~ Creates a Sl'lgle form pro,Ject. Used to create a 501>t appkabon.
I I Module Project
I rd Creates a PowerShel 501>t modUe.
Locabon:
49 http:/ /info .sapien .com/index.php? option=com_c ontent & view=article &id=246 :how-do-multi-form-projects-
work&c atid=27 <emid=2656
172 I PowerShell Studio - A Comprehensive Guide
There is no Startup.pss file generated with a Collection Project because each file is considered individual content
and therefore tl1ere is no need for an entry point. Each file can be nm individually using the "Run" co1n1nand on
the Ribbon Bar.
New options were added to the Collecbon Project in oi-der to accommodate yotrr deployment needs by controlling
the behavior of the Packager, MSI, and Deploy1nent as a whole or as individual files .
~~epcrtcl
De1Jlov As:
:O cro...-o off fl
This determines tl1e deploy1ne11t behavioi- of the Project as a \hole. There are two
C]l l g) .
"De~
Deploy As options to choose fro111:
~--
Pr-yHc
,.
Scrjpt ~l
~ Hbc (File) - Tells the project to handle each file individually when it comes to
~hr.le Groepof f!An
.. OJC"'l ..... ~:: deploy1nent. Each project file will maintain its O\Vll independent settings.
When to use: Use this setting when you are using the Collection Project to group
individual files that don't i1ecessary interact with each other. Witl1 this setting you
OejloyAt
Ol:lb u
to-dul\s,_-,t b- 6 lfe Ni dtd WI can package and deploy (pubbsh) eacl1 script independently.
d'>t ~
(Project) - Tells the project to handle the deployment of all the files. You inust
define a primary file for the purposes of the Packager and MSI builder.
When to use: Use this setting when you have a group of files that interact and have a start I entry point
script. For exan1ple, if you have a priinary script that dot sources various secondary scripts. In this case,
tJ1e pri1uary script \Viii get converted into an executable and you can create an installer that includes the
primary packaged script and all the supporting files I scripts. The project files are also deployed (published)
as a whole.
Primarv File:
This property tells the project, wllich file is tl1e pri1nary file \vhen Deploy As is set to Project. The pri1nary file
will be the file that is packaged into an executable. All other files will be considered external " Content".
Previously the deployn1ent options were unavailable in the Collection Project t1nless you opened tl1e files
independent of the project. These nevv deploy.ment settings no\v allow the Collection Project to fit your
deployment needs.
A script module is a file (.psn1l) that contains any valid Windows PowerShell code. Script developers and
ad111inistrators can use this type of module to create 111odules whose members i11clude fm1ctions, va1iables, and more.
At heart, a script 1nod11le is simply a Windows PowerShell script vvith a different eA.1ension, which allovvs
administrators to use i1upo1t, export, and 1nanage1nent fm1ctions on it.
PowerShell Studio - Form Design and Projec ts I 173
In PovverShell Studio you can also add a form (.psf) in the 1nodule vvhich is vvhy the final script has to be generated
before it is included in the module' s script.
None of t11ese co1nponents, by the1nselves, are actually necessary. For example, a module can teclmically be only a
script stored in a .ps1nl ftle. You can also have a module that is nothing but a manifest ftle, vvhich is used mainly
for organizational ptu-poses. You can also w1ite a script tba t dyna1nically creates a n1odule, and as such doesn' t
actually need a directory to store anything in.
50
Jv!icrosoft offers a great article on flow to 1vrite a Pov11erShell Script Module. You create a script module by saving
1
a valid Po"verSbell script to a .ps1nl file, and then saving that file in a directory located \Vihere Po,verShell can find
it. In that folder you can also place any resources you need to run your script, as \ell as a n1anifest file that describes
to PowerShell ho\:v youJ n1odule works.
It can be confusing when using "Build Module" because all the .psl files within the Project will be merged into one
script and inserted into the Module .psn1l file. Again, tllis is because of the ability to add a .psf fonn file, wllich
needs to be generated by Po\verShell Studio to create all the code needed to Sl1ppo11 the form.
'I' Properties c " x If for some reason, you do not want files to be 1nerged, you can set the file' s Build
_ _..'--'
" Property to Content instead of Include. Do this by selecting the file in Project pa11el
ff;J~ I M and the11 use the Property panel to change the file's settings. Settit1g the file to Content
v Mls<:
Buld ensures the file will be included when exporting the 1nodule.
Niltne
Content
'
5"t R~lstryValud"orAllUS>
~ .
ef~fnc I~ ~
Shao-ed Fal$e Setting the file to Exclude "'ill ensuTe that the file is NOT included when exporting
the n1odule.
Setting the file to Include vvill ensure that it IS merged when building t11e module.
Build
HDw the fit relates to the buld and deployment
proce=.
; ;
toooOOOOOOOO+o- ooo. .o . .o o .. .o.oo. .oo. .o ooo. .o . .o . .o . .o . . oooo+oooooo . .ooMOM OOOOO O O OOO OO. .O . .O . .O OOOOOOOO H O- - OOOO. .O . .O O.OOOOOOOOOO. .O . .O M O M O . .O . .O . . OOOO' OO >. .O OOOOO OM OOOOOOO OOO OO"O"O" 'O OOOOOOOOOOO- OOOO. .O . .O . .O O.OOOOO<O. .O"O'"OM O M O . .O . . O. . . . .. . .. .. . . . . . . .. .. . . . . .. . .. . .. . .. , , , ,, , , . , ,, ,, , ,, . ., _ ,, , ,. ., . .. , , . , , , ,. . . . . . . . .. .. . .. . . . . . . . .. . .. . .. . .. . . . . .. .. . _ , ,, , ,, , ,, . ., . , , ,, . ., . . ., , H 0000~
OO " - '' ' ' ' "" '' ' " ' ' ' '' ' ' '. .O . .O M O M 0 . .0 . .0 . . 0000 ' 000. .0 . .0 0 00. .0 -00 0 0 000 00. .0 000. .
@I
~
CJ..10 Fflt Group-
Pnnt
Oou
various psl sc1ipts a11d
merge them il1to a
single script 111odule .
Source JU~~ runctlOns
1v "Q - 1
-
~ .,, n 9""' -Mew ....ee 16,.ps!
lii:tt"'crad....._
v- e ~~Jll&f
'--~~~~~~~~~~~~--'
When you select this "...,,. 1x e.i "'n c.._..._
.., (: Cict~v
.,;~ --....._,.,
option, you \~ill be
first asked to select a file (if one is not already open), the11 you
will be presented witl1 a dialog to select \IV hich functions to
include in your new 1nodule, as "veil as t11e ability to naine your
1uodule.
Module Name - This is where you give your module a name to use. It is not reco1mnended to use 1nod1tle .names
that contain spaces.
Location - You can specify where you would like the modttle saved, by default it \ Vill be saved in the Po'1verSbell
Sh1dio project directory.
Create Module Folder - tllis option 'vill create a ne\iv folder using the module's name and places aJI the relevant
files for the module within that directory.
Sou rce Files - the list of all files that you have added that will be used to i1nport functions tl1at you select.
Add File - use the Add File button to add n1ultiple files to the Source Files list.
Remove File - used to remove selected file(s) fTorn t11e Source Files list.
Functions - presented as a node list, this list is compiled fro1n the files in the Source Files list. You can check the
functions that you \Vant to import and llllcheck functions you do not wish to import. Any check ftmction that includes
referenced ftmctions \IV.ill also be imported.
If any duplicate identical functions are found, the function \vill only be i111ported once. If a11y functions are fotmd
that have t11e saine name but the code in the functions are different, all '1Vill be imported however, PowerShell Studio
\ill renan1e all duplicates a11d an error will be shown in the Output Pane.
Once you click on "Create Module" Po'1verShell Studio \Vill generate three files:
.psd 1 - this contains the modules manifest.
.J>Sm 1 - contains all the iinported functions and the Export-Moduleme1nber c111dlet state1nent listing all t11e
imported functions.
.help.xml - contains the PowerShell XML help file for the inodule, which is generated from the imported
.fimctions.
PowerShell Studio - Form Design and Projects I 175
There are times when we do not want to share specific functions, aliases, variables or cmdlets \.Vith users. Export-
ModuleMember can enable you to tell what functions are visible to a user.
For exa1nple, let's say there are two functions in a module; Get-Userlnfo and Get-Processes. If we want only the
Get-Processes function to be visible to users, we would use the follo\.ving code in the module co11taini11g the
functions:
Export-ModuleMember Get-Processes
L...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................j
FOR
PowerShell Studio - Form Controls I 179
FORM CONTROLS
It isn' t about the singular use of a control, designing a form is about having numerous controls work in unison witl1
each other! Controls are at the heart of any GUI fonn, fro1n the fonn itself to the controls the form houses such as
buttons, listviews, datagrids, etc.
A common mistake is the improper use o.f ( ) and (-eq) so let 's clear it up before moving on:
If ($box.checked = $true) f- This assigns a value of $true to $box.checked.
If ($box.checked -eq $true) f- This is evaluating the current value of $box.checked.
0-.. 51 Thebutton is one of the most used controls, it provides interactivity between the user and the fonn,
usually to start or stop a specific process flow.
~ Form 0 x There are many combinations of properties that you can use to
customize buttons to fit almost any design that you are looking for.
button1 Flat Style Back Color
Whether it is changing the button style, font style, font colors,
background colors, background i1nage, or adding an icon to the
~on2 I Popup Style button2 - Background lrlllllje
button, you will find almost with practice you can create some very
eye appealing buttons for your fonns.
r ... ~_.,
'""""'"' Standard Style MT0'6J Fonts
When you first create a button, it uses a default na1ning convention
of $button!, the I being the next nu1nber available for the button
bU!on4 J System Style Image
control. What happens if you copy/paste a button? For exa1nple, if
.._____ _ _ _ _ _ _ _ _ _ _ _ _ _-=--.: the button is named "buttonl", when copied it will be automatically
named "buttonButtonl ".
You can, and should always change the name of your button controls to reflect a na1ne easy to identify in script code
\.Vhat it does. For exainple, instead of "buttonl'', it might be called "Query_Running_Processes". To reference t11e
button control in script code we would of course add a $ to the beginning of t11e name; $butto11l or
$Query_Running_Processes.
,
O<XkChaoged
[_ ~
[1 Fontdianged
Ql Edit Default Event (Click) The Default Event for the button control is
[_ ForeColotehanged Add Events... Ctrl E "Click'', or select the b11tton and press "Ctrl-
[ Loca~
[_ Marljin(honged
Go to Event E" .
[ ReQOOChanged if/ Rename
[. Ri<jltToteftehanged
l Slz~
[, Tablnde~
0 Help
-
PowerShell Sn1dio handles most of the
l TabStopOlanged 00 Apply Property Set.. Ctrl + l background details of event inanage111ent for
[1 Tex!ChanQed
~d
I!! Create Property Set... Ctrl + Shift + l
- you.
c dick fil Create Control Set... Ctrl + T
[_ ControlAdded -
C ControRemoved
[J Dra'11)rop
Insert Recent Control An event is a me1nber of a class, just like a
[1 DragEnter
c 0.-agOV'er
rlil Copy Ctrl + C property or a inethod. Wbe11 you use the
[ DraQleave ~ Paste Ctrl + V
Get-Member cmdlet by default, it renrrns
l GIW'~ )( Delete Del
r events, along with the other 1ne1nber types.
U P~
r
r
HelpRequested
Pa.nt ,.
DD
DD Select All
Bring to Front
Ctrl +A
Ctrl + B
>
~yCon~ag
[ QueryAcassiblhtyHelp Send to Back Ctrl + Shift + B For exa1nple, a close button ($b11tto11Close)
c fnter is an instance of the button class,
L KeyOown Properties
r J(e~es
00 View Code Svstem.Windows.Forms.Button. You can
[_ J(e~
[ ' Layoot Document Outline create a button and add it to a fom1 "vitl1 the
lJ leave
t'1ouseClick
co1nmands:
D MQuseQipueChanged
l MouseDown
[. Mousefnter
L Mousel.eave
1 #Create a close button
[
l
MouW!over
M~ve
2 =
$buttonClose New-Objec t 'System.Windows.Forms.Button '
D MousellP 3 #Add if to the form.
[_ Move
[ Prev~wl<eyOown 4 $form l .Controls.Add ($buttonsClose}
c Resltt
[ Cl>angeUICoes
[' s~
[ SystrmColoisChanoed Like all buttons, i11 fact like all controls, $ButtonClose has a Click event.
l Va'damg
[. Vaada~ When the Click event happens ("is raised"). tlle system calls the event handler
C Parentehanged for the Click event.
Typically, you ~vrite the event handler com1nands in a script block a11d save them in a variable that is natned for tl1e
event. In this example, we "vrite an event handler for the Click event of $buttonClose. We write a co1n1na11d that
calls the Close() inethod of the fonn, enclose it in a script block, and assign it to a variable conveniently named
$buttonClose_ Click. Despite its usefulness, tl1e variable naine is just a name and it has no effect on tJ1e outcome.
The next step is to "register" the event handler script. Registering associates the Click event \:Vith the
$buttonClose_Click event handler: When the event handler is registered, the system n1ns the co1ninands in the event
handler whenever the Click event happens on the $buttonClose button.
To register ai1 event handler in PovverShell Studio, in the Properties box, click the Event icon (thunderbolt). In the
ro'\tv for the event, such as Click, type the name of the event handler variable without the dollar sign ($).
For the default event of each type, like the Click event of a button, PowerShell Studio does it for you.
But, in the background, Po\verShell St11dio writes a co1nmand to register the event handler.
.add_($eventHandler)
For example:
1 #Register an event handler for the Click event
2 $buttonClose.add_C lick($buttonClose_Click)
But what is add_Clicl{O? Or, inore generally what are those inethods na1ned add_<EventName>? If you search
MSDN in the Button class (System. Windows.Forms.Button), or the class of any other control, or even their parent
classes, you won't find any nlethods na1ned add_ClickO or add_<AnyEventNa1ne>.
Example:
You have created a ne\v form with one button na1ned "buttonl", ai1d added two events: Click and TextChanged. If
you Export to File fro1n the deploy tab, and examined the produced .psl file, you will notice that Po,verShell Studio
has done a lot of the work in the background for you, as seen belo,v:
1 #Create button 1
2 $button 1 =New-Object 'System.Windows.Forms.Button'
3 #Add button 1 to the form
4 $form l .Controls.Add ($button l)
#Button 1 properties
$button l .FlatStyle = 'Flat'
$button 1.Location = '27, 43'
$button l .Name= 'button l '
$button l .Size= '75, 23'
$button l .Tab Index = 0
$button l .Text= 'button 1'
$button l .UseVisualStyleBackColor =$True
182 I PowerShell St udio -A Comprehensive Guide
And you will see the following script code added for you:
1 $butto n l _Click={
2 #TODO: Place custom script here
3 }
4
5 $butto nl _TextChanged={
6 #TODO: Place c ustom script here
7 }
Why use an IDE like PolverShell Studio if you can hand-code the script?
Sure, you could hand-code everything to create your own script file without using an IDE, and no\v that we have
pulled back the curtain, and exposed the magic behind the scenes, you can see that even using an IDE the script
n1ust still confonn to PowerShell scripting standards. An IDE allows you to acco1nplish what used to take hours in
only minutes ! With PowerShell Studio, you need only drag/drop a control onto your fonn, position it where you
like, set the control's properties, add events that you need, and insert the specific code that you would like executed
when a specific event is raised. It's really that si1nple! The majority of the coding is done by Po\verShell Studio for
you. Yes, I fully expect this to make hardcore PowerShell scripters heads e>..'Plode, but then again, the C# guys felt
the saine \vay until they e1nbraced Microsoft's Visual Studio!
> ................................
$buttonl .
f
~
A~~~~i.t;fiit:yoi;j~ct...................................................................
In the Script Editor, as you start to type the control ruune ending with a period (.), a dropdo"vn will open showing
you all the methods and properties that you can apply to the control.
- $buttonl_Click={Change-Button}
14
When you type the control na1ne within the editor and
enter a period at the end (.) you will see a pop out menu
$button.'ly8utton.
> fA~~-~~ibiiitYQb}~ct .....,_,_,........_..._,_,..._._..._,_,,............_,,] I\
to sho"v you all the available properties and inethods
> A~~~~it;i~o~i~~liActi~~o~~~i.P'ti~~.........................
> AccessibleDescription
available for t11at control.
> AccessibleName
> AccessibleRole
0 add_AutoSizeChanged
0 add_BackColorChanged
0 add_Backgroundlm ageChanged
tj add_BackgroundlmagelayoutChanged
0 add_BindingContextChanged "
$buttonMyButton.Visible = $true
Button Visible or Hidden ~ ~
Of course, it would be hard to shovv' you if the button were
My Button
- - invisible, however the comma11d would be:
$buttonMyButton.Visible = $false
<;,.... ..... . ....... .......... ... ............. ... ....... ....................... ... ... ... . ... ..... ... . .... ..... ..... ... .......... ... ...... . ... ... . . . ....... ....... ... ............. ... . . . ....... ..... . ... . ... ... . . . .... .......... ... .......... ... ..... .... . ........ .. ... ............. ... ....... ... ..... .... . ... .... . . .... .......... ... ... .......... ...... .... ... .......... ........... .. .......... ... ..... . .... ..... . ....... .......... ... .......... ... ... ... ....... .................... ... ...... . ... ..... ... .. .
I My &itton I TextBeforelmage
I My Button I lmageBeforeTe}..1:
You can also use the "TextlmageRelation" property to display the
l___ y Butt_on_....
M_ I ImageAboveText
image before, after, above, or below the text.
My Button
I TextAbovel1nage
PowerShell Studio - Form Controls I 185
Charts can be very useful especially ,;vhen comparing data, and are easily added to any form, but can be very
confusing when it comes to populating with data.
.a Form
When you first insert a chart into your fonn (drag/drop). It will appear
like the chart of the left. There is initially one series of data created in
100
a column type chart.
- Series1
80
... There are two helper functions that are generated by PowerShell
. Studio; Update-Chart a11d Clear-Chart .
60 1:
-
40
- Update-Chart plots the points that you supp[y onto the chart.
0 There are many chart properties that can be set either as default in the
0 2 4 6 8
properties pane for the chart control fro1n the designer, or on tl1e fly
within the script code. It all depends on how flexible you want the chart
to be, there 1nay be instances ,;vhere you want to give users a choice to
select the chart type that they prefer, this can easily be done with a dropdown choice.
First, add the Chart Control to an empty form, then edit a few of the chart properties:
- c x
- Desogncr A ... 0
Q -fill Copy ~
=
f.3Staso~ 1 lJ Centct ltonronlllr
: l!l ~
r-..
ll;1 ~ an !:!Di )( lltlo" ili Af<>11!1ottor.s .. ~ - Sitt Q CO"lttd Yid:!'! : 11 centct v..DQilr
~s.. m
~
PMtt
~ Atc-l P e:
.
1': (;I c... >It>
.
QJI t Cct12n I Heb
~ Su
CIC>boord - Ed!
""""" . vPropertJes
~ r t:IToot>ox )( )(
~
~ 100
80
-Series!
0
-
TllbS""'
.., Chart
Amo .."""
Owweas
Legends
lruo
Truo
(Collection)
(Cane ctton)
(Co8eclllon)
'ij~x Senes (Coll<etlon)
!IU eonit.-...s.., 60 >- >-- >- -
IP o...and , ""'
I
.o-JOatar-""Mow 0 0
) Olo~)
Oa!e- ... .__ - Oi1llSOU!Ct (none)
D- l119
Oer--
lfJ fi<S.....,Wallh 20 >- -
v Ocolgn
~)
lodoed
chrU
F.is.
,... flcml.a.,.,.,ll'>nol
v focus
r;zi-~
0 C:......V.adotic Truo
':JI -
'Cw fcnt!loalog
r,l'Qldox
......-nlllalog
0
1 2 3 5 6 7 8
o- 0
.., tmaoe
Text
An!!A..,,,._.,, .. "
~ Thi! lb<t ...-...S <!h lht control.
OHSa-
~..im.w~~~~..:Jlv ._,_~~~~~~~~~~~~~~~
. -- . --~ . -- - -
- - f- + - + 1Ayou1s Autolbrout AulDw..~bt9;taPM >. I ~ .- ,1 NUM I UlF-8 (LR-: 232 Col:: l 0-W: 1 '
186 I PowerShell Studio -A Comprehensive Guide
(Text)
Tile text.
Add Remove
OK Cancel
1. Select the Chart Control. ~y Tools -Conal Heb V.... ,.. . ...,6
2. Open the "ChartAreas" gg S.Ct Al ~ 5 S'tt
[j] ~!
fif ti) CO"llr"d I 4 () Cd'W Hclnzontlliy
x llci<>< Ill ....,.,a...... t1t "'0'1.,_.. ~ s.... Comil Y*lii. IE ecn"' .,...,, :
-
:::
collection property. ~ ~ )(r!Cc<:m ~Jl "C o ~t S! ~s.t Iii Heb
Cloboard Edi AIQrrncnt s.. """""" Ter.dotcs
\j'] Cihoot>ox x y PropenleS "
J> ~..__---------------. 1
i til: l fi1] ~ I 1t
&
gi
g Li _..,,
p
!fi.l ~ l TWl 1
"
--1
TebStoc> TM
! @ .,non l 0
VdiClc Ttuc
11'
.. '" ~ v Chort
i ' 0 ,,,._ ""''""' (Col<ctlon)
-
u~ISox ... Co
iii~ l~
: ~ Con1boeox 80
~I Con>ox1Mm.6"1l l\t!es
0.6ta
"'""""" 60 v
.,Jo.-..
I
0 0
O.b<T..-.,
c:i-.-. 40
0 &T"""1>wlor v OH:ion
j;} FkSysttmW- (t<Mnt) chrll
20
; ~ -.Oyoull'd lodc<d Pih<
v focus
~~
C.-Vlldollc TN<
I i:zJ Fcldet&cucseo-.1 Celog 2 3 s 6 7 &
id3 Fonl!)o;aloo y
:n-..- 0 0 0
-OYldc<
OHScoll!or
- - 1- - 1 - + l.4youe AutoLavcut 1Wtosaed~t9:33Pf.t >. I NU.Jrd I l11'f.s j line-:232 Cd: t Char: 1 .i:
l
0........1 .........
: _~l I ~~~.,.._----'I Editor" .
:'. E-~
I Y(Value) 0 1
"'
:_) t
'> POSltlCln 2 Sooondoty X
-..ccio.
Juo
128.0.0.0
"'
3 -..,.Y(V>luo) ox;s 4. Select the " X axis" .
v~-
s..~
yc..-
v T41e
r""""..,..,... 5. Under the Title property enter
> a.norx It!
Q.norY
Pmcesa.
"Process".
-
-Tl!eforl Ct"
Moaooc11 s..... s..t. t
Tl!e- -
v lobe
- '"".......' y
6. Click "OK" to close the Axis
-- .......
Tiiie
O..t~.- .
Collection Editor.
J
OK 7. Click "OK" to close the
ChartArea Collection Editor.
PowerShell Studio - Form Controls I 187
""- . r...,..,..
EJ ::IToolbox x y Properti?s x
~
! ~ ~
p ii
~ '"'"b,-_-
,.,.,----'-1~ rR-. 0 --0
TabStoc> Trve
" @ Button !> VISi1tt
""'
i 0~
!l' ..
100
Too SProeces.ses
- S.1esl
v Chart
......... ...,.
Ttut
(Colcction)
t;J~ OwtArus (Collect""1)
'.il C<b"'4ioo 80 legends (Collection)
He-. c
0.-
!j! C.01>:-..S"'P _,_ Tltlos (Colloctloo)
iP O.taGnd 60 - v Data
-...
~~)
I
{;JO.taCMW 0 )
11i:10...- . . - Tag
->
c:i-
0 &oal'lu.- 20 -
v D<slgn
~) d1art1
~R<Sys"'"'W-
Luclzd Fw
~-""'"'""'
:ill~ 0 v Focus
I 2 3 4 5 6 1 8
Jj Fold&& "'""-..c..ioo
d3 Foot!)alog v
0 0
."l Gr-
-
~--
.... ~ ..,
ISConoule ... Dc!>uo ,t,fft!R..Ut> f)Hcl> [l~!Z>Ut ie""fi>r'""""'
--
- -1-1- + m lAYout5. Au'lol11vout AIJto:..l\'cdat9'46PM >. I N UM I VTF-S I tnc:232 Col: l Ow: I .1
~ J
Process \IS
:: 1
YAxis Type PMlaiy
...,. Olalt
OiartArea
OiartType
v Data
lsXVM!elndexed False
Poirts (Collection)
XVM!eType f'Uo
YVakiesPerP<*i 1
l--...Mf-J..,.,..;T..~~_.....__--=====--=:::::::
lnwingStyle
Gets or sets the cevmg st)4e ol ba.- or c:oUm
elms.
[ Remove
OK
188 I PowerShell Studio -A Comprehensive Guide
- 0 x 1. Now add a ComboBox
nome 0."910' Deploy Tods
1: -
Source ConD'cl i'tolp View
.., A -;ai o
control to the form by
Pa~te
_
:,
b[il) COl>Y
~ OJI
~
~
PreWM
GUI
ggSelect Al
)( Delete
.:9 ~
L
ili ~ llottomo
d-:...
ffl
* AiQ'i -
'-.entm
=
t.;j Sze to eon=-ot
Sze To Cetltror Wd1tl
~I :.ze To 104 ..,,g,1
dragging and dropping it
c:lol>oo<d Preview Edt Size T""1iates fro1n the toolbox to the fonn
~ ii:Toollox ~~~--'-~~~~~~~~~~~~~----. ~opertleS 'x area.
i
4'
QI
= Ci!
frlU :C>: to ICcl'
... 1
'P
l10
~ sccmbobox!: Systrtn.Wfldows~
';:J1 I !wI _J
2. Select the Co1nb0Box in
f., Lt <1'oonter> Maxl<nQ lh D
the designer, tl1en in the
....
@auttan Sorted Fa15"
~ . . O>art
! 0 Chodcllox
~ Chedo:d.ls1!3ox
Tcp 5 Proccesses
Toblndox
TobSll>O
1
True properties open the "Items
100 Truo
Collection".
'.iJ CobOlaloQ
.,, "' - Process \'IS
v Dobl
~ Comboeox (Dotollo11d191)
Ii Contex-~
80 O.:aSource (!>one)
iP o..da)'Mefrb (!>one)
v-
O.taGnd
i,Jo.taGndV!ew 60 .... ~- ~- l_, (Collection)
"" 0.leT""'9idce< Tog
D~ 40 ~ ~- - v Design
o~
if) Fil<Sys..,.Wo..,,.,.
~ Flcw.U)'MPon<I
20 .... - ~)
lodced
comboboxl
False
v Focus
'ill Fcldetllrawse<o..log 0 .... C......V-bc T"'
i;z) F--Modemt>olog 1 3 s 7
v Layout
t;i3 Fontlloaiog 2 6 8
Process
Ant'hnr' Tnn. I "'ft
I r"J Gr-6<> Items
Hdlf>rovlclor The otens on .,. combo box.
1._.-
- -
- --
I- + - - -
---"'---------
+ layouts
- - - --
'"'"' Lyout '"'"' ""'<d 10:-0PM
-~
OK
We' re still not done yet, \Ve now n.eed to add in script
code to make the chart function.
We \vill add a fm1ction to check that Microsoft Chart Controls exist on the machine miming the fonn because Chart
Controls are required for the form to function properly, and 1nust be installed beforehand.
PowerShell Stu dio - Form Controls I 189
Function to chec]{ that Microsoft Chart Control exists on the local machine
1 function O nApplicationLoad {
2 #Note: This function is not called in Projects
3 #Note: This function runs before the form is created
4 #Note: To get the script directory in the Packager use: Split-Path
$hostinvocation.MyCommand .p a th
5 #Note: To get the console output in the Packager (Windows Mode) use:
$Console0utput (Type: System.Collections.Arraylist)
6 #Important: Form controls cannot be accessed in this function
7 #TODO: Add snapins and custom code to validate the application load
8 if([Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization"
) -eq $null)
9 {
10 #Microsoft Chart Controls are not installed
11 [void] [reflection.assembly]::Load ("System.Windows.Forms, Version=2.0.0.0,'
12 Culture=neutral, PublicKeyToken=b77a5c56 l 934e089")
13 [void] [System .Windows.Forms.MessageBox] ::Show("Microsoft Chart Contro ls for
Microsoft .NET 3.5 Framework is required"'
14 ,"Microsoft Chart Controls Required")
15 #Open the URL
16 [System.Diagnostics.Process]::Start("http://www.microsoft.com/downloads/en/'
17 details.aspx?familyid= 130F7986-BF49-4FE5-9CA8-
91OA E6EA442C&displaylang=en");
18 return $false
19 }
20
21 re turn $true # return true for success or false for fa ilure
22 }
We then add the event " SelectedlndexChanged" for the ComboBox, so that we can detect when an item has been
selected from the Co1nb0Box. In the designer, right-click on the Co1nb0Box control and select "Edit Default Event",
then in the editor add the code belo'v in the event block.
190 I PowerShell Studio - A Comprehensive Guide
1 $comboboxl _SelectedlndexChanged={
2 Update-ProcessChart
3
4 }
Each time the SelectedindexChanged event is raised the Update-ProcessChart function will execute. Now when you
Run the fonn, and select Stackedbar from the Co1nb0Box, your form should look like the one below.
Congratulations! You have created your first Chart!
Top 5 Proccessoes
- Process VIS
WINWORD (7048)
SnagitEditor (4356)
firefox (9020)
Microsoft.Photos (8532)
0-.. 52The checkbox control is very useful vvhen you want to provide inultiple selections or to enable/disable
other controls.
0 Oiecked There two possible states, checked or unchecked. The default is m1checked unless set
checked either by code or in CheckBox properties.
D Unchecked
The default location of the checkbox within the control is Middle Left, you can use tl1e CheckAlign property if you
need to change the position.
nO O Q O ttr
O;,Q,O
:
~ checkbox 1
0
9
: 6 checkbox:1 6 6checkbox1 b
OOO
6. . ... . . . . . . . 06 6. . . . . . . . . . . .
06
OO O OO O: O..O O
:
o checkb~
:
9
:
OO O OO
. O. OO
. O
.
6checkbox1 6 6HFl checkbox:1 6 6checkbox:1 b
rg :
6~ ......................~ ......................6 iT~OC
l ~ Fl
0 O 7::::-:b
The TextAlign property can be used to determine where tl1e text in tl1e CheckBox control aligns, the sa1ne values as
CheckAlign are available.
You can see below the different controls that were used for this example.
CheckBox Control - D x
Admin Credentials
UserName: USet"i a e
Passv;ord:
-
L_ oK ]
In this exrunple, we use a Checkbox to control the enable/disable of the Userruune and Password text boxes.
We add the default CheckChanged event to 1nonitor if the user checks or unchecks the CheckBox "Use Ad1nin
Credentials"
When the CheckBox is checked both the U semame and Password boxes are
enabled: E2J UseAdmi.n Croedenlials
UserName; I ~
:::::======::::::
Passvt0r~ !
OK I
Basically, all this is saying are that the controls $UserName and $Password,
shottld be enabled when $CheckBox- Achnin- Creds. Checked is true.
PowerShell Studio - Form Controls I 193
In more complex fonns the CheckBox can be used to enable/disable controls, as well as determine the values of
specific variables, such as ii1 ARMS we have used this to allo'v a selection for using Microsoft Update Server,
supplying a Windows Registry key value, and disabling the custo1n WSUS server configuration boxes.
wsus~
"
I
' /!Uo download/Notiy of nstalabon
WSUS Server Comgu-ation
Port I
I 0 /!Uo dov.Tiload/~ i'lstalatlon
15e1ect Day :
__
l~Comg..re ri_Setmgs
_ _ _~I 18530
0 /!Uo Updates/User corligucible
Who can approve/asapprove ~es?
Al Users 0 Mnnstrators
Restart v.ih logged On Users?
lnstal Minor Updates Potomatlcaly?
0 Ntow user to decide v.t1en to restart
@ Yes Siertly 0 No !teat like al ~es
Nolly user a.to-restart in 15 minl.tes
Lenl of Tme Watring Before Reboot If Req\ftd? How often to c:hec:k for new updates?
Defaul 5 "*1. 0 Custom f..'lr"des Eveiy 22 hous 0 Custom Hotn
Select i'b.n
jSelect Mrdes :
1 $checkboxUseMicrosoftUpdateSe_CheckedChanged = {
2 If ($checkboxUseMicrosoftUpdateSe.Checked -ne $true)
3 {
4 $WSUS_Server.Enabled =$tru e
5 $port.Enabled =$true
6 $usewsusserver = "2"
7 }
8 else
9 {
10 $WSUS_Server.Enabled =$false
11 $port.Enabled =$false
12 $usewsusserver = "1"
13 }
14 }
When "Use Microsoft Update Server" is checked, it vvill disable the WSUS Server Naine and Port# text boxes, and
supply the value needed for the Windows Registry Key:
HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\ Windo,vsU pdate\AU
194 I PowerShell Studio - A Comprehensive Guide
As you become more experienced with PowerShell and PowerShell Studio, you \vill leam many ways to incorporate
the CheckBox to provide a much more interactive application for your users.
R ememeber to use the ( ) and (-eq) appropriately, this is the type o.fmistake that will leave you scratching
your head trying to determine what is going wrong!
If ($box.checked = $true) ~ This is assigned a value of $true to $box.checked
If ($box.checked -eq $tn1e) ~This is evaluating the value of $box.checked
o'fi Form 0 x
\\/hat's Checked Mlat's NOT Cheoked
Software lnstalation Oracle Java Microsoft SOL
Adobe Acrobat Avamar Backup
0 Oracle Java
0 Adobe Acrobat
D Microsoft SQL
D Avamar Backup
Analyze
....
111 this case the user selected t\vo items and "vhen "Analyze" is clicked the results are displayed in the two text boxes
to the rigl1t. We could use that sa1ne information instead of displaying in the text boxes to kick off soft"vare
installations for the ite1ns selected, and we could create a log containing what sofnvare \Vas installed and what was
not installed.
PowerShell Studio - Form Controls I 195
1 $buttonAnalyze_Click={
2 # Determine what items are checked and send to "What's Checked" box
3 foreach ($item in $software_items.Checked ltems)
4 {
5 $ch ec ked_box .A pp en dText("$ item 'n")
6 }
7 # Determine what is NOT checked and send to "What's NOT Checked" box
8 $unchecked= $software_items.ltems I ?{
9 $software_items.Checkedltems -notcontains $_
10 }
11 foreach ($item in $unchecked)
12 {
13 $unchecked_box.AppendText("$item ' n")
14 }}
NOTE: I have used a CheckedListBox "vhen dynainicaJly listing installed software on a syste1n, giving
the user ai1 option to select each item in the CheckedListBox and clicki.J1g a button to ren1ove the selected
software. Although I prefer to use a DataGridView in this case, like below, simply because it looks better,
and cai1 provide 1nore structured information:
~ SCC>IO..T.. 6 WSUSll>dd 'llt ....,.,..,_..,. lk] OS- ' F\o_P.... ;j, JovoT"' !!! .....o..i<T"' ~I.WT"' 0 -..
I\, ...._ T"' A.9-T"' 9 S,C"""""""'- p""'.-~ ..
-- - _,...- __ -
lott.w.,.. t.l-tioo
... -
--- ..
ldoboNR
~~S..5M .. '
2.G0.19120
50
-.s.a-...
'
WnE080-1974"'58F9l ,
CF8802804<:03A-'38Ml.
---
---10"1 10 1 52.14 CIE9EF98E-259E" 1604l
ldobl FIWt Pfaoret' 1 l Id 110l152 -.s,.-- ""
u -s.o-'-"-
'"
VttMonl.2.1
In this example, we will create a form that will list all installed soft\vare on tl1e local or a re1note computer,
utilizing the CheckedListbox.
196 I PowerShell Studio - A Comprehensive Guide
Since the Control Helper Function (Update-ListBox) is created automatically for you \Vhen you added the
CheckedListBox control to your fom1. The only thing you need to do is add some code to your Button control
"Click eve11t":
First, you need to grab the computer naine that was entered into the TextBox, but you need to make sure that if the
user accidently entered a space at the end of the nrune that you trim that off:
Next, we need to evaluate that the co1nputer is actually online. There are some scripters that don't do tlus, they
siinply use a Try/Catch when it co1nes to determining if a system is online and catch the error if it is not
responding. It can save a couple seconds that \Vay, ho\:vever I personally do not like doing that, instead I do a test-
connection:
Next, we \Vill use the Uninstall keys witlun the Windows Registry to detennine the installed sofhvare on a syste1n,
I do not reco1nmend ever using WMI as everyone knows that will cause every piece of installed software to do a
repair, and can cause many issues.
PowerShell Studio - Form Controls I 197
1 $array = @()
2 #Define the variable to hold the location of Currently Installed Programs
3 $UninstallRegKeys =@("SOFTWARE\ \Microsoft\ \Windows\ \CurrentVersion\ \Uninstall",
4 "SOFTWARE\ \Wow6432Node\ \Microsoft\ \Windows\ \CurrentVersion\ \Uninstall")
5
6 # Notice we use the Uninstall Key registry location instead of WMI
7 foreach ($UninstallRegKey in $UninstallRegKeys)
8 {$Hive= [Microsoft.Win32.RegistryHive]"LocalMachine"; $regKey =
[Microsoft.Win32.RegistryKey] ::OpenRemoteBaseKey($ Hive, $computer); $ref=
$regKey.OpenSubKey($UninstallRegKey);
9 lf ($ref)
10 {
11 #Create an instance of the Registry Object and open the HKLM base key
12 $reg= [microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine', $computer)
13
14 #Drill down into the Uninstall key using the OpenSubKey Method
15 $regkey = $reg.OpenSubKey($UninstallRegKey)
16
17 #Retrieve an array of string that contain all the subkey names
18 $subkeys = $regkey.GetSubKeyNames()
19
20 #Open each Subkey and use the GetValue Method to return the string value
21 foreach ($key in $subkeys)
22 {$64check =
"SOFTWARE\\Wow6432Node\ \Microsoft\ \Windows\ \CurrentVersion\ \Uninstall"
23 $Hive= [Microsoft.Win32.RegistryHive]"LocalMachine";
24 $reg Key= [Microsoft.Win32. RegistryKey] ::OpenRemoteBaseKey($ Hive, $computer);
25 $ref= $regKey.OpenSubKey($64check);
26 If ($ref)
27 {
28 if ($UninstallRegKey -match "Wow6432Node")
29 {$Softwarearchitecture = "x86"}
30 else
31 {$Softwarearchitecture = "x64"}
32 }
33 else
34 {$Softwarearchitecture = "x86"}
35
36 $thisKey = $UninstallRegKey + "\\"+$key
37 $AppGUID = $key
38 $thisSubKey = $reg.OpenSubKey($thisKey)
39 $app = $thisSubKey.GetValue("DisplayName")
198 I PowerShell Studio - A Comprehensive Guide
15 #Drill down into the Uninstall key using the OpenSubKey Method
16 $regkey = $reg.OpenSubKey($UninstallRegKey)
17 #Retrieve an array of string that contain all the subkey names
18 $subkeys = $regkey.GetSubKeyNames()
19 #Open each Subkey and use the GetValue Method to return the string value
20 foreach ($key in $subkeys)
21 {$64check =
"SOFTWARE\ \Wow6432Node\\Microsoft\ \Windows\ \CurrentVersion\ \Uninstall"
22 $Hive= [Microsoft.Win32.RegistryHive]"LocalMachine";
23 $reg Key= [Microsoft.Win32.Re.gistryKey] ::OpenRemoteBaseKey($Hive, $computer);
24 $ref= $regKey.OpenSubKey($64check);
25 If ($ref)
26 {if ($UninstallRegKey -match "Wow6432Node")
27 {$Softwarearchitecture = "x86"}
28 else
29 {$Softwarearchitecture = "x64"}
30 }
31 else
32 {$Softwarearchitecture = "x86"}
33 $thisKey = $UninstallRegKey + "\\"+$key
34 $AppGUID =$key
35 $thisSubKey = $reg.OpenSubKey($thisKey)
36 $opp= $thisSubKey.GetValue("DisplayName")
37 If ($opp -ne $null)
38 {Update-ListBox $checkedlistbox 1 $opp -Append}
39 }} Else {# Computer is offline ->this could optionally be output to a log file}}}}
PowerShell Studio - Form Controls I 199
0AdobeAIR
l2J Adobe Flash Player 24 NPAPI
0 AutoRun Pro En rpr e ersion 5.0.0.89
0 Adobe Media Player I+ List Installed Software
0 SAPIEN Document Explorer 2016
0 Dropbox
0 Email Grabber 2
0 Epson PC-FAX Driver
0 EPSON Scan
0 FileZilla Client 3.23.0.2
0 lnstallAware XS
0 Power2Go
0 LabetPrint
0 Magic ISO Maker v5.5 (build 0281)
0 Mozilla Firefox 50.1.0 (x86 en-US)
0 Mozilla Maintenance Service
0 NVIDIA Stereoscopic 3D Driver
0 Microsoft Office Professional Plus 2010
D O'MlCloud
0 PDF Complete Special Edition
.....
This is what the form should now look like when it is run. You can see that \Ve we.re able to gather a list of all
installed software fro1n the co1nputer that was specified, and each sofuvare application listed can be
checked/unchecked. This could be further adapted to add an Un.install button, and so1ne more code to allow
uninstalling of all applications checked. We can easily do th.is by using tl1e GUID of the application, and if you
noticed we already have that stored in the $key variable.
l $checkedlistboxl .Checkedltems I
2 ForEach-Object{
3 $soft_computers.Text= $soft_computers.Text -replace "", '"' -replace '(?s) {\n){2,}',
"' n" -replace '\n$', "
4 $Computer= $soft_computers.Text.Split("'n") I 3 {$_.trim(}}
5 $uninstall = $key
6 $softname = L
7 $returnval =
([WMICLASS]"\\$computer\ROOT\CIMV2:win32_process").Create("msiexe,c ' /x$uninstall
'/norestart '/qn")
* this is only an example, you would need to first capture the $key variable for each application.
200 I PowerShell Studio - A Comprehensive Guide
The ColorDialog Control is an easy way to give users the ability to change the colors of for1ns, controls or fonts.
Each color can be represented in Hexadecimal digits, since RED, GREEN, and BLUE each can have values from 0
to 255 (256 possible values), there are 16,777,216 colors available for choosing!
There are a few properties that you can define that will control how the ColorDialog box is displayed, and whether
only basic colors will be selectable or all colors vvill be available.
r~...:
crr o wo
x
rrr oo
&.ecalots:
x
G
D
lll or l!ll o r
CustOIOcdcn:
l ~'"~ rrrrr rrrrrrr r tt.e: :! Li~
rrr rr rrr rrrrrrrr Red:
s..:Li G:ei:LI
CoicliSclld 1..t.m:EJ lb:E)
OK Concel OK Cancel Add to Or.otom Colors
iiSJ Form D X In this exa1nple I have created a simple fon11 with one button that
allovvs the user to change the fonn background color. The same
I Change ColOf I concept can be used to change other control colors or font colors .
.
l $buttonChangeColor_Click ={
2 # Open the ColorDialog Box
3 $color Dialog l .ShowDialog {)
4 # Grab the color that the user selects
5 $BackColor = $colordialogl .Color.Name
6 #Translate the HEX# to a System Drawing Color for the Form Background
7 $BackColor = [System.Drawing.ColorTranslator]::FromHtml('#' + $BackColor)
PowerShell Studio - Form Controls I 201
If only basic colors are chosen then the translation from HEX# is not needed, however since you cannot determine
iv hichcolor will be chosen, I recommend always using the translation or you will receive errors and the color picker
will not function correctly.
53
ComboBox and Do1nainUpDown Controls are basically the same with the exception that the Co1nb0Box
0-... is more of a drop down style, while the DomainUpDown is more of a rotational selector.
There are three different drop do,vn sty les to choose from:
lem4 tern 4 v
lem l Item l
kem2 Item 2
Item 3 Item 3
C'll' t
NOIB: Both Si1nple and DropDown allow the user to inanually type in a value, if you only want the user
to select fro1n the list provide then you should use DropDown List.
First you need to create the default event "SelectedlndexChanged" for the Co1nb0Box.
1 $comboboxl _ Selected.IndexChanged= {
2 $textbox l.Text = $comboboxl.Selectedltem }
The preceding code demonstrates ho\v we get the selected item from the ComboBox by exaffilillng
$co1nboboxl .selecteditem which \Ve then use to change the text in $textboxl. You could also use the results of the
ComboBox selectio11 in nu1nerous \vays to manipulate other controls or data.
If the co1nbo box's Dro1>DO"\vnStyle is not DropDownList and you are going to accept new values, it is
recommended to use the text property instead of selecteditem.
For exa1nple, \Ve have a ComboBox, with a DropDownStyle set to "DropDown" or " Simple" . We have
three ite1ns in the collection, Apples, Oranges, and Peaches. However, both of these Combobox styles also
allo\v the user to type in their own value. So, let's say they choose to type in "Pears"
The following helper function is generated when you add a Co1nb0Box to a fonn, and allows you to dynainically
load ite1ns for the ComboBox:
1 function Update-ComboBox
2 {
3 <#
4 .SYNOPSIS
5 This functions helps you load items into a ComboBox.
6
7 .DESCRIPTION
8 Use this function to dynamically load items into the ComboBox control.
9
10 .PARAMETER ComboBox
11 The ComboBox control you want to add items to.
12
13 .PARAMETER Items
14 Th e object or objects you wish to load into the ComboBox's Items collection.
15
16 .PARAMETER DisplayMember
17 Indicates the property to display for the items in this contro l.
18
19 .PARAMETER Append
20 Adds th e item(s) to the ComboBox without c learing the Items collection.
21 #>
22 Param (
23 [Parameter(Mandatory=$true)]
24 (System.Windows.Forms.ComboBox]$ComboBox,
25 [Parameter(Mandatory=$tru e)]
26 $Items,
PowerShell Studio - Form Controls I 203
27 [Parameter(Mandatory=$false)]
28 [string]$DisplayMember,
29 [switch]$Append
30 )
31
32 ~(-not$Append)
33 {
34 $comboBox.ltems.Clear()
35 }
36
37 if ($Items -is [Array])
38 {
39 $comboBox.ltems.AddRange($1tems)
40 }
41 e lse
42 {
43 $comboBox.ltems.Add ($Items)
44 }
45
46 $comboBox.DisplayMember = $DisplayMember
47 }
To add additional ite1ns to ai1 existing ComboBox list use the append parameter:
You can also assign the ContextMenuStrip to a control within the script editor, for example:
$button l .ContextMenuStrip = $contextmenustrip l
The ShowImageMargiI1 property detennines whether space for an i1nage for each menu item is displayed.
-----------
0 ShowCheckMargin -----------
! Edit items...
If you enable the Sho\vCheckMarginyou also need to set the property for each rnenu item' s Behavior/CheckOnClick
to "True" or the check inark will not display for the selected menu item. This is typically used when creating an
option that remains enabled for a user until deselected. If you are sin1ply creating a right click menu item that
executes once each time selected, then you \.Vill not have a need for using the check inark.
PowerShell Studio - Form Controls 205
Click on the s1nall triangle in the upper right corner of the ? .. .. .. . ContextMe.nuStrip T~
contextmeoustrip1
Context1nenuStrip, check both the " ShowimageMargin" and .... 1 RenderMode: [ImnagerRenderMode
.
" ShowCheckMargin" . _____...,. E2J ShowlmageMargin
E2J ShowCheckMargin
Then click on "Edit Items". Ed'rt Items ...
4. If you "vant a check mark to appear or disappear each time the menu item is clicked, then you can set the
ClieckO nClick oroperty to 1RUE.
~- Disable Changes When you are finished your right-click meny should look like the
example on the left.
[ Stop
I
Timer
All three menu items can have an image assigned to the1n using the Items Collection Editor (see bel0Vi1). The
"Disable Changes" menu item Behavior/CheckOnClick is set to True so that when the user selected this menu ite1n
it will remain checked until the user re-selects the menu ite1n to uncheck it. Both the "Stop" and "Tuner" menu
ite1ns Behavior/CheckOnClick property is set to False because these are to execute only once per user click.
Item Clicked
This event occurs when a 1nenu iten1 is clicked. Use this event as a general catch all event fo r the 1nenu items. It
allo,vs you to react to the menu ite1n clicks without having to set each individual menu ite1n' s click event.
You can access the clicked iten1 by accessing the event's argument Clickite1n property:
$ .Clickedltem
1 $contextmenustripService_ltemClicked=[System.Windows.Forms.ToolStripltemClickedEventHandl
er]{
2 #Event Argument:$_ = [System.Windows.Forms.ToolStripltemClickedEventArgs]
3
4 if($_.Clickedltem -eq $startToolStripMenultem)
5 {
6 Write-Host 'Start'
7 }
8 e lseif ($_.Clickedltem.Text -eq 'Stop')
9 {
10 Write -Host 'Stop'
11 }
12 }
Opening
This event occurs when the ContextMenuStrip is opening. Use this eve11t as a trigger to initialize the inenu ite1ns
such as enabling I disabling or ltiding menu items.
You can prevent the ContextMenuStrip from opening by cancelling the event:
$_.Cancel = $true
PowerShell Studio - Form Controls I 207
The follo"ving is an exainple demonstrating the use of the Opening event to initialize the menu ite1ns:
l $contextmenustripService_Opening=[System.ComponentModel.CancelEventHandler]{
2 #Event Argument: $_ = [System.ComponentModel.CancelEventArgs]
3
4 $pauseToolStripMenultem.Enabled =$fa lse
5 $startToolStripMenultem.Enabled =$false
6 $stopToolStripMenultem.Enabled =$false
7
8 if($treeviewServices.SelectedNode -ne $null)
9 {
l0 $service= $treeviewServices.SelectedNode.Tag
ll
12 if($service -ne $null)#ls there is a service object?
13 {
14 $pauseToolStripMenultem.Enabled =$false
15 $startToolStripMenultem.Enabled =$false
16 $stopToolStripMenultem.Enabled =$false
17
18 $service.Refresh() #Update the status
19
20 if($service.Status -eq 'Running')
21 {
22 $stopToolStripMenultem.Enabled =$true
23 $pauseToolStripMenultem.Enabled = $service.CanPauseAndCon tinue
24 }
25 e lseif($service.Status -eq 'Paused')
26 {
27 $startToolStripMenultem.Enabled =$true
28 $stopToolStripMenultem.Enabled =$true
29 }
30 e lse
31 {
32 $startToolStripMenultem.Enabled =$true
33 }
34 }
35 }
36 e lse
37 {
38 $_. Cancel= $true #Don't show th e context menu
39 }
40 }
208 I PowerShell Studio - A Comprehensive Guide
Closed
This event occurs \vhen the ContextMenuStrip has closed. You can use this event to handle state cl1anges or
selection changes in a combo box 1nenu ite1n if you do not handle their state changes as they occur.
To detennine why the ContextMenuStrip closed, you can access the event's argmnent CloseReason property :
$_.CloseReason
Values:
AppFocusChange
Specifies that the ContextMenuStrip control was closed because ai1other application has received the
focus.
App Clicked
Specifies that the ContextMenuStrip control \Vas closed because an application was launched.
Item Clicked
Specifies that the ContextMenuStrip control was closed because one of its items \vas clicked.
Keyboard
Specifies that the ContextMenuStrip control was closed because of keyboard activity , such as the ESC
key being pressed.
CloseCalled
Specifies that the ContextMenuStrip control \Vas closed because the Close method was called.
1 $contextmenustripService_Closed=[System.Windows.Forms.ToolStripDropDownClosedEventHandl
er]{
2 #Event Argument:$_ = [System.Windows.Forms.ToolStripDropDownClosedEventArgs]
3 Write-Host "Close Reason: $($_.CloseReason)"
4
5 if ($_.C loseReason -eq 'ltemClicked')
6 {
7 Write-Host 'ComboBox Value:' $comboBoxMenultem.SelectedText
8 Write-Host 'TextBox Value:' $textBoxMenultem.Text
9 }
10 }
Close
This 1nethod closes the ContextMenuStrip control.
$contextmenustripService.Close()
PowerShell Studio - Form Controls I 209
Show
This method displays the context menu. Use this method when you wish to 111anually trigger the context 1nenu.
l $treeviewServices_NodeMouseClick=[System.Windows.Forms.TreeNodeMouseClickEventHandler]
{
2 #Event Argument:$_= [System.Windows.Forms.TreeNodeMouseClickEventArgs]
3 if($_.Button -eq 'Right')
4 {
5 $treeviewServices.SelectedNode =$_.Node
6
7 #Display a context menu for any node without setting
8 #each individual contextmenustrip property
9
1O #Show the context menu relative to a control
11 $contextmenustripService.Show($treeviewServices, $_.Location)
12
13 #Alternative: Show context menu using a screen location
14 #$truePoint = $treeviewServices.PointToScreen ($_.Location)
15 #$contextmenustripService.Show($truePoint)
16 }
17 }
DataGuid~iCll Control
fcah1res
Multiple column types The DataGridView control provides 1nore built-in column types than the
DataGrid control. These. column types 1neet the needs of most conunon
scenarios, but are also easier to exte11d or replace than the column types in
the DataGtid control.
Multiple ways to clis1>lay data The DataGrid control is limited to displaying data from an external data
source. The DataGridView control, however, can display m1bound data
stored in the control, data fro1n a bound data source, or bound and unbound
data together. You can also imple1nent virtual mode in the DataGridVie\v
control to provide custom data n1anage1nent.
Multi1>le ways to customize the The DataGridView control provides inany properties and events that
display of data enable you to specify ho\v data is formatted and displayed. For example,
you can change the appearance of cells, rows, and colu1mis depending on
the data they contain, or you can replace data of one data type with
equivalent data of another type.
210 I PowerShell Studio - A Comprehensive Guide
Multi11Ie options for changing The DataGridView control enables you to 'vork with individual grid
cell, row, column, and header components in nu1nerous ways. For example, you can freeze rows and
appearance and behavior colmnns to prevent the1n from scrolliI1g; hide ro,vs, colUIIll1s, and headers;
change the way row colu1nn, and header sizes are adjusted; change the
way users make selections; and provide ToolTips and sho1tcut rnenus for
individual cells, rows, and colunms.
The DataGrid coutrol is retained for back\vard compatibility and for special needs. For nearly all purposes, you
sl1ould use the DataGridVie"v control. The only feature that is available in the Data Grid control that is not available
il1 the DataGridView control is the hierarchical display of information from t\VO related tables in a single control.
You 1nust use two DataGridVie\v controls to display iJlfonnation from hvo tables that are in a tnaster/detail
relationship.
1
because it den1onstrates dynamically loading
your DataGridVie"v, building columns on the
fly , as well as selectable iten1s in the
DataGridVie\v reslilts.
DataGridVielv datagridview_soft'1vare
TextBox soft_co1nputers
Button buttonsoftlist
Button buttonDeleteSelectedSofu:va
RichTextBox richtext softbox
This is done in hvo parts, first we use tl1e code belovv to scan the system for all installed sofuvare creating an array
that vve can use to populate our DataViewGrid.
l $array = @()
2 #Define the variable to hold the location of Currently Installed Programs
3 $UninstallRegKeys =
@("SOFTWARE\ \Microsoft\ \Windows\ \CurrentVersion\ \Uninstall",
4
"SOFTWARE\\ Wow6432Node\\Microsoft\\ Windows\ \CurrentVersion\ \Uninstall")
PowerShell Studio - Form Controls I 211
5 # Notice we search the Uninstall Key registry location, we do not use WMI as this causes known
issues
6 foreach ($UninstallRegKey in $Uninsta11RegKeys)
7 {
8 $Hive = [Microsoft.Win32.RegistryHive]"LocalMachine";
9 $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,
$computer);
10 $ref= $regKey.OpenSubKey($UninstallR egKey);
ll If ($ref)
12 {
13 #Create an instance of the Registry Object and open the HKLM base key
14 $reg=
[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine', $computer)
15 #Drill down into the Un install key using the OpenSubKey Method
16 $regkey = $reg.OpenSubKey($UninstallRegKey)
17 #Retrieve an array of string that contain all the subkey names
18 $subkeys = $regkey.GetSubKeyNames()
19 #Open each Subkey and use the GetValue Method to return the string vaJue for DisplayName
for each
20 foreach ($key in $subkeys)
21 {
22 $64check =
"SOFTWARE\\Wow6432Node\ \Microsoft\ \Windows\ \CurrentVersion\ \Uninstall"
23 $Hive= [Microsoft.Win32.RegistryHive]"LocalMachine";
24 $regKey =
[Microsoft. Win32. RegistryKey]: :Open RemoteBaseKey($ Hive, $computer);
25 $ref= $regKey.OpenSubKey($64check);
26 If ($ref)
27 {
28
29 if ($UninstallRegKey -match "Wow6432Node")
30 { $Softwarearchitecture = "x86"}
31 e lse
32 =
{ $Softwarearchitecture "x64"}
33 } else
34 { $Softwarearchitecture = "x86"}
35 $thisKey = $UninstallRegKey + "\\"+$key
36 $AppGUID =$key
37 $thisSubKey = $reg.OpenSubKey($thisKey)
38 $obj= New-Object PSObject
39 $obj I Add-Member -MemberType NoteProperty -
Name "ComputerName" -Value $computername
40 $obj I Add-Member -MemberType NoteProperty -
Nome "Application" -Value $($thisSubKey.GetValue("DisplayName"))
41 $obj I Add-Member -MemberType NoteProperty-
Name "Version" -Value $($thisSubKey.GetValue("OisplayVersion"))
212 I PowerShell Studio -A Comprehensive Guide
In the second step, we take the data that \!Ve just gathered and call the Update-DataGridView_Software function.
54 Update-datagridview_software - DataGridView $datagridview_software -Item $apps
55 Function to Update DataGridView
56 function Update-datagridview_software
57 { Param (
58 [ValidateNotNull()]
59 [Parameter(Mandatory =$true)]
60 [System.Windovvs.Forms.DataGridView]$DataGridView,
61 [ValidateNotNu ll()]
62 [Param eter(Mandatory =$true)]
63 $Item,
64 [Parame ter(Mandato ry =$false)]
65 [strin g]$DataMember
66 )
67 $DataGridView.Suspend Layout()
68 $DataGridView.DataMember = $DataMember
69 if ($Item -is [System.ComponentModel. IListSource] '
70 -or $Item -is [System.ComponentModel.IBindinglist] -or $Item -is
[System.ComponentModel.IBindinglistView])
71 { $DataGridView.DataSource =$Item}
72 else
73 {$array= New-Object System.Collections.Arraylist
74 if ($Item -is [System.Collections.llist])
75 { $array.AddRange($1tem) }
76 Else {$array.Add ($Item) }
77 $DataGridView.DataSource =$array}
78 $DataGridView.Resumelayout() }
PowerShell Studio - Form Controls I 213
The results are a nicely fonnatted DataGridVie\;v with five columns, sorted by Application Name.
Adobe AIR
--
Adobe /!crdJll. Reader DC 15.020.20042
2.6.0.19120
Adobe ~ems ~icorporat x86
~-
-- --- - -
t-
Cpse>n Evett Manager 2.40.1)001 SEIKO EPSON CORPOR... x86 {0388AA32.f2X:-4178-BlL
I-
Cpse>n FAX lUly 110.00
-
SEIKO EPSON CORPOR... x86 OC8E&:93-C82E-4378-9._
C?son Pm CD
- 2.42.00 SEIKO EPSON CORPOR... x86
>--
61\31 F~27S0-4968-A._
- Pin
-Cpse>nNet 2.! SEIKO EPSON CORPOR.._ x86
- -~
I {3E314000-274E-4S4791 _,
- -- v
In a DataGridView tl1e first cell of each row starts at zero (0) and continues, in the example above the cells would
be 0-4.
In tl1e previous exarnple if we look at the row that is currently selected, Adobe Media Player:
$datagridview.SelectedCells[O].Value = Adobe Media Player
$datagridview.SelectedCells[l].Value = 1.8
$datagridview.SelectedCells[2].Value = Adobe Systems Incorporated
$datagridview.SelectedCells(3].Value = x86
$datagridview.SelectedCells[4].Value = {DE3A9DC5-9A5D-6485-9662-347162C7E4CA}
.-
F_
u11_RowSe
__ _ _ _ _ _ __,.lv~
1ect Depending on the setting of SelectionMode in the
CelSelect
Ful!RowSelect Data GridView properties it \ Vill determine ,;vhat tl1e user can
~ select in the DataGridView.
Rowtteadetselect
Cok.mnHeadetSe!ect
In tbe example above \.Vhere we allow the user to select inultiple rows then uninstall the selected software \.Ve use
the following code:
6 $softname $_.Cells[O].Value =
7 $returnval =
([WMICLASS]"\\$computer\ROOT\CIMV2:win32_process").Create("msiexec '/x$uhinstall
'/norestart '/qn")
8 }
*This should be wrapped in an event, such as an Uninstall Button tvith a click event. $buttonl_Click={}
E~t C lurnn x Header Text - this is the visible na111e of the column.
~ ~-:..._ ReadOnly - [True/False] set as tn1e if you do not want the data in
l ML Jl Remove
aGrid\lew eonttol horizoritaly.
To add a row of data to a DataGridViel.v; your na1nes and variables will of course be different from exan1ples.
1JT) MyForm x
Monday . December 26. 2016 0 ...
Date\Ti December 2016
Sun Mon Tue Wed Thu Fri Sat
27 28 29 30 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
Dayof 18 19 20 21 22 23 24
25 00 27 28 29 30 31
1 2 3 4 5 6 7
DayofY. [ I Today: 12/26/ 2016
216 I PowerShell Studio - A Comprehensive Guide
The control displays a calendar style form so the user can select a specific date, the default date/tin1e is always the
current date/time.
~1
--------.
54
lAdd Day(s)
==================
I
$datetime ickerl.value.AddDays(xx)
Add Hour(s} $datetimepicker 1. value.AddHours(xx)
Add Minute(~l _ _ _ _ _ _ _ _ f$dateti1nepickerl.value.AddMinutes(xx)
Add Month(s)
,___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ $datetimepickerl.value.AddM~nths(xx)
PowerShell Studio - Form Controls I 217
l $datagridviewl_CellMouseDown=[System.Windows.Forms.DataGridViewCellMouseEventHandler
]{
2 #Event Argument:$_ = [System.Windows.Forms.DataGridViewCellMouseEventArgs]
3 if($_.Columnlndex -eq 2){
4 $dtp =New-Object System.Windows.Forms.DateTimePicker
5 $datagridviewl .Controls.Add ($dtp)
6 $dtp.Format ='Short'
7 $Rectangle= $datagridviewl .GetCellDisplayRectangle($_.Columnlndex, $_.Rowlndex, $true)
8 $dtp.Size =New-Object System.Drawing.Size($Rectangle.Wid-th, $Rectangle.Height)
9 $dtp.Location =New-Object System.Drawing.Point($Rectangle.X, $Rectangle.Y);
l0 $dtp. BringTofront()
ll $dtp.add_ ValueChanged({
12 $datagridviewl .CurrentCell.Value =$this.Value
13 $this.Visible = $false
14 }) $dtp.add_LostFocus({ $this.Visible= $false }) } }
o9 Fornl D x Useful when you half limited space on your fonn but need to present many
ite1ns for selection by the user.
(Select The DomainUpDown Control can be populated either ina.nually using the
collection properties of the control \Vithin the PowerShell Studio designer?
or programinatically through code.
55 https://www.sapien.com/forums/viewtopic.php?t=l 0544
218 I PowerShell Studio - A Comprehensive Guide
NOTE: All iten1s that are added via the iten1s property of the control, will return once the form is closed and
reopened, even if remove or clear is used.
BlinkRate Gets or sets the rate at which the error icon flashes.
BlinkStyle Gets or sets a value indicating when the error icon flashes.
CanRaiseEven Gets a value indicating whether the component can raise an event.
ts
Container Gets the !Container that contains the Component.
ContainerCon Gets or sets a value indicating the parent control for this ErrorProvider.
trol
DataMember Gets or sets the list within a data source to monitor.
DataSource Gets or sets the data source that the ErrorProvider monitors.
DesignMode Gets a value that indicates whether the Component is currently in design mode.
Events Gets the list of event handlers that are attached to this Component.
Icon Gets or sets the Icon that is displayed next to a control when an error description string has
been set for the control.
56 https://www.sapien.com/blog/2011/08/l8/primalforms-2011-spotlight-on-the-errorprovider-control/
PowerShell Studio - Form Controls I 219
RightToLeft Gets or sets a value that indicates whether the component is used in a locale that supports
right-to-left fonts.
Site Gets or sets the !Site of the Component.
Tag Gets or sets an object that contains data about the component.
Icon
Use this property to change the icon used to indicate an error.
Default Icon:
BlinkRate
This property controls the rate in nlilliseconds at which the error icon blinks. Use this property to il1crease or
decrease the blink rate of the icon. Note: 1000 ntilliseconds = 1 sec.
Default Value: 250
Blink Style
Tllis property controls whether the error icon blinks when an error is set.
AbtVaysBli nk:
Always blinks ~vhen the error icon is first displayed, or when an error description string is set for the control and the
error icon is already displayed.
NeverBlink
Never blinks the error icon.
SetError
This method sets the error description string for the specified control.
Use the SetError 1nethod to display the error icon next to the target control and display a specified error 1nessage
when the user hovers the inouse over the error icon. To clear a11error1nessage, pass an e1npty string to the method,
using the sa1ne control as a parameter.
l $textboxName_Validating=[System.ComponentModel.CancelEventHandler]{
2 #Event Argument:$_ = [System.ComponentModel.CancelEventArgs]
3 #Check if the Name field is empty
4 if($textboxName.Text.Trim() -eq "")
5 {
6 #Display an error message
7 $errorproviderl .SetError($textboxName, "Please enter your name.");
220 I PowerShell Studio - A Comprehensive Guide
Name:
SetlconAlignment
This 1nethod sets the location where the error icon should be placed in relation to the control. Default Alignment:
MiddleRight
Note: You must set the aligrunent for each individual control.
Note: You can set also set the Icon Alignment in the designer by settiI1g the target control's
"IconAlignment on errorproviderl" property.
An example use of the SetlconAlignment method \here tl1e error Icon is set on the left side of the TextBox
control:
$errorproviderl .SetlconAlignment($textboxName,
[System.Windows.Forms.ErrorlconAlignment]::Middleleft)
Name:
( OK )
TopLeft
The icon appears aligned with the top of tl1e control and to the left of the control.
TopRight
The icon appears aligned with the top of the control and to tl1e right of the control.
PowerShell Studio - Form Controls I 221
MiddleLeft
The icon appears aligned witl1 tl1e middle of the control and the left of the control.
MiddleRight
The icon appears aligned \.Vi th the middle of the control and the right of the control.
BottomLeft
The icon appears aligned with the bottom of the control and the left of the control.
BottomRight
The icon appears aligned witl1 the bottom of the control and the right of the control.
SetlconPadding
Sets the amount of extra space left bet\.veen the specified control and the error icon.
B.
.. Note: You 1nust set the padding for each individual control.
$errorproviderl . SeticonPadding($textboxName, 1)
222 I PowerShell Studio - A Comprehensive Guide
In the For1nEvent_Load section add the following lines of code to look like belo\v:
1 $FormEvent_Load={
2 #TODO: Initialize Form Con trols here
3 $errorproviderl .SetlconAlignment($textboxName,
[System.Windows.Forms.ErrorlconAlignment]::Middleleft)
4 $errorproviderl .SetlconPadding($textboxName, 1)
5
6 Update-ComboBox $comboboxl
([System.Enum]::GetNames([System.Windows.Forms. ErrorlconAlignment]))
7 $comboboxl .Selectedltem = "MiddleRight"
8 $errorproviderl .SetError($textboxName, "Please enter your name.");
9 }
Create an textboxNaine "validating" event (right-click on the textboxNa1ne control and select "validating"). Within
the textboxNaine_Validating section add the follo\ving lines of code to look like below:
10 $textboxName_Validating=[System.ComponentModel.CancelEventHandler]{
11 #Event Argument:$_ = [System.ComponentModel.CancelEventArgs]
12 #Check if th e Name field is empty
13 if($textboxName.Text.Trim() -eq "")
14 {#Display an error message
15 $errorproviderl .SetError($textboxName, "Please enter your name.");}
16 else
Create a comboboxl "selectedindexchanged'' event (right-click on the combobox control ai1d select
"selectedindexchanged"). Within the comboboxl _selectedindexchanged section add the f 0110,ving lines of code to
look like below :
19 $comboboxl _SelectedlndexChanged={
20 #TODO: Place custom script here
21 $errorproviderl .SetlconAlignment($textboxName,
[System.Windows.Forms.ErrorlconAlignment]$comboboxl .Selectedltem)
22 }
Create a nm11ericupdownl "valuechanged" event (right-click on the nu1nericupdown control and select
"valuechai1ged"). WithiI1 the nu1nericl_valuechanged section add the following lines of code to look like below:
23 $numericupdown 1_ ValueChanged={
24 #TODO: Place custom script here
25 $errorproviderl .SetlconPadding($textboxName, $numericupdown l .Value)
26 }
Now 'vhen you run the form it should appears like the example below :
Enter Name:
11
[ OK ]
224 I PowerShell Studio - A Comprehensive Guide
59Wlrile researching this topic, I came across a great article by John Simmons about the FileSystemWatcher, it is
written for C# however it is still a great article discussing the advai1tages and limitations of this control.
The FileSystemWatcher component is designed to watch for changes within the directory, not to changes to the
directory's attributes themselves. For exa1nple, if you are watclring a directory called c:\Mydir, the co1nponent will
monitor changes within the directory but not changes to the directory itself.
There are several properties you set for your FileSystemWatcher co1nponent instai1ces to determine ho\v they
behave. These properties determine what directories and subdirectories the co1nponent instance will monitor and
the exact occurrences \.vithin those directories that \Vill raise events.
The Path property indicates the fully qualified path of the root directory you want to watch. This can be in standard
directory notation(c:\directory) or in UNC fonnat (\\server\directory).
58 http://www.c-sharpcorner.com/article/monitoring-file-system-using-filesystemwatcher-class-partl I
5 9 https://www.codeproject.com/ artic les/587 40/filesystemwatcher-pure-chaos-part-of
PowerShell Studio - Form Controls I 225
The IncludeSubdirectories property indicates \.Vhether subdirectories within the root directory should be
monitored. If the property is set to true, the component watches for the same changes in tl1e subdirectories as it does
in the main directory the component is watclling.
Set Filter property to an empty string("") to watch for changes in all files. To watch a specific file, set the Filter
prope1ty to the file name say "samp.t:A1" . You can also ' vatch for changes in a certain type of file. For example, to
watch for changes in document files, set the Filter property to "*.doc".
FileSystemWatcher class does not ignore lridde11 files. Setting the Filter does not decrease "vl1at goes into the buffer.
By settingNotifyFilter property to one of the NotifyFilters values, you can track several types of changes such as
changes in Attributes, the LastWrite date and time, or the Size of files or directories or when sec1trity access to a
file or directory tights changes. These values are all part of the NotifyFilters enumeration. You can set mtlltiple
changes to \Vatch for by using "I" operator.
Your FileSyste111Watcher con1ponent has the potential to receive an enormous ntunber of events, particularly if you
have set it to \.Vatch a very high-traffic directory. Tl1is can cause problems, as the FileSyste1nWatcher co1nponent
can only receive event notifications at a manageable rate. The system notifies the co1nponent of ftle changes, it
stores those changes in a buffer the co1nponent creates and passes to the Win32 Application Prograinming Interfaces
(APis). If there are many changes in a short tiine, the buffer can overflo\v. This causes the co1nponent to lose track
of cha11ges in the di.rectory, and it ' vill only provide "blanket" notification a11d the con1pone11t \.Vill raise an exception.
Default size is 4KB, you cai1 i11crease the buffer size using Inten1a1BufferSize, but increasing the size of the buffer
is expensive, as it comes from non-paged inen1ory that caiu1ot be swapped out to disk, so keep the buffer as srnall
as possible. A 4 KB buffer can track changes on approxiniately 80 files in a directory. Each event takes up 16 bytes
in the buffer, plus enougl1 bytes to store the na111e of the file, in Unicode (2 bytes per character), tl1at tl1e event
occurred on. You can use this info11nation to approximate the buffer size you will need.
To avoid a buffer overflow, use the NotifyFilter and Include Subdirectories properties so you can filter out unwru1ted
change notifications.
In addi.tio11 to using the FileSyste1nWatcher co111ponent to innnediately 11101ritor a specific directory. you can use the
WaitForChai1ged method to wait until a specific event occurs ai1d then contiI1ue with execution of tl1e thread. For
exa1nple, if you are working with a Web-based nevvs applicatio~ you inight create an adn1in portion of the site
\Vhere users upload tl1eir ne\.vs stories. You cottld use the WaitForChai1ged method to \.Vatch tl1at directory until the
last access date c.hanges, and tl1en begin processing tl1e ne\.vs directory for new articles.
You specify U1e type of change to watch for by setting tl1e value of a WatcherChangeType e11umeration. The possible
values are as follows:
226 I PowerShell St udio - A Comprehensive Guide
WaitForChanged is a synchronous 1nethod that retun1s an object of type WaitForChangedResult. This class contain
specific infom1ation on the type of change that occurred in the directory. You can access information such as Name,
OldName, and TiinedOut on this object to find out 1nore about the change. TimeOut is the time (in 1nilliseconds) to
wait before timiI1g out.
If you use it in a Windov.is Form application, the application \Vould stop responding if the inethod was used on the
UI thread instead of the \Vorker thread.
Although some co1nmo11 occurrences, such as copying or moving a file, do not correspond directly to ai1 event, these
occurrences do cause events to be raised. When you copy a file, the syste1n raises a Created event in the directory
to \;vhich tl1e file was copied but does not raise ai1y events in the original directory . When you move a file, the server
raises two events: a Deleted event in tl1e source directory, followed by a Created event in the target directory.
FileSyste1nWatcher has fotu different events that can be added and configured, you can access these events by right-
clicking on the FileSystemWatcher control in tl1e Designer.
Olanged
0 Created
0 Deleted
l Renamed
j
Create r _J
cancel
PowerShell Studio - Form Controls I 227
There are four different flow directions: LeftToRight, TopDown, RightToLeft, Botton1Up.
I I
jOradiob.Aton2 lj
I
!O ra<iob4 .ionJ :
IjO radiob.Aton4 I!
I I
. I
! I
I. .I
I !
I
!
I
I"'------------------------------"'i
Left to Right Top Down
og Fo m oSI rm
-------------------------. r---------------------------------------------------------------------.....
...
--~ ---------- ---------~-~-- -----~------
!0 raciotx.ttonJ 0 raciotx.tton2 0 raciotx.tton1 '
:'
I ..' I
'
I 0 raciotx.tton4 .'
:
,
:
.
I
I
I
::
.'
I
I.. ''
: iiO raciobutton4 II
...I
I
I .'
'
Ii I
:O
.:'
raciotx.ttonJ
.
'
I 1..0
:
raciobutton2
..i
I
:
.i: !O !
."'----------------------------- '
---- ----------------------------------------J -----raciobutton
--......... 1
...... _...............____,
-----------~-..._...............................................
Be aware that when using the FlowLayoutPanel that it will ignore all docking an anchoring of any controls that are
placed within it, if not it would defeat the purpose of the Flo"vLayoutPanel having the ability to align controls.
228 I PowerShell Studio - A Comprehensive Guide
5.4 FOLDERBROWSERMODERNDIALOG
Q 60
If you are running Windows 7 or later it '1Vill display the moden1 version of the FolderBro,;yserDialog:
Org.ono:t """"(oldtf
Oocumcnb
If you are running on a legacy OS, less than Windows 7, it will display the original FolderBrowserDialog:
_,__
I
.......
,o...;,.-..-.~
......
Ntlilo ...
~ ......,....~
~ .... au
.---
~--1:111
ii '-SMl~W
31 ...
......._.,
--
-
....
--
.............
/J-.....ilrrilM. .
. . ,...... . . . . .1
Ila r ....s;.,.
Here is an exa1nple of how to display the FolderBrowserModernDialog using its Show Dialog method:
Keep in niind that the (TextBox - Browse for Folder) in the Controls Sets panel still uses the legacy style
FolderBro111serDialog. I'll show you a little later ho111 you can create your own Modern Browser Control
set, iffact you can easily create many control sets for comb;nations ofcontrols that you regularly use.
60https://www.sapien.com/blog/2015/05/0l/powershell-studio-2015-new-folderbrowsermoderndialog-
control/
PowerShell Studio - Form Controls I 229
....:
With this control, there is no code that is automatically generated in the editor, however there is so1ne you will need
to add yourself. In this exainple I used a click event for the "Change Font" button:
1 $buttonChangeFont_Click={
2 $fontdialogl .ShowDialog()
3 $font= $fontdialog l .Font
4 $richtextbox 1.Font= $font
5 $buttonChangeMe.Font =$font
6 }
230 I PowerShell Studio - A Comprehensive Guide
The GroupBox is used for design purposes to organize and layout the functionality of your fonn so that it is easier
for the user to follow.
~JV..J
For example, as you can see in the figure on the
I* Force wsus Updates
0 Use Mia'osoft Update SeNer
SeJect ths op:oo to use the
left, multiple group boxes have been used within
Microsoft Wnd<ms Update
SeNer for recevng updates. a large group box to organize the different
I
settings. This inakes it inuch easier for the user
to follow the organization of the different
0 Notiy before download and instal
@ Enable 0 Disable options that are available.
@ /Uo download/Nolly of flStalation
@ ~Users 0 Aduilisbators
'""
0 Pl.ow user lo deode ~tien to Fe$lart
@ Yes - Siertly 0 No -treat like al updates
@ Notiy user alio-feStart In 15 miUes
I t ..li:A
wsus Com!ation
0
You can see the final outcome in the figure to the I Foroe WSUS Updates
Use Microsoft Update SeNer
Select this opt.on o use the
right. This is a much better approach to form Mcrosof: Wndows Update
SeNer fot receM'l9 updates
design.
Download and lnstal Options
l.eni of Tme Warring Before Reboot If Recped'> How often to check f0< new ~es1
@ Defaul - 5 min. 0 Custom Mirues @ Every 22 hous 0 Custom Hous
1
Select Hotn :
'Select Mrues : I
PowerShell Studio - Form Controls I 231
o_. Form 0 x First, Drag/Drop the HelpProvider Control to your form, you will
notice that it has very little properties associated with it, and there is no
code generated in the editor. However, it is very simple to getting
button1 runrung.
In this exainple, I have created a si1nple fonn with one button ai1d one
combobox to demonstrate how to setup the HelpProvider, this will
work the same for any control.
First you need to tell the form which control you are initiating the HelpProvider for:
l $helpproviderl .SetShowHelp($button l)
Second, you need to set the string that you \Vant to display when the user clicks on the control and presses Fl :
l $helpproviderl .SetHelpString($button l, "Help for button l ")
:: ...
232 I PowerShell Studio - A Comprehensive Guide
0-.. 61
The hnageList Control is used to store a group of in1ages that can be accessed by other controls. linages
that are included in the I1nageList are stored as bina.J.}1 data 'vithin the form. Example below:
l # imagelistl
2 $Formatter_binaryFomatter = New-Object
System. Runtime .Serialization.Formatters. Binary. BinaryFormatter
3 #region Binary Data
4 $System_IO_MemoryStream = New-Object System.10.MemoryStream
(, [byte[]] [System.Convert] ::FromBase64String ('
5 AAEAAAD///// AQAAAAAAAAAMAgAAAFdTeXNOZWOuV21uZG93cy5Gb3JtcywgVmVyc21vbjOOLjA
u
6 MC4wLCBDdWxOdXJIPW51dXRyYWwslFB l YmxpYOtleVRva2VuPWl3N2El YzU2MTkzNGUwODkFAQA
A
7 ACZTeXNOZWOuV21uZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJIYW l lcgEAAAAERGFOYQcCAgAAAAk
D
8 AAAADwMAAAAaCAAAAklTRnQBSQFMAwEBAAEIAQABCAEAARABAAEQAQAE/wEJAQAl/wFC
AUOBNgEE
9 BgABNgEEAgABKAMAA UADAAEQAwABAQEAAQgGAAEEGAABgAIAA YADAAKAAQABgAMAA YA
BAAGAAQAC
10 gAIAA8ABAAHAAdwBwAEAAfABygGmAQABMwUAATMBAAEzA.Q ABMwEAAjMCAAMWAQADHA
EAAylBAAMp
11 AQADVQEAAOOBAANCAQADOQEAAYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB
lgHvAQAB
12 l glnAQABkAGpAaOCAAH/ATMDAAFmAwABmQMAAcwCAAEzAwACMwlAATMBZglAATMBmQIA
ATMBzAIA
13 ATMB/wlAA WYDAAFmATMCAAJmAgABZgGZAgABZgHMAgABZgH/AgABmQMAAZkBMwlAAZkBZg
IAApkC
14 AwcAAQMHAAEBBwABAQcAAQEnAAEHBwABBwcAAQcHAAH/BgAL'))
15 $imagelistl .lmageStream =
$Formatter_binaryFomatter.Deserialize($System_IO_MemoryStream)
16 $Formatter_binaryFomatter =$null
17 $System_IO_MemoryStream =$null
18 $imagelistl .TransparentColor = 'Transparent'
19 #endregion Generated Form Code
There are five different bit depths to choose fro1n for the images in the hnageList; 4Bit, 8Bit, 16Bit. 24Bit, and
32Bit.
Bit depth refers to the color infonnation stored in an itnage. The higher the bit depth of an image, the more colors it
can store. Tl1e si1nplest i1n age, a 1 bit i1nage, can only shovv two colors, black and \Vhite. That is because the 1 bit
can 01tly store one of tw o values, 0 (white) and 1 (black). An 8 bit image can store 256 possible colors, vvhile a 24
bit i1nage can display about 16 million colors. Keep in mind that the larger the bit-depth and size of yo1rr images,
the larger tl1e finished .psf or .ps l file will be, I recoilllnend using the s1nallest bit-depth that you can get away with.
The human eye can only discern about 10 nzillion different colors, so saving an inzage higher than 24-bit
is excessive ifthe only intended purpose is for vie1'11ing, unless you need transparency. Also, standard JPEG
and 1'/FF.files can only use 8-bit and 16-bit, respectively.
a .. ffii lmagelist Tasks To add ilnages sitnply click on the triangle in the upper
j ~ unagelistl
... .. ; Image Size ~t:Wt3 right con1er of the I1nageList control, then select the
iinage size, bit-depth, and click the " Choose Images" .
Image Bit Depth IDepth8Bit v
1
J Choose mages
In tl1e image on the right you can see how an i1nage with a
lower bit-depth will have a relatively graiitier look to it
than an image w ith a higher bit-depth. Typically for
1nonitor viewing 8-bit provides a liappy medium between
size savings and great looking hnages.
5. 9 LABEL CONTROL
Q 62
The Label Control is a clickable text string display. Typically used to provide labeliI1g for other controls.
-
Analysis Meter -- --- Here we use a Label Control (Analysis Meter) to indicate what the
ProgressBar is used for.
0%
Ttflhenyou change the text in a label PowerShell Studio will change the nan1e of the variable of the Label
Control. For instance, ifyou change the name ofthe Label Control to "Exit ,, then PowerShell Studio will
change all references in the script code to $LabelExit.
TIP: To direct Windows PowerShell to evaluate an expression before inserting the result in a string, use a
sube:Kpression. The syntax is$( <e:x.'})ression ).
Without subexpression:
Form x
Building automa~ on (Get-Process PO'lt-wShe!I S.'udio1 Main\'Jinda11Title
With subexpression:
Form x
&nkJ.ng 3u:oma:.on on SAP1EN POY.tfShell S:udio 20 5
To disable or enable the clickable feature of the label use the Enabled property. Enabled = $false 111ill
disable the clickable feature.
62 https://www.sapien.com/blog/2015/12/ 16/spotlight-on-the-label-control/
PowerShell Studio - Form Controls I 235
The LinkLabel Control is much like the Label Control that vve just discussed, with the exception that this provides
for a linkable text.
PovrerShell (Administrator)
- This is only a fevv of the many possibilities that can be ilnagined
for use.
Open Webpage
l $1inklabelAutomatedRemediation_LinkClicked=[System.Windows.Forms.LinklabellinkClickedEven
tHandler]{Start("http://www.automatedremediation.com")}
The ListBox Control is used to display multiple items which can be populated either manually in the control
properties or program1natically \:vithin the script code. The ListBox also provides the MultiColu1nn property to
enable the display of items in colmnns instead of a straight vertical list of items. With this, the control can display
more visible ite1ns a11d the user no longer needs to scroll to an item.
The selection 1node property allows you to define if the items in the ListBox are single-select, multiple-select, or
not selectable at all.
None No items are selectable
One Only one ite1n at a ti1ne is selectable
MultiSimple A inouse click or pressing the SPACEBAR selects or deselects an item in the list.
MultiExtended Pressing SHIFT and clicking the 1nouse or pressing SHIFT and one of the arrow keys (UP
ARROW, DOWN ARROW, LEFT ARROW, and RIGHT ARROW) extends the selection
from tl1e previously selected item to the current item. Pressing CTRL and clicking the inouse
selects or deselects an item in the list.
The selection mode can also be set within script code using:
$listboxl.selectionMode = "MultiExtended"
To allow users to select 1nultiple items then perfor1n an action on each item selected, you can si1nply do tl1e
follo\ving:
./ Set the selection inode for the ListBox control to either "Multiextended" or "Multi Simple" .
./ Perform the desired actions on each selection with: $Listboxl.selecteditems I o/o {$_ "Enter your actions"}
The $listbox.selecteditems refers to all selected ite111s i11 the ListBox. The % after the pipe is a symbol for
FORBACH and the $_ refers to tl1e current object. You could even call functions or scripts blocks.
PowerShell Studio - Form Controls I 237
aSJ Form D x In this example, we have a ListBox control at the top, which we
have populated with ite1ns in the collection within the control's
property window.
computerl
er2 There is one button in the center that will be used to perfonn an
action on each selected ite1n in the ListBox.
....:
l function checkonline
2 {
3 # Check if computer is online
4 if (test-Connection -ComputerName $_-Count l -Quiet)
11 11
5 {$richtextboxl .AppendText( $_ is online 'n )}
6 else
11 11
7 {$richtextboxl .AppendText( $_ is offline 'n )}
8 }
9
l 0 $buttonProcessSelectedCompu_Click = {
ll # Clear the textbox
1111
12 $richtextboxl .Text=
13 # Call the CheckOnline function for each selected item
14 $Listboxl .Selectedltems I 3 {
15 checkonline $_}
16 }
238 I PowerShell Studio - A Comprehensive Guide
This information comes from David Corrales at SAPIEN who created a very nice three-part series of Spotlights on
the ListVievv Control.
Vielv
This property indicates how items are displayed in the control. Use this property to set the style or vievv of the
ListView control.
Largelcon
Each item appears as a full-sized icon with a label below it.
~
PrimalScript PrimalForms OtangeVue
PrimalSQL
~
PrimalXML
Details
Each ite1n appears on a separate line \Vith further information about each item arranged in columns. The left-most
colmnn contains a small icon and label, and subsequent colmnns contain sub items as specified by the application.
A column displays a header which can display a caption for the co1Ullll1. The user can resize each column at run
ti1ne.
Product Status
, ............ ........................,...................................................................................
._
!OtangeVue lnsta ed
~;lP~~F;:;OOoooououoooooouomuuuuuo~~~"";f """""""""""""""""""""
@) PrimalSaipt lnstaDed
PrimalSQL lnstaDed
lnstaDed
63 https://www.sapien.com/blog/2012/04/04/spotlight-on-the-listview-control-part- l J
PowerShell Studio - Form Controls I 239
Smallfcon
Each ite1n appears as a s1nall icon with a label to its right.
~ f(h~~~V~~! !Si Primal Forms
~-p~~&riPt.. - PrimalSQL
I PrimalXML
List
Each ite1n appears as a s1nall icon with a label to its right. Items are arranged in columns with no column headers.
1~o;~~~1
- , ..............................
!:i:l Primal Forms
~ PrimalSctipt
Primal SOL
,...., PrimalXML
Tile
Each item appears as a full-sized icon with the ite111 label and subitem infonnation to the right of it. The subite1n
information that appears is specified by the application. This vie,;v is available only on Windows XP and the
Windows Server 2003 fa1nily. On earlier operating systems, this value is ignored and the ListVie\v control displays
in the Largelcon view.
,.................................1
piangeVue 1
l n~a ted
....................................................................................
,l
"1
tiilflfl
- - nsta .ed
Prima!Forms
~ PrimalScript
~ f'sta.ed
(~;) PrimalSQL
~) 4'\staed
fI Prima!XML
~ Jistaied
240 I PowerShell St udio - A Comprehensive Guide
Sonie properties only pertain to particular views. The compatible viei11s will be listed in each property 's
description .
Alignment
This property indicates hovv items are aligned within the ListView .
Default
When the user moves ru1 ite1n, it re1nains \vhere it is dropped.
Top
Ite1ns are aligned to tl1e top of the ListVie'v control.
Left
Ite1ns are aligned to the left of the ListView control.
SnapToGrid
Ite1ns are aligned to an invisible grid in the control. When the user moves an ite1n, it moves to the closest
juncture in the grid.
AllowColumnReorder
This property indicates whether the user can reorder colunm headers in the Details view. Set this property to True,
the users the order of the column header, by dragging the header to the desired location.
ChecldJoxes
This property indicates \.Vhether a check box appears next to each item in the control.
When CheckBoxes is set to True, use the ItemChecked event to respond to an item's checked state changes.
Product Status
[t] MEh~~9~v~~~~;i
CJ !s fF>;;~i"F~~.......................~~~. . . ..
El ~ PrimalScript lnsta ed
EJ ~ PrimaJSQL lnstaDed
EJ I.- PrimaJXML lnsta!led
Columns
This property contains a collection of colu1nn headers that are displayed in the Details view.
PowerShell Studio - Form Controls I 241
c:> r: ~
lktYltwTMb
tcBltt~
(cfjC~~
((fi Gr~ _ _t_
()pcm h t_C_
olumns
_ _c_oC_
fl:_
tlOn
_ ~
- ,
V'icw:
===o )
Or you can access the ColumnHeader Collection Editor via the Property Pane:
AnowColumnR False
Autokange False
(Colledioni Q
ContextMenu~ (none) ~
Enabled True
Groups (Collection)
The ColmnnHeader Collection Editor allows you to add I remove Colmnn as well as modify their properties:
( st ... _ Cdloc+_C...
Olltcfe. .l ; C l
td! I &i .
: l
. l6oc - ' 3
...,,_ o -
.....,.~ t:::l -
T ~
f~ "
!Al
ColumnBeader [System.Windows.Forms.ColtunnHeader]
t
DisplayIndex This property indicates the display order of the column relative to the currently displayed
columns
242 I PowerShell Studio - A Comprehensive Guide
Imagelndex This property indicates the index of the image displayed in the ColumnHeader.
Text This property contains the text displayed in the column header.
TextAlign This property determines the horizontal aligrunent of the text displayed in tl1e CohunnHeader.
Values (Default: Left):
Left
The object or text is aligned on the left of the control element.
Right
The object or text is aligned on the right of the control ele1nent.
Center
The object or text is aligned in the center of the control ele1nent.
Set Width = -1, to adjust the width of the longest ite111 in the column.
Set Width = -2, to auto size to the width of the colUllll1 heading.
Note : When setting these special values, the control will automatically replace the Width with the calculated
value.
FullRowSelect
This property indicates "vhether all sub items are highlighted along with the item when selected.
GridLines
This property indicates whether grid lines appear bet\veen the ro,vs and columns containing the items ai1d sub ite1ns
in the control. The grid lines are only shown when in Details view.
Product Status
~a:;;;g~v~~~~~f ...................................--
tst PrimalFormslnstaDed
~ PrimaJScript lnstaBed
bCl PrimaJSQL lnstaDed
I;- PrimaJXM L lnstaDed
Grou1>s
This property contai11s a collection of ListViewGroup objects that are used by the control. Groups are very useful
to display ite1ns in categories withil.1 the ListView.
B.
If there are groups defined and a item has no group set; it will go into the "Default " group.
You can access the Group Collection Editor via the Designer:
61C~.a
( Groupi ~--tM-(-ciurnM--c-oll-t':-1.-
~ _.
'":l-tO--.t
c~
---ol
HeaderStvle
This property indicated the style of the colu1nn headers in the Details vievv. Use this property when you wai1t to
prevent the users from having the option to click on the headers. Typically, you would want to sort the itetns when
a user clicks on the header. You can respond to a header click by using the ListView 's Colu1nnClick event.
None
The colu1nn header is not displayed in report view.
244 I PowerShell St udio - A Comprehensive Guide
Nonclickable
The colunm headers do not respond to the click of a mouse.
Clickable
The column headers function like buttons and can cany out an action, such as sorting, when clicked.
HidcSelcction
This property indicates whether the selected item in the control remains highlighted \vhen the control loses focus.
HotTracking
This property indicates whether the text of an ite1n or subite1n has the appearance of a hyperlink \vhen the inouse
pointer passes over it.
Enabling hot tracking will cause the Activation property to be set to OneClick and the HoverSelection property to
be set to true. In addition, run-time label editing is not allo\ved \vhen hot tracking is enabled.
LabclEdit
This property indicates whether the user can edit the labels of ite1ns in the control. Use the BeforeEditLabel and
AfterEditLabel events in order react to when a user changes a label.
Largelm ageList
This property contains the I1nageList control used by the ListView for i1nages in Large Icon view. See the Spotlight
on tl1e ImageList Control blog article for n1ore infon11ation on tl1e ImageList.
" The index of the corresponding SmalllmageList should be the same as the LargelmageList.
SmalllmageList
This property contains the ImageList control used by the ListView for images in all views except for the Large
Icon view.
StatelmageList
This property contains the ImageList control used by the ListView for custom states.
PowerShell Studio - Form Controls I 245
Q_ If an IniageList is specified in the StatelmageList property and the CheckBoxes property is set to true, the
in1ages at index positions 0 and 1 in the JnzageList are displayed instead of the check box. The image at
index position 0 is displayed instead of the unchecked check box, and the image at index position 1 is
displayed instead of the checked check box.
MultiSelect
This property indicating "vhether 1ntlltiple ite1ns can be selected. If this property is set to tn1e, use the Selectedlte1ns
property to determine "vhich items are selected.
Sorting
This property indicates the way ite1ns are to be sorted.
None
The ite1ns are not sorted.
Ascending
The ite1ns are sorted in ascending order.
Descending
The ite1ns are sorted in descending order.
Selecteclltems
This property contains all the ite1ns that are selected in the ListView.
ft..
Each itenz is a ListViewltem object; so you must use the Text property to display the nanie.
Items
This property contains a collection of all the items in the ListView. All items in a ListView are represented by a
ListViewlte1n object:
ListViewltem [System.Windows.Fonns.ListViewlte1n]
246 I PowerShell Studio - A Comprehensive Guide
t
Checked This property indicates \Vhether the item is checked.
Text Th.is property contains the displayed teA1 of the item.
ToolTipText Th.is property contains the text shown when the 1nouse pointer rests on the ListViewltem.
GroUfl This property points to the group to \Vhich the ite1n is assigned.
Set this property to any existing Group. All items \Vith an unsigned Group will be shovv in
the ''Default" Group.
lmagelndex This property indicates the index of the i1nage that is displayed for the iten1.
Statelmagelndex Tlus property indicates the index of the state image (an image such as a selected or cleared
check box that indicates the state of the ite1n) that is displayed for the ite1n.
SubItems Tlus property is a collection conta.imng all subitems of the ite1n.
Compatible Views: Details, Tile
You can access the Ite1ns Collection Editor via the Designer:
Ed
Opens the Items collection td1tot
Ed Gr
Otta1ls
LabelEdil
labe!Wrap
(Collection)
False
True
ca
The ListVie\vlte1n Collection Editor allows you to add I remove Item as well set their properties:
PowerShell Studio - Form Controls I 247
2:
$ II
- ..
,_
..... __
--
i.r... ...,.. '
o -
* a
~
,_
~t-if
=
~,.... ~
a w
c....
... .. ...
-~
~
z -
......
.
1
,_
.
I
Public Method
[ListVie,vltem] Add ([String] text)
Creates an ite1n with the specified text and adds it to the collection.
Example Use:
In the cases where you \vish to add Sublte1ns to the ListVie"v you can add them using:
lmagelndex ~ 2
By clicking on tl1e Sublte1ns property in the
ListViewlte111 Collection Editor, you will be
lmageKey D (none)
StatelrnagelndexD 0 -- presented with a ListViewSubitem Collection Editor.
B Data
(Co ec:tion) The only important property you need to set for a
Tag
ListViewSubltemis the Text property.
B Display
L lndentCount _ 0 Via the Script Editor:
Example Use:
1 $subltem =$1istitem.Subltems.Add('lnstalled')
Clear
This method removes all items and columns from the ListView.
1 $1istviewl .Clear()
Begin U1>date
This 1nethod prevents the control from drawing until the EndUpdate 1nethod is called. Use this 1nethod vvhen you
are updating or adding a large number of ite111s.
EndUpdate
This method resumes drawing of the list view control after drawing is suspended by the BeginUpdate method.
1 $1istviewl .EndUpdate()
PowerShell Studio - Form Controls I 249
l $1istviewl .BeginUpdate()
2 $1istviewl .Items.Clear();
3 foreach ($itemin$array)
4 {
5 [void]$1istviewl .Items.Add ($item.Text)
6 }
7 $1istviewl .EndUpdate();
AfterLabelEdit
This event occurs when the label for an ite1n has been edited by the user. Label editing must be enabled for this
event to be called (See L abelEdit property).
AfterLabelEdit event uses the following argument, which is accessible via the $_ variable:
(System.Windows.Forms.LabelEditEventHandler]
t
CancelEdit Gets or sets a value indicating whether the edit has been canceled.
Label Gets the ne\v text assigned to the label of the ListViewlte1n.
Item Gets the zero-based index of the ListVievvItem containing the label to edit.
Use this event to react to name changes. For example, if the represents a file, you can use this event as a trigger fo r
renaming the file. You should also perform any validation and reject the na1ne change if there is a failure.
l $1istviewl _AfterlabelEdit=[System.Windows.Forms.LabelEditEventHandler]{
2 #Event Argument:$_ = [System.Windows.Forms.LabelEditEventArgs]
3 if(-not (Validate-File Name$_.Label))
4 {
5 $_.CancelEdit =$true
6 }
7 e lse
8 {
9 #Rename the file
l0 }
ll }
BeforeLabelEdit
This event occurs vvhen the user starts editing the label of an ite1n.
This event uses the [System.Windovvs.Forms.LabelEditEventHandler] argument. See AfterLabelEdit for more
information about this argument.
250 I PowerShell Studio - A Comprehensive Guide
1 $1istviewl _BeforelabelEdit=[System.Windows.Forms.LabelEditEventHandler]{
2 #Event Argument: $_ = [System.Windows.Forms.LabelEditEventArgs]
3 if (-not$1istviewl .ltems[$_.ltem].Checked)
4 {
5 $_.CancelEdit =$true
6 }
7 }
ColumnClicli
This event occurs when the user clicks a colmnn header within the list view control. Typically you \Vill use this
event to sort the list by the selected colm1m.
ColmnnClick event uses the follo,ving argu1nent, which is accessible via the $_ variable:
[System.Windows.Forms.ColumnClickEventArgs]
1 $1istviewl _ColumnClick=[System.Windows.Forms.ColumnClickEventHandler] {
2 #Event Argument:$_= (System.Windows.Forms.ColumnClickEventArgs]
3 Write-Host ("Column '{O}' was c lic ked" -f $this.Columns[$_.Column].Text)
4 }
Item Activate
This event occurs when an item is activated. One or more ite1ns can be activated by the user, depending on the
Activate property.
Activating an item is not the same as selecting an item. For exaniple, you may want to display a webpage
when the user activates an item in the ListView. Use the Selectedltenis or Selectedlndices property to
referenced the activated iteni.
Item Checked
This event occurs when the checked property of a ListVievv ite1n changes.
ltemChecked event uses the followil1g argument, winch is accessible via the $_ variable :
[System.Windows.Forms.Item ChecliedEventArgs]
1 $1istviewl _ltemChecked=[System.Windows.Forms.ltemCheckedEventHandler]{
2 #Event Argument:$_= (System.Windows.Forms.ltemCheckedEventArgs]
3 if ($_.Item.Checked)
4 {
PowerShell Studio - Form Controls I 251
5 Write-Host "Checked Item: $($_.Item.Text)"
6 }
7 e lse
8 {
9 Write-Host"Unchecked Item: $($_.Item.Text)"
10 }}
SelectedlndexChan ged
This event occurs when the Selectedlndex collection changes. Use the event when you \ant to react to a change in
the selection.
1 $1istviewl_SelectedlndexChanged={
2 Write-Host "Selection Changed"
3 }
ltemSelectionChanged
This event occurs when the selection state of an item changes. Use this event instead of the SelectedlndexChanged
when you want to kno,;y the which item was selected or unselected.
ItemSelectionChanged event uses the follo,ving argument, "vhich is accessible via the $_ variable:
[System.Windows.Forms.ListViewltemSelectionChangedEventArgs]
Mask
This property sets the string governing the input for this control.
Input Mask ? X]
Select a predef1ned mask description from the list below or select Custom to define a custom mask. You can access the predesigned masks either via the
Mask DeSCliption Data Format Validating Type Property pane, or by clicking the sn1all triangle in the
Numeric (5-digi!s) 12345 lnl32 upper right comer of the MaskedTextBox control.
Phone number (574} SSS-0123 6ione)
Phone number no area code SSS-0123 6ione)
Short date 12111/2003 OateTme
Short date and~ (US) 12/11/2003 11:20 DateTime
Social secuity nunber 000-00-1234 6ione)
Time (fu'opean/Military) 23:20 OateTme
Tune (US) 11:20 DateTime
Ql)Code 98052..()399 6ione)
<Custom> 6ione>
Mask: 0 Use ValidatingType
Preview:
If you need to create your O\Vn format, please refer to the follo\.ving table:
0 Digit, required. This element will accept any single digit between 0 and 9.
9 Digit or space, optional.
# Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in
the Text property. Plus (+) and minus (-)signs are allowed.
L Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is
equivalent to [a-zA-Z] in regular expressions.
? Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is
equivalent to [a-zA-Z]? in regular expressions.
& Character, required. If the AsciiOnly property is set to true, this element behaves like the "L"
element.
c Character, optional. Any non-control character. If the AsciiOnly property is set to true, this
element behaves like the"?" element.
A Alphanumeric, required. If the AsciiOnly property is set to true, the only characters it will
accept are the ASCII letters a-z and A-Z. This mask element behaves like the "a" element.
a Alphanumeric, optional. If the AsciiOnly property is set to true, the only characters it will
accept are the ASCII letters a-z and A-Z. This mask element behaves like the "A" element.
Decimal placeh~older. Th e actual display character used will be the decimal symbol
appropriate to the culture.
) Thousands placeholder. The actual display character used will be the thousands placeholder
appropriate to the culture.
Time separator. The actual display character used will be the time symbol appropriate to the
culture.
I Date separator. The actual display character used will be the date symbol appropriate to
culture.
$ Currency symbol. The actual character displayed will be th e currency symbol appropriate to
the culture.
< Shift down. Converts all char acters that follow to lowercase.
> Shift up. Converts all characters that follow to uppercase.
Disable a previous shift up or shift down.
\ Escape. Escapes a mask character , turning it into a literal. "\\" is the escape sequence for a
backslash.
All other Literals. All non-mask elements will appear as themselves within MaskedTextBox. Literals
characters always occupy a static position in the mask at run time, and cannot be moved or deleted by
the user.
(999) 000-0000
In this inask the first three digits are optional and the last seven are required. The parentheses are considered
Literals, which means the user ca1mot altered the1n.
BeeDOnError
This property indicates ' vhether the iuasked text box control raises the syste1n beep for each user key stroke that it
rejects. Values (Default: $False)
Culture
Tllis property sets the culll1re infom1ation associated with tl1e 1nasked text box.
Set this property if you are specifically targeting a culture that is not the current default (English (United States)
for US 1nachines). This effects the fonnat of the date tin1e entries and these changed will be reflected when
selecting predefined 111asks as n1entioned above.
254 I PowerShell St udio - A Comprehensive Guide
MaskComuleted
This property indicates whether all required inputs have been entered into the input mask.
The MaskC01npleted property can be useful \hen it comes to validating the data. See the MaskFull property for
an example.
MaskFull
This property indicates \.vhether all required and optional inputs have been entered into the input 1nask.
This property is si1nilar to MaskC01npleted property \.Vith the exception that it also enco1npasses optional inputs
specified in the Mask property. To compare these properties and to de1nonstrate their usefulness when it co1nes to
validating, \Ve \ill look at validating a phone number. The predefined Mask for a US phone nmnber specifies that
the area code (first three digits) is optional and the re1naining seven digits are 111andatory .
The following examples will help de1nonstrate the difference between the two properties:
Phone: (555)555-_
I
MaskCompleted False
MaskFull False
Phone: ( ) 555-5555
I
MaskCompleted True
MaskFu II False
Text
The prope1ty gets or sets the text as it is currently displayed to the user.
PowerShell Studio - Form Controls I 255
The value rett1n1ed may include formatting characters specified in the Mask property. See the TextMaskFormat
property for more infon11ation.
TextMaskFormat
Tllis property detenrunes whether the string returned by the Text property includes literals and/or prornpt
characters.
Use the TextMaskFonnat if you need to 1nodify the fonnat of the string that is returned by the Text property of the
MaskedTextBox control.
Pho:ne: ( ) 555-5555
I
JncludePrompt
Return text input by the user as well as any instances of the pro1npt character.
Text: " 5555555"
lncludeLiterals
Return text input by the user as well as any literal characters defined in the rnask.
Text: "( ) 555-5555"
lncludeProniptAndLiterals
Return text input by the user as well as a11y literal characters defined in the mask and any instances of the
pro1npt character.
Text: "(_) 555-5555"
1:!,xcludePromptAndLiterals
Return only text input by the user.
Text: " 5555555"
ValidatingType
Thls property contains the data type used to verify the data input by the user.
You need not set tllis property nonnally, since the preset Masks already set this property appropriately . Tllis ensures
data types are \Vithin the correct range. For example, "77/77/7777" is a valid format for a date, but the value is not.
You must set the ValidatingType property to a type, wllich in PowerShell is defined by the full class name
surrounded by brackets. For exan1ple, to set the ValidatingType to a DateTitne you will need to do tl1e following:
Use this method to determine if the content of the MaskTextBox is valid. This 1nethod requires that a co1npatible
type be set in the ValdiatingType property. If the ValidateText fails it "vill return a $null value otherwise it will
ren1n1 an object of the corresponding type.
Example:
A
The A1askTextBox will automatically validate the text 1~1hen it loses focus.
MasklnputRejected
This event occurs when the user's input or assigned character does not match the corresponding fonnat element of
the input mask.
1 $maskedtextboxPhone_MasklnputRejected=[System.Windows.Forms.MasklnputRejectedEventHa
ndler]{
2 #Event Argument:$_ = (System.Windows.Forms.MasklnputRejectedEventArgs]
3 $1abe1Error.Text ="Failed input -Postion ({O}): {l }" -f $_.Position, $_.RejectionHint.ToString()
4 }
The event passes a para1neter variable $_ . Use this variable to access the follo"ving properties:
$ .Position
Returns the position in the 1nask corresponding to the invalid input character.
$_.RejectionHint
Returns an enumerated value [Systein. ComponentModel.MaskedTextResultHint] that describes "vhy the
input character "vas rejected. Please see the MSDN MaskTextResultHist Help page for 1nore infonnation.
TypeValidationCompleted
This event occurs when MaskedTextBox has finished parsit1g the current value using the Validatit1gType property .
Use this event to react to \Vhen a type validation fails or succeeds. This event is also fired \Vhen the ValdiateText
method is called.
PowerShell Studio - Form Controls I 257
1 $maskedtextboxBirthDate_TypeValidationCompleted=[System.Windows.Forms.TypeValidationEv
entHandler]{
2 #Event Argument:$_= [System.Windows.Forms.TypeValidationEventArgs]
3 if($_.lsValidlnput -eq $false)
4 {
5 $_.Cancel= $true# Keep the focus on the control
6 $errorproviderl .SetError($maskedtextboxBirthDate, "Invalid Date Format");
7 }
8 e lse
9 {
1O $errorprovider 1.SetError ($maskedtextboxBirth Date, "");
11 }
12 }
The TypeValdiationCompleted passes a parainetervariable $_.The following are important properties you can
access with this variable:
$ .Cancel
This property indicates whether the event should be canceled. Set it to $true to retain the focus on the
MaskTextBox.
$_.Is Validlnput
This property indicates whether the fonnatted input string was successfully converted to the validating
type.
$ .Retun1Value
This property returns the object that results fro1n tl1e conversion of the fonnatted input string.
09 Form ~ El . El_
o ---~--------- L-ffi MenuStrip Tasks
T peHere J
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - Embed in ToolStnpConta1ner
Insert Standard Items
Re.nderMode: ManagerRenderMode v l
Dode [TOP v 1
GripStyle: [ Hidden ~
Edit terns .
There are two options for entering 1nenu items, you ca11 type directly into the text boxes in the control, or you can
click on tl1e small triangle in the upper right con1er of the MenuStrip control to access the MenuStrip Tasks, then
click "Edit Items".
File I Here I
right.
I Print I Printer
Save PDF
The default event for each 1nenu ite1ns is a Click Exit I _Here I
' '
Event. To add the Click Event si1nply double- I " Here I
click on the appropriate menu item.
1 $printerToolStripMen u Item_Click={
2 #TODO: Place custom script here
3 }
PowerShell Studio - Form Controls I 259
0 Exit
( :Ji[:ic:>;--Gl~~ M
. . .St1nriplosb
- . EmHd ToolStnpCon1t1ner
In.kit Stlfdltd ltitm5
RitndttModr:: ,~
M.-
.,-
gtr-
Rtn-
dm.t
-o-d-. v
l>o<le Top - iv
--
McniM<1; r.,.OnaJon ......,....,
T...lnago- lnago8"o<oTeoG
Sl:e Tiue
1w.. odTo F,.
r..,.
FllM
r...
v Oat
!ll.90own l>ono)
!ll.9Downl- (Colodlon)
liloTootSlnpMor-.a~
T09
v DniW>
a-i-1
I OK I Clncol
Then in the left pane, select the menu ite1n that you want to add the i1nage to. In the right pane select the image
property and click the browser button to select the inlage that you want assigned. You can also edit the ilnage
aligmnent, scaling, and transparency.
MenuStrip Tasks If you \Vould like to quickly add many of the standard application
1nenu ite1ns quickly, you can do that by clicking on the "Insert
Embed 1n Too Str:pContainer
Standard Items" link within the MenuStrip Tasks window.
Insert Standard Items -
RenderMode: ManagerRenderMode v I File Edit Tools Help
Dacie: Top v I
lJ New Ctrl+ N
- Open Ctrl+O
GripStyle: Hidden v j
Edit Items... Save Ctrl+S
Save As
This will populate the MenuStrip with standard menu items along with 1nany Print Ctrl+ P
associated standard 1nenu icons. Print Preview
This will not generate any of the necessary code in the editor that is Exit
needed to make the menu itenis functional, you will need to insert the
code yourself
$monthcalendar l. SelectionRange
There are several coilllnon co1mnands such as the ones above that are handy to know, so we will go over a few of
those here:
PowerShell Studio - Form Contro ls I 261
Li1nit the amount of days that can be selected in a date range (ex. 20 days):
$n1onthcalendarl .MaxSelectionCotmt = 20
For flexibility, the only limits on date display and ret1rrn for your calendar are the ones the Cale11dar control itself
has. This ineans you can select as large a ra11ge of dates as the Calendar control is willing to let you choose (10
years' worth) over any date range between January I, 1752 ai1d Dece1nber 31, 9998.
There has been some confusion over the differences ii1MaxSelectionCou11ta11d SelectionCount. The main difference
is the SelectionC01mt limits the nu1nber of days ill the retlrrned date rai1ge beginning \Vith the first date selected,
however the user vvill still be able to select a larger rru1ge on the calendar in the fonn.
MaxSelectionCount limits the size of the date range selectable on tl1e calendar by the user. This vvould be the
reco1mnended n1ethod when you are restricting date range sizes because it doesn't make sense to restrict the size of
a date range if the user is unaware a restriction is imposed.
If you vvant to obtainjust the Month, Day or Year of the selected start date use:
$monthcalendarl . selectionstart.day
$monthcalendarl . sel ect i onstart. month
$monthcalendarl. sel ectionstart.year
When you are getting the start, end or ra11ge of dates, it a11toniatically includes the tune, and since your user
doesn't have the ability to set ti1ne from the calendar control, time will always show a start tin1e of 00:00:00
(12:00:00AM).
Luckily, the Mo nthCalendar control bas a ToString so tl1at we cai1 fonnat the date:
$monthcalendarl . Select i onSt art . ToString( 'MM/ dd/ yyyy') \Vill return a date formatted for example
12/30/2016.
Notice that the Month Jv!M is capitalized, nzm is for niinute, so care_fui with your capitalization here! 65A
coniplete list ofCusto1n Date and Time Forn-zat Strings are available on MS'DN 66For niore resources on
the 1\1!onthCalendar Class, Jv!SD1V is an excellent resource that lists every constru.ctor, niethod, and
event.
0-... 67
Use the NotifyIcon control, to alert users of special events, such as when a task is co1npleted. Typically,
this control is used for infonnational purposes, but it cai1 also be used as a source for user ii1teraction.
BalloonTi11Text
This property sets the text associated with the balloon ToolTip. Use this property to
This is the balloon text. display a 1nessage in the Balloon Tooltip.
BalloonTipTitle
This property sets the title of the balloon ToolTip.
Balloon Title ~ x The title text is displayed above tl1e balloon text.
This is the balloon text.
BalloonTiplcon
This property sets the icon to associate witl1 the balloon Tooltip. In other words, the icon displayed inside the
tooltip itself.
Note: The BalloonTip Title property must be set in order to view the balloon icon.
Icon: None "\ x Icon: Info "\ x Icon: Error "\ x Icon: Warning "\ x
Balloon Icon Balloon Icon Balloon Icon Balloon Icon
Icon
This property sets the icon to display in the syste1n tray.
Importai1t: This property niust be set; otherwise the tool tip balloon will not sho\;v !
The designer vvill allow you to bro,;vse and select an icon to display \hen the tooltip is shown.
~ I Choose icon~
Note: If a "phantom" icon re1nains in the system tray after closing the form, then it is recoilllnended set the Visible
property to False in order to clear the icon before closing form.
L Exit
ContextMenuStrip
This property sets the shortcut inenu to show when the user right-clicks the icon.
Set this property to an existing ContextMenuStrip to assign a menu to the syste1n tray icon.
Visible
This property indicates ,;vhether the icon is visible in the notification area of the taskbar.
BalloonTipClicked
This event occurs when the balloon tip is clicked. Use this event to react to user clicks in the ToolTip balloon.
1 $notifyicon 1_BalloonTipClicked={
2 Write-Host 'The Balloon Tip was Clicked'}
264 I PowerShell Studio - A Comprehensive Guide
Click Me ~ x
Please click on this balloon!
These events occur "vhen the syste1n tray icon is clicked. If you need more infor1nation such as "vhich inouse
button was used, then it is reconunended to use the MouseClick events (See belo"v).
MouseClick
This event occurs when a user clicks on the system tray icon.
[System.Windows.Forms.LabelEditEventBandler]
l $notifyicon l_MouseClick=[System.Windows.Forms.MouseEventHandler]{
2 #Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
3 Write-Host "System Tray Icon Mouse Click: $($_.Button) Clicks: $($_.Clicks)"
4 }
MouseDoubleClick
These events occur when a user double clicks on a system tray icon. This event has the same arguments as the
MouseClick event.
l $notifyicon l_MouseDoubleClick=[System.Windows.Forms.MouseEventHandler]{
2 #Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
3 Write-Host "System Tray Icon Mouse Double Click: $($_.Button) Clicks: $($_.Clicks)"
4 }
ShowBalloonTip
This 1nethod displays a balloon tip in the taskbar for the specified ti111e period.
PowerShell Studio - Form Controls I 265
The method uses the properties of the Notifylcon to display the balloon tip. Therefore, they must be set
before calling this method.
l $Notifylcon.ShowBalloonTip(O)
This variation, displays a balloon tip with the specified title, text, and icon in the taskbar for the
specified time period. You need not set the Notifylcon 's properties ifyou use this method variation.
Helper Function:
The following is a helper function that allows you to display the Notify Icon. The help function also assigns the
calling executable ' s icon) if the Notify Icon's Icon property hasn' t been assigned.
l function Show-Notifylcon
2 {
3 <#
4 .SYNOPSIS
5 Displays a Notifylcon's balloon tip message in the taskbar's notification area.
6
7 .DESCRIPTION
8 Displays a Notifylcon's a balloon tip message in the taskbar's notification area.
9
10 .PARAMETER Notifylcon
11 The Notifylcon control that will be displayed.
12
13 .PARAMETER BalloonTipText
14 Sets the text to display in the balloon tip.
15
16 .PARAMETER BalloonTipTitle
17 Sets the Title to display in the balloon tip.
1 .PARAMETER BalloonTiplcon
2 The icon to display in the ballon tip.
3
4 .PARAMETER Timeout
5 The time the ToolTip Balloon will remain visible in milliseconds.
6 Default: 0 - Uses windows default.
7 #>
8 param(
9 [Parameter(Mandatory =$true, Position = 0))
1O [ValidateNotNull()]
11 [System .Windows.Forms.Notifylcon]$Notifylcon,
12 [Parameter (Mandato ry =$true, Position= l )]
13 [ValidateNotNullOrEmpty()]
266 I PowerShell Studio - A Comprehensive Guide
14 [String]$BalloonTipText,
15 [Parameter(Position = 2)]
16 [String]$BalloonTipTitle = ",
17 [Parameter(Position = 3)]
18 [System.Windows.Forms.ToolTiplcon]$BalloonTiplcon ='None',
19 [Parameter(Position = 4)]
20 [int]$Timeout = O
21 )
22
23 if ($Notifylcon.lcon -eq $null)
24 {
25 #Set a Default Icon otherwise the balloon will not show
26 $Notifylcon .lcon =
[System. Drawing. Icon]:: ExtractAssociated Icon ([System. Windows. Forms.Application] :: ExecutableP
ath)
27 }
28
29 $Notifylcon.ShowBalloonTip($Timeout, $BalloonTipTitle, $BalloonTipText, $BalloonTiplcon)
30 }
Exainple Use:
There is a sa1nple form de1nonstrating the Notify Icon available in SAPIEN's Download section at
(https://\V\V\v.sapien.com/downloads#Sample%20Scripts/Prilna1Fonns%2020 l l/NotifylconSan1ple.zip)
Increment:
This detennines the amount to increment or decre1nent on each button click. I.E. if tl1e increment is set to (5) tl1en
each button click \ivould increase by 5, 10, 15, 20, 25, and so on.
Maximum:
This liinits the 1naxiJ.num value that the control can be increased.
Minimum:
This li1nits the 1nini1num value that the control can be decreased.
Thousands Separator:
If set to Tn1e, this \ivill auto1natically insert a "," separator for numerical values over 999. For example, 1000
would read 1,000.
To get the current selected value fro1n the Nu1nericUpDown control use:
$numericupdownl.value
.ValueCbanged
For the ValueChanged event to occur, the Value property can be changed in code, by clicking the up or do\ivn button,
or by the user entering a new value that is read by the control. The new value is read when the user hits the ENTER
key or navigates away fro1n the control. If tl1e user enters a new value and then clicks the up or down button, the
ValueChanged event will occur twice.
The OpenFileDialog control operates with the saine principles as the FolderBrowserDialog, except instead of select
a folder location it is used to select a specific file(s). If enabled, the OpenFileDialog can allow multiple files to be
selected.
aO Form In tllis exainple, we created a ne\v form with a textbox and a button,
looks fa1niliar doesn't it. We then added tl1e OpenFileDialog control
to the form by drag/drop tl1e control from the toolbox on top of the
fonn.
Now right-click on the button and add the " Click" event. This generate the event and a fevv lines of code:
1 $button l _Click={ }
But that does nothing on its own~ we need to insert so1ne code to inake everything work togetl1er:
1 $button 1_Click={
2 #This is looking for the OpenFileDialog window to close successfully, meaning a valid file was
selected and OPEN was clicked.
3 if ($openfiledialogl .ShowDialog() -eq 'OK')
4 {
5 #this populates th e text box with the selec ted file.
6 $textboxl .Text= $openfiledialogl .FileName
7 }
8 }
1 $button 1_Click={
2 if ($openfiledialog 1.ShowDialog() -eq 'OK')
3 {
4 $filenames= $openfiledialog 1.filenames
5 foreach ($file in $filenames) {
6 $textbox 1.AppendText("$file 'n")
7 }}}
The ForEach loop is used to collect each file name that ' vas selected, then each is appended to the RichTextBox,
use a ' n to insert a line retum
a'9 Form 0 x
C:\Users\Jeff\Docunerts\eel-box.pg
C:\Users\Jefl\Docunerts\Oieckist .pd
C:\Useis\Jeff\Docuneris\dc~.pcf
[]
.:i
It should look so1nething like the example above when you are done!
PowerShell Studio - Form Controls I 269
The Panel control is like the GroupBox control, in that it is used to provide grouping for other controls. The
difference being that a Panel control can have scroll bars, and GroupBox has a caption at the top. When you move
a Panel control around on a fo11n, all control within the Panel control vvill 1nove \ith it.
In this exa1nple, you can see the Panel Control (dark grey box), \ith three different controls contained within it. If
you don't need the caption at the top, as in a GroupBox, then the Panel is usually the best choice especially when
adding color to the panel.
Notice in the form in the next page, showing before and after BackColor,
the color on a GroupBox tends to bleed over the top of the GroupBox
which doesn' t inake a very professional looking design.
09 Form
My Tile
--- -- - - -- - ---- -- -- - -- -
.
Keep in mind that with the Panel Control or the GroupBox Control, if you disable the control by setting .enable =
$false, then all controls within the Panel or GroupBox will also be disabled. You can use this to yotrr advantage by
disabling or enabling an entire group of controls vvith one com1nand.
270 I PowerShe ll St udio - A Comprehe nsive Guide
Image and hnageLocation properties. the difference betvveen tJ1ese two properties determines how you p'lan to load
the in1age.
Image property i1nbeds the ilnage in the form so that it is self-reliant \hen displaying an image, no internet or file
share connection required. The image is converted to a Base64String \Vhich is then imbedded into the form. Which
looks sinlilar to the code belo,v:
lmagelocation property is used to load an image asynchronously from eiU1er a \Vebsite or disk location. I.his is used
mainly to either decrease the overall file size of the fonn or if you \vant the ability to edit an image at a later tilne
that w ill display next time the fom1 is Joaded.
lnitiallmage. tllis refers to the image that you \Vant to display \Vhile the main image is loading, used if you
are using lmageLocation and it might take a fe,v seconds for the main iJnage to do\vnload.
Errorlmage. is the image that you 'vant to display if an error occurs during the image-loading process, or if
tl1e i1nage load is cancelled. Works 'vith In1ageLocation property.
SizeModc, this propert)1 controls how the PictureBox \Vill handle the image placeme11t and sizing. Tl1ere are five
different settings.
1. Normal! The image is placed in the upper-left comer of the PictureBox. The image is clipped if it is larger
than the PictureBox it is contained in.
2. Stretchlmage: The image \Vithin the PictureBox is stretched or shn1nk to fit the size of the PictureBox.
3. AutoSize: The PiclmeBox is sized equal to Ule size of the linage that il contains.
~. Centerlmage: The image is displayed in the center if the PictureBox is larger than the i1nage. If the image
is larger than the PictureBox, U1e picture is placed in the center of the PictureBox and lhe outside edges are
clipped.
5. Zoom: The size of the image is increased or decreased maintaining the size ratio .
The PictureBox support file types *.gif, *.jpg, *.jpeg, *.bmp, *.w1nf, *.png, tl1ere is a .NE'T source available to
allo"v mai1y other file types, it is called 69DevIL.
70
High0nCoding has an excellent article on using this type of i1nage inse1tion from a database. The article
demonstrates how to fetch data from tl1e database using PowerShell, and how to display ilnages in the windows
form using data from the database.
ProgressBar
ProgressBarOverlay (o/o)
Maximum: The Maximu111 is the upper bound of the ra.nge this ProgressBar is working with.
69 http://openil.sourceforge.net/
70 http://highoncoding.com/ Articles/235_Accessing_Database_And_Displaying_lmages_Using_Windows_P
owerShell.aspx
71 https://www.sapien.com/blog/20 l l /07 /l 4/primalforms-20 l l -spotlight-on-the-progressbar-control/
272 I PowerShell St udio - A Comprehensive Guide
Minimum: The Minimu1n is the lower bound of the range this ProgressBar is working \Vith. When the Value
property is equal to the value of the Minimum property , the ProgressBar will be empty .
Values (Default 0)
Step : The Step is the ainount to increment the current value of the ProgressBar by when the PerfonnStepQ method
is called.
Value: The current value of the ProgressBar, in the range specified by the Minimu1n and Maximrun properties.
Values (Default: 0)
Increment: This inethod advances the current position of the ProgressBar by the specified a1nount.
1 $p rogressbarl .lncrement(l)
PerformStep: This 1nethod advances the current value of the ProgressBar by the amount of the Step property .
Here is a sample script block triggered by a button, that displays its progress as it creates a backup of all t11e text
files located in a folder specified by the user:
l
and reload the form. Now, tl1at said tllis beco1nes
some\.vhat unfeasible if you are trying to change many
different controls because you \.Vould need a
' - - - - - - - - - - - - - - - - - - - - - - = " Property Grid for each control you \.Vanted to edit.
You can use the ReadOnly attribute to keep specific control properties fron1 being editable. The Browseable attribute
detennines whether a control's property is show n in the grid or hidden.
274 I PowerShell Studio - A Comprehensive Guide
DescriptionAttribute. Sets the text for the property that is displayed in the description help pane belo\v
the properties. This is a useful "vay to provide help text for the active property (the property that l1as focus).
Apply this attribute to the MaxRepeatRate property.
CategoryAttribute. Sets the category that the property is u11der in the grid. Tltis is useful when you want
a property grouped by a category naine. If a property does 11ot have a category specified, then it will be
assigned to the Misc category. Apply this attribute to all properties.
BrowsableAttribute - Indicates whether the property is sho\vn in the grid. This is useful \>vhen you \Vant
to hide a property from the grid. By default, a public property is always shown in the grid. Apply this
attribute to the SettingsChanged property.
ReadOnlyAttribute - Indicates \hether the property is read-only. This is useful vvl1en you wai1t to keep
a property from being editable in the grid. By default, a public property vvith get and set accessor functions
is editable in the grid. Apply tltis attiibute to the App Version property.
DefaultValueAttribute - Identifies the property's default value. This is useful when you want to provide
a default value for a property and later detennine if the property's value is different than the default. Apply
this attribute to all properties.
DefaultPropertyAttribute - Identifies the default property for tl1e class. The default property for a class
gets the focus first "vhen the class is selected in the grid. Apply this att1ibute to the AppSettings class.
No':v I know \>vhat you are thinking, why not just add a second Property Grid(2) control with its " SelectionObject"
set to the first PropertyGrid(l) control so that you could change the "Selection.Obj ect" of the PropertyGrid(l) tl1en
you could easily switch to other controls? Wouldn't that be nice! Unfo1tunately, it doesn' t work that \!Vay , in fact
you can control every other property except the "SelectionObject" property. As you can see i11 the exa1nple belo,v,
the only selection available in the " SelectionObject" is (none).
ii9 Form 0 x
PropertyGrid(l) PropertyGrid(2)
J
"
1~---0-~
Selec~
Sets the currently selected object that the grid v.i ll brO'...'Se.
PowerShell Studio - Form Controls I 275
Q OptionC Q OptionC
.::
Example #2 ? Rad108utton 0 x
There is one Panel control on the left with three radiobuttons, one
GroupBox control on the right with three radiobuttons, and three
@OptimA Q OptionA
additional radiobuttons on the fon11 itself.
Q OptionB @OptionB
The radiobuttons in the Panel control, in the GroupBox control, and Q OptionC Q OptionC
on the Form, all work independently of each other. This allows you
to group RadioButtons together in three different ways. Q OptionA
Q OplionB
In this scenario, the user can make one selection from three different @OplionC
Checl{ed: This indicates whether the RadioButton is checked or not. Use the Checked property to determine the
state of a specific radio button or -vvhen you want to check or uncheck a radio button. When you set this property to
True, the previously checked radio button in the group \Vill be unchecked.
$radiobuttonl.checked =$true
CheckChanged: Occurs whenever the Checked property changes value. Use the CheckChanged property \iv hen you
wish to respond to the user checking a radio button. Tllis event also fires when the previously checked radio button
is unchecked due to the user checking a different radio button.
72
https://www.sapien.com/blog/20 l l /07 /08/primalforms-20 l l -spotlight-on-the-radiobutton-control/
276 I PowerShell Studio - A Comprehensive Guide
'J Rad10Button 0 x 111 this exainple, we demonstrate how to use the checked property of a
RadioButton by checking the state of each RadioButton when the mouse moves
over the Panel control, if option Panel A, B, or C is selected \e set the text for
the Label control below.
0 Panel A
l $panell _MouseMove=[System.Windows.Forms.MouseEventHandler]{
0 Panel B 2 If ($radiobuttonPanelA.Checked -eq $true)
3 { $1abell .Text= "Panel A is selected"}
@PaneJC 4 elseif ($radiobuttonPanelB.Checked -eq $true)
5 { $1abell .Text= "Panel Bis selected"}
6 elseif ($radiobuttonPanelC.Checked -eq $true)
Panel C is selected 7 {$label l .Text = "Panel C is selected"}
8}
Ahnost everyone will tell you that formatting for RichTex.1box is at best very drrficult, \vhich is why most of the
industry tends to output to either Out-GridView or if more flexibility is needed then html reports are usually used
instead. There is a Web Vie"v control, however unfortunately it is one of the fe"v controls that are not offered in the
default toolbox.
The nicest thing about a RichTextbox is that a nicely fonnatted RTF docun1ent can be loaded into the RichTex.1Box
\lvitl1ol1t losing any of the formatting.
l $richtextbox l .LoadFile('c:\Users\Jeff\Desktop\ARMS\EULA.rtf')
19 MyFc>1m X
Under the terms e>f this Software End User License Agreement (lierelnafter
referred t<> as "the Agreement") executed by and between Jeffery Holder
(hereinafter referred to as '"Jeffery Holder" or "the Pre>vlder") and you, a
physical perron or legal entity (hereinafter referred t<> as "You" or "the End
User"), You are entitled to use the Software defined In Artlcle 1 of this
Agreement. The S<>ftware defined in Artlde 1 of this Agreement can be stored
on a data carrier, sent via electronic mail, downle>aded from the Internet.
downloaded from the Provider's servers or obtained from o ther sources,
subj ect to the terms and conditions specified below.
Auto Scrolling
If you have a RichTextBox and you ,;vould like for it to auto1natically scroll to the last entry as text is displayed, this
example will do it for you:
Many times, the SaveFileDialog control is misunderstood, it only saves a file, it does not create the file to be saved.
You must first output the file to be saved.
For example, let's say you have a report contained in the variable $report and you want to save that to a file, you
\.Vould use the SaveFileDialog FileOK event:
To show the dialog box so that the user can select the directory and filename of the file to be saved you would use:
1 $savefiledialog 1.ShowDialog ()
a MyForm
.,___~~~~~~~~~~~~~~~~~~ !
x In this basic example, we added a TeA1box, a Button, and
the SaveFileDialog control to an empty form. Our goal is
In this bask: example we have a text box where a report is displayed. and a
Save ~on located below that will open the SaveAle dialog so the user can
we vvant to be able to save the teA1 that is displayed in the
selec:t the location and name ol the file to be saved I box to a file .
1 $buttonSave_C lick={
2 $report= $textboxl .Text# Put the text into a variable, but we could just use the
$textboxl .text and no variable in this case.
3 $savefiledialog 1.ShowDialog () # Open the Dialog Box
4 }
5
6 $savefiledialog 1_F ileOk=[System.ComponentModel.CancelEventHandler]{
7 $report I Out-File $savefiledialog l .FileName
8 }
The SplitContainer creates two pai1els on a fonn which cai1 be presented as either horizontal or vertical. I've seen
in many discussions that the SplitContainer only supports two panels, however you can add more two panels by
sin1ply dragging more SplitContai11er controls to the fonn.
!I I: i
JL_______________ l
PowerShell Studio - Form Controls I 279
I
i
f
f
;
panels.
:-------------------------------------------1 ii !
'
:'
:
:' I
:
!
t
:
:
: I'
I
i
t
I It f
i !l j
'' 'I
I
;
t I i
t
,'' "
I
,,
" pane12
'1
i
!i
I 1 I
: t
!
:
Panel2 H
: I !j
'
:
'1
: ;
J
: I t
' ,
I
I
"
I
:
I
'
I
f
!
:
~i
: 1'
!
If
:
:
:I
I
I
:
: I
~J I i
f
:, ;'I: j
': II J I
' I I
i
I
:
I
:I , I I
LJ!.
r-------------------1 ,-----------------------------1
Form
.---------
______r----------
-:_ _~-~I;,l II
1! 11 I
!I I I
I ! l i
' ii I
Pllnet1
!11 Panell
II
1
- II
Il
1 Ii
i
II
1 I :
i I
J
1 1 1
l____J[_________ll_____ _______________
Example A ExampleB
280 I PowerShell Studio - A Comprehensive Guide
In example A, we drag a new SplitContainer onto Panel2 on the left, this results iI1 Panel2 being split into two
panels, exainple B .
- -
.....
Windows For1ns Splitter controls are used to resize docked controls at nm ti1ne. The St>litter control is often used
on fonns vvith controls that have varying lengths of data to present, like Windows Explorer, whose data panes
contain information of varying widths at different ti1nes.
When the user points the mouse pointer at the m1docked edge of a control that can be resized by a splitter control,
the pointer changes its appearance to indicate that the control can be resized. The splitter control allows the user to
resize the docked control that is i1nmediately before it. Therefore, to enable the user to resize a docked control at
run ti1ne, dock the control to be resized to an edge of a contaiI1er, and then dock a splitter control to the sa1ne side
of that container.
rlJ ~t F 1m
Now vvhen we run the fonn you vvill notice that if you 1nove your x
1nouse over the splitter bar, you can hold and drag to resize the
TeA1.Box.
This will 'ork vvith any control that you want to give users the
ability to resize the undocked side of a control.
To ensure that the Splitter control does not resize controls docked
to a size that is too small to be useful to the user, you use the
MinEA1ra and MinSize properties. The MinExtra and MinS.ize
properties determine the minimum size that controls docked to
the left ru1d rigl1t (or top and botto111 if a horizo11tal SJJlitter
control) can be sized to. If the otl1er controls on yotrr fonn tl1at the
Splitter control is docked to display a specific style of border, you can use the BorderStyle property to n1atch the
border sty le of the controls that are docked to it.
You inight find it desirable to set a max:immn size limit on controls that the S1>1itter control is docked to. The
SplitterMoved and SplitterM.oving events enable you to detennine vvhen the user is resizing a docked control. You
can use the SplitPosition property in an event handler for the S11litterMoved or S11litterMovin.g events to detennine
the size of the control that the Splitter control is docked to and set the SplitPosition property to a different value to
linrit the docked control's vvidtb to a specified maximum vvidtl1 (or height if a horizontally aligned Splitter control).
0- 73
Use the StatusBar control, to display status iufonnation to the user. The StatusBar can also be used for
- user interaction but typically plays an inforn1at:ive roll.
There are two options when using the Statusbar, you can ejtJ1er sho'v only the StatusBar text or you coo show
StatusBar panels tl1at you have added. This is controlled by the "ShowPanels" property.
ShowPanels set to True - displays the panels that you have set.
ShowPanels set to False - displays only the StatusBar teA1.
-
This is the Statusbar Text ertered into the text property .::
Panels (Collection)
74
Use the Stat11sStrip control, to display status infonnation to the user. The StatusStrip serves as a
0-... replace1nent to the StatusBar and offers more support for user interaction than tl1e StatusBar by allowing
you to add buttons, progress bars, and other controls. It's like StatusBar on Steriods!
j I ......
A Statuslabel
(ffiJ ProgressBar
~
- OropOownButton
03 Split Button
AllowltemReorder -This property allows the items in the StatusStrip to be reordered when the ALT key is
pressed.
SizingGrip - This property indicates whether a sizing handle (grip) is displayed in the lower-right corner of the
control. This property is mainly cos1netic and should be set to False \<vl1en using fixed sized forms, such as \vhen
the fonn's FonnBorderStyle property is set to FixedDialog.
Sho,vltemToolTips -This property indicates whether ToolTips are shown for the StatusStrip. Set this property to
True \<vhen you want to provide help information for items in the StatusStrip.
Layout Style - Tllis property indicates hovv the StatusStrip lays out the items collection.
StackWithOverflow
Specifies that items are laid out automatically.
H orizontalStackWithOverflow
Specifies that items are laid out horizontally and overflow as necessary.
VerticalStackrVithOverflow
Specifies that items are laid out vertically, are centered within the control, and overflo\v as necessary.
rtOl1l
Specifies that items flo"v horizontally or vertically as necessary.
Table
Specifies that items are laid out flush left.
Ijyou want to ensure all the items on the status bar are visible even when the form is resized then you
can use the Flow layout style.
Docl< - This property indicates \vhich StatusStrip borders are docked to its parent control and detennines ho"v a
StatusStrip is resized vvith its parent.
None
The control is not docked. The StatusStrip becomes a free floating control that cannot be moved by the
user.
Top
The control's top edge is docked to the top of its contailling control.
Bottom
The control's bottom edge is docked to the bottom of its containmg control.
Left
The control's left edge is docked to the left edge of its containing control.
Right
The control's right edge is docked to the right edge of its containing control.
Fill
All the control's edges are docked to the all edges of its containing control and sized appropriately.
284 I PowerShell Studio - A Comprehensive Guide
Item Clicked
This event occurs when a ToolStripitem is clicked. This event allows you to handle all the click events in one
location, but it is not recormnend using this event if you are have DropDownButtons or SplitButtons. Instead you
should use each ToolStripltem's individual event handlers.
0-... 75
Use the TabControl \.vhen you wish to present a series of related controls that are separated into
- individual pages which can be selected by a tab.
Tit Netwock Tools. ~ Syst.., ~once ~ u.t/\khlol Softwore ~ Oelde &!IOl!ll1se Cdlcol..
SCCM Cierl Tools .c', WSUS ~
ReS!we Tools
'f&< Advanced l'w'9 [i;i) OS Re;ioll \. I lk>quoted Paths ii Java Tools g Pdobo Tools .Audm9 Toob "*Moe Tools (!J ~Desk Tooh !
F'4e5hote Poo/yz0<
Use< Tools 0 McNee
OK Caned
""""u'
SelectedlndexChanged
This event occurs when tl1e value of the Selectedlndex property changes.
Use this event if you wish to respond when the current tab is changed. For exa1nple, you could use this event to
trigger data validation or enable or disable certain controls that depend upon the current tab.
@- Pressing Ctr/ + Tab will select the next TabPage in the TabControl.
The TableLayoutPanel is like other tables that you have used, it is basically just a table "vith colmnns and rows.
Once you practice using the TableLayoutPanel you can use it to quickly create dialog forms that are easily
resizable.
I ;~----~----------~-------------~-------------------------~-------------------~
!
I
I
I. .
:
:
:
r----------~J . . . . . . . . . . . . . . . . . . . . . ,
.:
i
.:
:
I :I OK Cancel I t
I.I
--------------------------------------------------------------
~ . .
.~-~;----------------------------------------------------------~-------
.~---------------..--- . -----------..-------..-------------------------------l..----.--------l
i...............-------....------.........................................................................-----........--.... ........_ ----..................--.................-......................................
_,, ........
OK
'
.,.i ............................
Cancel !
..
76
To re-create this example, perfor1n the following steps:
2. Set the padding on the fonn to 12,12,12,12. You may "vant to change the ainount later, but use tllis for
now.
3. Add a TableLayoutPanel to the fonn. Set Dock to Fill. It starts with two columns and two ro\vs. No\.v,
it's decision tin1e. Shottld the labels be on the left or on tl1e top (assuming the language is English)?
Should the buttons be at the bottom or on the right? For no\.V, I wa11t the labels above the controls and the
buttons on the bottotn.
4. Keep the coln1nns at two and add 4 more rows. How should you add ro\.vs? In the Designer, there are
two main \.Vays: Add Row 1nenu item or the Edit Columns ai1d Rows 111enu iten1 on the Tasks menu of the
TLP. For now, simply select the Add Ro"v inenu four times. Four rows are added to the TLP with
Absolute RowStyles (\.ve will fix this later, making any of the ro,vs autosize with nothing in them will
cause them to disappear from the designer).
5. In ro, 0, column 0 put a label. Set the teA1: to "Naine :". Set t11e Anchor to Left and Right. Set the
Margin to 0,0,0,0.
6. In ro, 1, colrunn 0 put a TextBox. Set the name to "tbNaine". Set the Anchor to Left ai1d Right. Set the
Margit1 to 0,5,0,0.
7. In row 2, column 0 put a label. Set the teA1 to 'Description:". Set t11e Anchor to Left ai1d Right. Set the
Margin to 0 6,0,0.
8. In ro\.v 3, colu1nn 0 put a TextBox. Set the name to "tbDescription '. Set the Anchor to Left, Top, Right
and Botto1n. Set the Margin to 0,5,0,0. Set MultiLine to Tn1e.
10. In rovv 5, column 0 put a button. Set the text to "OK". Set t11e name to "buttonOK". Set the Anchor to
Bottom ai1d Right. Set the Margin to 0,0,0.0. Set the DialogResult to OK.
11. In row 5, colunm 1 put a button. Set the text to :'Cancel". Set the name to "buttonCancel". Set t11e Anchor
to Botto1n ai1d Right. Set the Margin to 6,0,0,0. Set tl1e DialogResult to Cancel.
12. No'v that we have our controls in place, we can set the correct RowStyles ai1d ColumnStyles. Select tlle
TLP a11d choose Edit Colunms and Rovvs fro1n t11e Tasks menu.
13. It shows the columns by default. The second colt1nm is just there for t11e Cancel button. We need to make
it as s1nall as possible and chai1ge the other controls to span across it. Set tl1e style for the second column
to Auto Size. This \Vill cause the column to shrink to tJ1e width of the Ca11cel button (the only control in
that col1unn). Leave column one alone.
14. In the drop down, select Ro,;vs. We want t11e ro'v that contains the .Description text box to eA'})and witi1
the dialog. Set the style for the forth ro\v (row 3 me11tioned above) to Percent. We want the rO\.V that is
empty to be exactly 10 pixels tall. Set t11e fift11 row to Absolute (it should already be that), and set the
amout to 10. All other rows should autosize to their contents. Set the frrst, second, tllird and sixth ro,vs to
Auto Size.
15. Once you click OK, your form should be close to what you want.
288 I PowerShell Studio - A Comprehensive Guide
16. For the labels and textboxes, set the Colu1nnSpru1 to 2. This will cause the1n to stretch the entire width of
the TLP.
17. Finally, let' s finish off the look of the form. Select the form. Set Text to "Edit Item". Set AcceptButton to
buttonOK. Set CancelButton to buttonCancel. Set Showlcon to false. Set MinimizeBox to false. Set
Maxi1nizeBox to false.
11 ,.;.;rll;...."'."f""
;....- " - - - - - - - - -13- If you need a simple text box without a lot of fonnatting needed, then the
I TextBox is the best fit. Ho\ivever, I generally use a RichTextbox \ith all my
applications in case later I decide to add in any additional formatting I don't
need to change controls. I see no benefit using a Textbox when you can use a
RichTextbox instead.
~ r ...eo. &, sett"9 tho r...eo._ "11U1Lne" to
TM. Ille T""'Scot wl alow more tho<> one lne """"tho box.
By setting the TextBox property "MultiLine" to TRUE, the text box will support
more than one line.
Copy to Clipboard - To copy the contents of a textbox to the Windows Clipboard use:
77 https://www.sapien.com/blog/201l/06/l3/primalforms-20 l l -spotlight-on-the-textbox-control/
PowerShell Studio - Form Controls I 289
l $filename= [System.10.Path]::GetTempFileName()
2 $textboxl .SaveFile($filename)
3 Start-Process wordpad $filename -ErrorAction 'Stop'
NOTE: You could change to Start-Process winword $filename -ErrorAction 'Stop' to open in Microsoft Word.
Ticl<
This event occurs when the specified tinier interval .has elapsed ai1d the ti1ner is enabled.
Ifanother event such as a button click is processing a slo111 script, the Tinier 's Tick event vvill not fire until
after that event has completed processing.
Wanting: If the a1nount of tune to process a Tick event takes longer then the Interval tiine, it can lead to an overlap
issue. Please be sure to leave an adequate ainount of time for each Tick event to process. An alternate solution to
this potential issue is to stop the ti1ner "v hile processing the Tick Event:
l $timerl_Tick={
2 #Temporarily stop the timer
3 $timerl .Stop()
4
5 #Process the Tick Event Here ...
6
7 #Resume the timer
8 $timerl .Start()
9 }
Warning: Ti1ners can cause out of me1nory errors in long running scripts. Using the timer' s StOfl method can help
free allocated me1nory and thus prevent memory errors.
In the following exa1nple, vve create a 60 second count down ti1ner that utilizes the timer 's Tick event to update the
display (label) with the re1naining time.
Button= $button!
01/10/201716:24:09 Timer = $timer I
1 $formMyForm_Load={
2
3 $button l .Text= [DateTime]::Now
4 $timer.Start()
5 }
6 $timerl_Tick={
7 $button l .Text= [DateTime]::Now
8 }
Label = $labell
Start Button = $buttonSTART
Stop Button = $buttonSTOP
START STOP
Click the " Start" and " Stop" buttons to start and stop the ti1ner.
1 $fo rmMyForm_Load={
2
3 $1abell .Text= [DateTime]::N ow
4 $timerl .Start()
292 I PowerShell Studio - A Comprehensive Guide
5 $run = 1
6
7 }
8 $timerl _Tick = { $1abell .Text= [DateTime]::Now}
9 $buttonStart_Click={ $timerl .Start() }
10 $buttonSTOP_Click={ $timerl .Stop()}
,/J MyForm x There three different display option for each toolbar menu
item:
1. Text only
2. Text and linage
3. Image only
Button, SplitButton and DropDownButton can be displayed in varying \ays as either text only, image and text, or
image only.
lmageScaling ze o
ImageTransparentColor Mags Ila
RghtToleft No
Right TolefthltoMim>rln False
Text Bdton
[ OK ] [ Cancel ]
-Pf! My Form x
0
Button label 0
SplitButton 0
DropOown ComboBox Text Box
294 I PowerShell St udio - A Comprehensive Guide
NOTE: There is a known bug \vith ToolStrip in Windows Forms. The issue is that when using the renderer,
you will see a "vhite border around the ToolStrip. Microsoft has stated that it will not be fixing this bug.
of] My Form x
File View Tools Help
l I~ Q
You are probably 1nost used to seeing the ToolStrip control used like the example above in most applications.
0-.. 8
Represents a s111all rectangular pop-up window that typically displays help for the feature. The tooltip
appears when the mouse hovers over the control.
~
-
How to Create a ToolTip for a control: a!? MyForm ~r
~
a.
1. Add your control that you want to add a ~
~on
ToolTip for, in this exainple we picked a
silnple Button control.
2. Drag/Drop the Tooltip control onto the form,
the Tooltip control \Vill not appear on the form,
it will appear at the botto1n of the Designer
Panel.
3. After you add the ToolTip control to a form it
will add a new dynanlic property to all other
controls on the forn1 as "vell as future controls l
'i. 1oo1bp1 -
that you 111ay add.
4. Select the control to add a Tooltip to, go to the property "ToolTip" for the control, in our
example the property for the button control.
5. Enter the infonnation you want displayed in the Tooltip when the user hovers the mouse over
the control. It is best to keep the text as short as possible, if you need to enter 1nultiple lines use
the ' n to start a new line.
6. Select the ToolTip control and make sure that the "Active" property is set to TRUE.
7. That' s all there is to it!
81 https://adminscache.wordpress.com/2013/05/0 l /winforms-trackbar-gui-using-console-beep/
296 I PowerShell Studio - A Comprehensive Guide
1 #--
2 #region Application Functions
3 #----------------------
4
5 #endregion Application Functions
6
7 #--
8 # Generated Form Function
9 #--
10 function Show-test_psf {
11
12 #---------------------------
13 #region Import the Assemblies
14 #--
15 [void] [reflection.assembly]::Load ('System.Windows.Forms, Version=2.0.0.0,
Culture=neutra l, PublicKeyToken=b77a5c561934e089')
16 [void] [reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c56 l 934e089')
17 [void] [reflection.assembly]::Load ('System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7fl 1d50a3a')
18 [void] [reflection.assembly]::Load ('System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f l l d50a3a')
19 #endregion Import Assemblies
20
21 #------------------
22 #region Generated Form Objects
23 #--
24 [System.Windows.Forms.Application] ::EnableVisualStyles()
25 $formMyForm = New-Object 'System.Windows.Forms.Form'
26 $DurationLabel = New-Object 'Sys tem.Windows.Forms.Label'
27 $FrequencyLabel = New-Object 'System.Windows.Forms.Label'
28 $ExitButton = New-Object 'System.Windows.Forms.Button'
29 $PlayButton = New-Object 'System.Windows.Forms.Button'
30 $DurationTrackBar =N ew-Object 'System.Windows.Forms.TrackBar'
31 $FrequencyTrackBar = New-Object 'System.Windows.Forms.TrackBar'
32 $1nitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
33 #endregion Generated Form Objects
34
35 #--------------------
36 # User Generated Script
37 #--
38
39 $formMyForm_Load = {
40 # Frequency TrackBar
41 $FrequencyTrackBar.Location = " 70,20"
PowerShell Studio - Form Controls I 297
42 $FrequencyTrackBar.Orientation = "Horizontal"
43 $FrequencyTrackBar.Width = 350
44 $FrequencyTrackBar.Height = 40
45 $FrequencyTrackBar.TickFrequency = 1000
46 $FrequencyTrackBar.TickStyle = "Top Left"
47 $FrequencyTrackBar.SetRange (37, 327 67)
48 $FreqTrackBarValue = 2000
49 $FrequencyTrackBar.Value = 2000
50 $Frequencylabel.Location = "200,75"
51 $Frequencylabel.Size = "120,30"
52 $Frequencylabel.Text = " Frequency ($FreqTrackBarValue) "
53 # Play Button
54 $PlayButton.Location = "120,220"
55 $PlayButton.Size = "75,23"
56 $PlayButton.Text= "Play"
57
58 $global:DurationValue = 300
59 $global:FrequencyValue = 2000
60
61 $DurationTrackBar.Location = "70, 150"
62 $FrequencyTrackBar.Orientation = "Horizontal"
63 $DurationTrackBar.Width = 350
64 $DurationTrackBar.Height = 40
65 $DurationTrackBar.TickFrequency = 200
66 $DurationTrackBar.TickStyle = "BottomRight"
67 $DurationTrackBar.SetRange(l, 2000)
68 $DurationTrackBarValue = 300
69 $DurationTrackBar.Value = 300
70
71
72
73 }
74 #Play the Tone
75 Function Playlt
76 {
77 [System.Console]::Beep($global:FrequencyValue, $global:DurationValue)
78 }
79
80 $FrequencyTrackBar_ValueChanged={
81 $FreqTrackBarValue = $FrequencyTrackBar.Value
82 $Frequencylabel.Text = "Frequency ($FreqTrackBarValue) "
83 $global:FrequencyValue = $FreqTrackBarValue
84
85 }
86
87 $PlayButton_Click={
298 I PowerShell Studio - A Comprehensive Guide
88 Playlt
89
90 }
91
92 $DurationTrackBar_ValueChanged={
93 $DurationTrackBarValue = $DurationTrackBar.Value
94 $Durationlabel.Text ="Duration ($DurationTrackBarValue)"
95 $global:DurationValue = $DurationTrackBarValue
96
97 }
98
99 $ExitButton_Click={
l 00 $formMyForm.Close()
l0 l
102 }
103
l 04 # -End User Generated Script--
105 #---------------------------
106 #region Generated Events
107 #---
108
l 09 $Form_StateCorrection_Load=
l l0 {
lll #Correct the initial state of the form to prevent the .Net maximized form issue
112 $formMyForm.WindowState = $1nitialFormWindowState
113 }
114
115 $Form_Cleanup_FormClosed=
116 {
117 #Remove all event handlers from the controls
118 try
11 9 {
120 $ExitButton.remove_Click($ExitButton_Click)
12 l $PlayButton .remove_Click($ PlayButton_Click)
122
$DurationTrackBar.remove_ValueChanged($DurationTrackBar_ ValueChanged)
123
$FrequencyTrackBar.remove_ValueChanged($FrequencyTrackBar_ValueChanged)
124 $formMyForm.remove_Load($formMyForm_Load)
125 $formMyForm.remove_Load ($Form_StateCorrection_Load)
126 $formMyForm.remove_FormClosed ($Form_C leanup_FormClosed)
127 }
128 catch {Out-Null<# Prevent PSScriptAnalyzer warning #>}
129 }
130 #endregion Generated Events
13 l
PowerShell Studio - Form Controls I 299
132 #----------------------
133 #region Generated Form Code
134 #---------------------------
135 $formMyForm.SuspendLayout()
136 $FrequencyTrackBar.Beginlnit()
137 $DurationTrackBar.Begin lnit()
138 #
139 # formMyForm
140 #
141 $formMyForm.Controls.Add ($Duration Label)
142 $formMyForm.Controls.Add($FrequencyLabel)
143 $formMyForm.Controls.Add($ExitButton)
144 $formMyForm.Controls.Add($PlayButton)
145 $formMyForm.Controls.Add($DurationTrackBar)
146 $formMyForm.Controls.Add($FrequencyTrackBar)
147 $formMyForm.AutoScaleDimensions = '6, 13'
148 $formMyForm.AutoScaleMode ='Font'
149 $formMyForm.AutoValidate = 'EnablePreventFocusChange'
150 $formMyForm.BackColor = 'WhiteSmoke'
151 $formMyForm.Backgroundlmagelayout ='None'
152 $formMyForm.ClientSize = '490, 267'
153 $formMyForm.FormBorderStyle = 'Fixed3D'
154 $formMyForm.lsMdiContainer =$True
155 $formMyForm.Location = '200, 200'
156 $System_Windows_Forms_MenuStrip_ 1 = New-Object 'System.Windows.Forms.MenuStrip'
157 $System_Windows_Forms_MenuStrip_ l .Location= 'O, O'
158 $System_ Windows_Forms_MenuStrip_ 1. Name = "
159 $System_Windows_Forms_MenuStrip_ 1.Size = '672, 24'
160 $System_Windows_Forms_MenuStrip_ 1.Tablndex = 2
161 $System_Windows_Forms_MenuStrip_l .Visible= $False
162 $formMyForm.MainMenuStrip = $System_Windows_Forms_MenuStrip_l
163 $formMyForm.MaximizeBox = $False
164 $formMyForm.MaximumSize = '3100, 5000'
165 $formMyForm.MinimizeBox =$False
166 $formMyForm.Name = 'formMyForm'
167 $formMyForm.SizeGripStyle = 'Show'
168 $formMyForm.StartPosition = 'CenterScreen'
169 $formMyForm.Text ='My Form'
170 $formMyForm.add_Load ($formMyForm_Load)
171 #
172 # Durationlabel
173 #
174 $Durationlabel.AutoSize =$True
175 $Durationlabel.Location = '293, 113'
17 6 $Duration Label.Name=' Duration Label'
177 $Durationlabel.Size = '35, 13'
300 I PowerShell Studio - A Comprehensive Guide
178 $Durationlabel.Tablndex = 6
179 $Durationlabel.Text = 'labell'
180 #
181 # Frequencylabel
182 #
183 $Frequencylabel.AutoSize =$True
184 $Frequencylabel.Location = '62, 11 3'
185 $Frequencylabel.Name = 'Frequencylabel'
186 $Frequencylabel.Size = '35, 13'
187 $Frequencylabel.Tablndex = 5
188 $Frequencylabel.Text = 'labell'
189 #
190 # ExitButton
191 #
192 $ExitButton.Location = '293, 220'
193 $ExitButton.Name = 'ExitButton'
194 $ExitButton.Size = '75, 23'
195 $ExitButton.Tablndex = 4
196 $ExitButton.Text = 'Exit'
197 $ExitButton .UseVisualStyleBackColor =$True
198 $ExitButton.add_Click($ExitButton_Clic k)
199 #
200 # PlayButton
201 #
202 $PlayButton.Location = '95, 220'
203 $PlayButton.Name = 'PlayButton'
204 $PlayButton.Size = '75, 23'
205 $PlayButton.Tablndex = 3
206 $PlayButton.Text ='Play'
207 $PlayButton.UseVisualStyleBackColor =$True
208 $PlayButton.add_Click($PlayButton_Click)
209 #
210 # DurationTrackBar
211 #
212 $DurationTrackBar.LargeChange = 20
213 $DurationTrackBar.Location = '62, 148'
214 $DurationTrackBar.Maximum = 100
215 $DurationTrackBar.Name = 'DurationTra ckBar'
216 $DurationTrackBar.Size = '350, 45'
217 $DurationTrackBar.SmallChange = 5
218 $DurationTrackBar.Tablndex = 2
219 $DurationTrackBar.TickFrequency = 5
220 $DurationTrackBar.add_ValueChanged ($DurationTrackBar_ ValueChanged)
221 #
222 # FrequencyTrackBar
223 #
PowerShell Studio - Form Controls I 301
224 $FrequencyTrackBar.LargeChange = 20
225 $FrequencyTrackBar.Location = '62, 28'
226 $FrequencyTrackBar.Maximum 100 =
227 =
$FrequencyTrackBar.Name 'FrequencyTrackBar'
228 =
$FrequencyTrackBar.Size '350, 45'
229 $FrequencyTrackBar.SmallChange = 5
230 $FrequencyTrackBar.Tablndex 1 =
231 $FrequencyTrackBar.TickFrequency = 5
232 $FrequencyTrackBar.add_ValueChanged ($FrequencyTrackBar_ValueChanged)
233 $DurationTrackBar.Endlnit()
234 $FrequencyTrackBar.Endlnit()
235 $formMyForm.Resumelayout()
236 #endregion Generated Form Code
237
238 #-------
239
240 #Save the initial state of the form
241 $1nitialFormWindowState = $formMyForm.WindowState
242 # lnit the On Load event to correct the initial state of the form
243 $formMyForm.add_Load ($ Form_StateCorrection_Load)
244 #Clean up the control events
245 $formM yForm.add_FormClosed ($Form_Clean up_FormClosed)
246 #Show the Form
247 return $formMyForm.ShowDialog()
248
249 } #End Function
250
251 #Call the form
252 Show-test_psf I Out-Null
Q 82
Displays a hierarchical collection of labeled ite1ns, each of \.Vhich is represented by a TreeNode. When
-- it co1nes to displaying hierarchical information such as a folder stn1cture, the Tree View control is a perfect
choice. 111 addition, the Tree View allows users to rename tree nodes which can be useful in many instances.
The TreeView also seives as a good navigation tool.
t;JDRoot eORoot
j ~- 0Node1 l 1 0Node1
j 'DNode 2
BDRoot 2 -----
.....
El0 Root 2
~..0Node4 ; .. 0Node4
LO Node 4 ;. DNode 4
TRUE FALSE
8
:
Root
-""'!"
ImageList property - this ssets the ImageList objects that are used by the tree nodes. You will
l ~.... Node1 also need to add the I1nageList control to your fonn, and populate \vith the image you \:Vould like
' ' Node2
~.. ~ Root 2 for the nodes to use.
1.... Node4
LabelEdit property - this determi11es if a user wilJ be allowed to rename a tree node, if you are
i.... Node 4
using this as a file treeview you could use this to allo\v users to rena1ne a file.
8 Root Sho\vLines property - by setting this to FALSE there will be no lines displayed between tree
Node1 nodes.
Node2
8
- Root 2
Node4
ShowPlusMinus property - this indicates whether the plus-sign (+) and
- Root
Node4
minus-sign (-) \Vill be displayed next to the tree nodes. Nodel
Node 2
Root 2
Node4
Node4
1. Minimum - The value of the control when the scroll thu1nb is at the left end of the HScrollBar or top of
the VScrollBar.
2. Maximum - This is the largest possible value of the scroll bar. Note that the Value property of the scroll
bar when the thumb is pulled all tl1e way to the right for the HScrollBar or the bottom of the VScrollBar
is not equal to the Maximum property. The Value property \vill be equal to this fonnula: Maximum -
LargeChange + 1.
3. Small Change - Here's the increment value used when the user clicks one of the arro"v buttons.
PowerShell Studio - Form Controls I 303
4. LargeChange - This is the incre1nent value used when the user clicks the scroll bar control on either
side of the scroll tl1umb.
5. Value - The current value of the scroll bar. This value represents the position of the top of the
HScrollBar's scroll thu1nb and the left side of the VScrollBar's scroll thumb.
blmonl
Web Page.
.. . ,..,.. . - -- . '
L
9.0. 1 Example
NOTE: when you first add the WebBrowser control to your fon11, the default property for "Dock" is FILL. This
will fill the entire form with the WebBrowser control. To resize t11e control, change the "Dock" property to NONE.
..
-
In this exa1nple, we have added the WebBrowser control \Vhich is
on the right, and three button 011 the left which \Ve are going to use
-
to display different webpages in the WebBrowser control.
3 $buttonReddit_C lick={
4 $webbrowserl .Uri= "http://www.reddit.com"}
5 $buttonlinkedln_Click={
6 $webbrowserl .Uri= http://www.linkedin.com}
EXAMPLE PROJECTS
In this section, we will \Valk you through several working examples of projects created using Powershell Studio.
This will help to reinforce what you have already lean1ed in previous chapters and 11ow to apply that to working
forms.
IP RANGE SCANNER
Tllis tool \vill scan a user defi11ed range of IP Addresses to identify active/non-active IPs, as well as attempt to
provide device information and open ports. This is a great tool for keeping an eye on "vhat is on your nehvork.
First, we create an einpty form, and give it a na1ne of IP Sca1mer, then a size of 1349 vvidth and 750 height. I also
typically set the form backcolor to "white" also.
R>;h<Tol<~ No
T<UIU lht
.., Behavior
~Qp ll*aisc
AutoVakie~ !Nbic9reW!'I~
,,,,,.,-.,s, ~)
Ooublc9.Jffwec
Enolled
"*
True
lrM:Modt NoConlToi
v .,....
.., Dt:tJgn
~ formrPScanner
lodC! .....
v -
~V.W.ocTrue
v Uyout
liutoSc ; '1odc Foni
Aucosaol Fike
>
>
)
...,_
Au~o.o
Ai.itOSc~ O, 0
Au..S:.
Loa:iort
Ma~l't
...........,
.....
O, 0
0,0
) ~ o.o
> Plddn; 0, O, 0, 0
S:t 1349, 750
Stlr1Po9bon \~ tt.oc.a
\~tlte f'b'tnd
v Hise
-~)
c-.artton ~)
. -
Siz
Now we are going to add some of the controls that we will need for tl1e fonn:
(1) GroupBox - groupboxl
(3) TextBox- textboxl, begin_IP, end_IP
(3) Label - labell, label2, label3
(1) PictureBox - pictureboxl
( 1) Button - buttonScanIPRange
308 I PowerShell Studio - A Comprehensive Guide
uC IP Scanner @~~
-------------------------------~
'f
Sl"'111g IP >ddr= Ending IP >ddr=
PictureBox1
I u.e 1tie(192.168.1
~IPRqe
1orma1:
I UJtJt .1)
A
\ I I
'
I I I
Label2
GroupBox1
Label1 Label3
I
ButtonScanlPRange
Next, \Ve will add a DataGridView that will be used to display our results. I also added an additional image on the
left just for design purposes but it isn't necessary.
~IP Scanner ~ e :~
--------------------------~
IP Range Sc..mer
Tho tool wl scan al IP addi moo wilwl the fiW190 spedied to ldertfy
activemonilCIJVe IPs and lll!en.,i 1<> pmvlde device/system rlonnmon
DA TAGRIDVIEW
Now, we want to add three columns to our DataGridView; IP Address, Name, Open Ports.
IP~-
- .....
p
C~Ott:1Source
Edit Col1.1,,,nJ.
AddC~
(f'IOl'l t J
l ' i -
~ IP - ...... IP - D E... :.<A: 9
D Enbl< Edrong
I~ s_c., IP Rongo
. -~--~
I UM"'-
-..x.xx (192.1681.l) _i --J D Enoble Dtleting
[:a Enblie Column Reotdttlng
Step 1. Click on the s1nall triangle in the upper right of the DataGridView.
310 I PowerShell Studio - A Comprehensive Guide
Add Column ? x For each column, the two properties that "ve are concen1ed with
are the Header Text, which is the displayed colmnn nrune, and
the Read-Only box should be checked.
Add all tluee colunu1s, then click Cancel to close.
@ lhbolnd cok.ml
Name: ~,
CoUnn
--1---------------.
Type: DataGndViewTexiBoxCobm v
llP_Pddress
Headert.exl: ...... _____________.
12] V~ Read 0rVy 0 Frozen
L Add J Cancel
Colmn width can be adjusted if you like by editing the Edit Columns ? x
colmnns, and changing the FillWeight property. Selected Coli.mm:
~llilf.fi!if1
Click on small triangle in upper right of !!fill Name rv Design
DataGridVie' v control, select "Edit Colums". ~ Open Ports
CoUmType DataGOOViewText BoxColu .... I
v ~
PUoSizeMode NolSet
OMderWidlh 0
- 100
Frozen False
Mnimu:nWidlh 5
Width 287
Wei~ I
wet<j'I. that is used when sung ths cobm in the I
auo size mode.
Md ... Remove
J
OK Cancel
The DataGridView header should now look like the example below:
Now, let's look at the code needed to pull everything together and inake it a functioning fon11.
You'll notice that PowerShell Studio has already added the Helper Function when we added the DataGridView
control to the form. #region Control Helper Functions
Add Events...
Go to Event
~
Ctrl + E
____,
~
the "Edit D efault Event".
r~ Copy Ctrl + C
f{9 Paste Ctrl + V
)( Delete Del
DD Select All Ctrl +A
DD
~ Properties
~ View Code
Document Outline
16 [int]$Time0ut = 100
17 )
18 Begin
19 {$ping = New-Object System.Net.Networkinformation.Ping}
20 Process
21 {
22 [System. Windows. Forms.Application]:: Do Events()
23 foreach ($a in ($StartAddress.Split(".") [O) .. $EndAddress.Split(".") [O)))
24 { foreach ($bin ($StartAddress.Split(".") [l] .. $EndAddress.Split(".") [l]))
25 {foreach ($c in ($StartAddress.Split(".") [2] .. $EndAddress.Split(".") [2]))
26 {foreach ($d in ($StartAddress.Split(".") [3] .. $EndAddress.Split(".") [3]))
27 { $pingStatus =$ping.Send ("$a.$b.$c.$d", $Timeout)
28 $IP_No_P ing = "$a.$b.$c.$d"
29 if ($pingStatus.Status -eq "Success")
30 {Try
31 {[System. Windows. Forms.Application]:: Do Events()
32 if ($ResolveHost)
33 {[System.Windows.Forms.Application]::DoEvents()
34 $getHostEntry = [Net.DNS]::BeginGetHostEntry($pingStatus.Address, $null, $null)
35 }
36 if ($ScanPort)
37 {[System.Windows.Forms.Application]::DoEvents()
38 $open Ports = @()
39 for ($i = l; $i -le $ports.Count: $i++)
40 {$port= $Ports[($i - l)]
41 $client= New-Object System.Net.Sockets.T cpClient
42 $beginConnect = $client.BeginConnect($pingStatus.Address, $port, $null, $null)
43 if ($client.Connected)
44 {$openPorts +=$port}
45 else
46 {#Wait
47 Start-Sleep -Milli $Timeout
48 if ($client.Connected)
49 {$openPorts +=$port}
50 }
51 $client.Close()
52 }}
53 if ($ResolveHost)
54 {$hostName = ([Net.DNS]::EndGetHostEntry([IAsyncResult]$getHostEntry)).HostName
55 }
56 # Return Object
57 $scanresult = New-Object PSObject-Property @{ IPAddress = "$a.$b.$c.$d";
58 HostName = $hostName;
59 Ports= $openPorts} I Select-Object IPAddress, HostName, Ports
60 [System.Windows.Forms.Applica.tion]: :DoEvents()
61 $host_data = $scanresult.HostName
PowerShell Studio - Example Projects I 313
62 $IP_data= $scanresult.IPAddress
63 $ports_data = $scanresult.Ports
64 $datagridviewl .Rows.Add("$1P_ddta ", "$host_data", "$ports_da ta")
65 [System.Windows.Forms.Application]::DoEvents()
66 }
67 catc h
68 {
69 $datagridviewl .Rows.Add ("$a.$b.$c.$d", "Unknown Device", "NIA")
70 [System.Windows.Forms.Application] ::DoEvents()
71 }}
72 else
73 {
74 [System .Windows.Forms.Application] ::DoEvents()
75 $datagridviewl .Rows.Add("$1P_No_Ping", "No Response", "N/ A")
76 }}}}}
77 }
78 End
79 {}
80 }
81 $datagridviewl .Width = 623
82 # Disable the button until finished processing
83 $buttonScanlPRange.Enabled =$false
84 # Change the button text so the user knows it is running
85 $buttonScanlPRange.Text =" .. Scanning"
86 #Clear the DataGridView in case there is any previous scan showing
87 $datagridviewl .Rows.Clear()
88 $datagridviewl .Refresh()
89 $StartScan IP = $begin_IP .Text
90 $EndScan IP = $End_IP .Text
91 lnvoke-TSPingSweep -StartAddress $StartScanlP -EndAddress $EndScanlP -ResolveHost -ScanPort
92 $buttonScanlPRange.Enabled =$true
93 $buttonScanlPRange.Text ="Scan IP Range"
94 }
If you.call DoEvents in your code, your application can handle the other events. For example, if you have a fonn
that adds data to a ListBox and add DoEvents to your code, your fonn repaints \vhen anotl1er wil1dov1 is dragged
over it. If you remove DoEvents from your code, your fonn will not repaint until the click event handler of the
button is finished executing. This coilllnand can be used to help eleviate the issue \Vitl1 a fonn displaying "Not
Responding".
314 I PowerShell Studio - A Comprehensive Guide
!J R~
textbox3, this "vill be used to only enable our "Scan IP Range' button when RightTol.ftO>anood
.:=; Si2e0langed
tl1ey are not e1npt)'. [__, Tab!ndex<hanged
TabStop(j)angod
12i Tex!Chlnged
I v~
_J Contr~
I ControlRemoved
0.-ag[)rop
_, 0.-aQEnter
[__, " aqOver
0.-agleavo
~ Glv~
_J ~equested
~ QueryContrueOrag
QueryAce6Sb6~ v
In the editor, enter tl1e follo"ving code for the two "textchanged" events that you just created.
95 $begin_IP_TextChanged={
96 $buttonScanlPRange.Enabled = (($begin_IP.Text-ne "")-and ($End_IP.Text-ne ""))
97 }
98
99 $End_IP_TextChanged={
100 $buttonScanlPRange.Enabled = (($begin_IP .Text -ne "") -and ($End_IP .Text -ne ""))
101 }
-NoNo--
- 0 x
--
tt. ,_. . ..:"" 11 lP tcichJMt wcm.,. t*"9t ~ ' '"">'
d"lt/ro-i*l'O""'"...,,. ~ Dl!Vdc ~- ~
- w,....._~-~h:ll'!lt
Ooen Port
2llO.UltDIO
--
1'2.168.12 NIA
~-
' @ Gt I ll l 1'2.168 ll
192168 14
No-
...No -
WA
WA
1'2.16811
1'2.168 1'
1'2.161' 10
t!l.1'8.111
No-
M W-
HIA
WA
WA
ao 1"6
This form will allow you to display all running processes on a re1note computer and kill any process.
Next, we create a click event for each button, "Get Processes'', "Kill Process" and "Refresh". PowerShell Studio
will insert the event wrapper in the code editor for you.
Below is the code for each button tl1at you will need to enter:
10 $buttonKillProcess_Click = {
11 $computer= $computer.Text
12 $kill box = $killbox.Text
13 $kill_process = gwmi -comp $computer win32_process I ? name -like *$killbox.exe
14 [void] $kill_process. terminate()
15 $process_text.T ext= "''
16 $Processes= Get-Process -ComputerName $compu ter I Out-String
17 $process_text.Text =$Processes
18 }
Refresh button:
19 $buttonRefresh_C lick = {
20 $computer= $computer.Text
21 $Processes= Get-Process -ComputerName $computer I Out-String
22 $process_text.Text =$Processes
23
24 }
That's it, run the fonn, enter a computer name and click "Get Processes" . I added a couple of labels for the text
boxes to give users more clarification. This doesn' t include error trapping tl1at should be included in every script.
PowerShell Studio - Example Projects I 317
FILESHARE ANALYZER
In this example, we will create a form that recursively analyzes the parent folder that you specify and all child
folders to obtain the total nmnber of files in each directory, total size of each folder, last accessed, attributes and
the specified folder owner if exists.
oD Fil.share Analyze<
Label TextBox
EUeShare AnaNzer textbox
Reo.nively onolyzes the poront folder tn.t l'O'J specfy s1d al Cf1id foldets lo obtan lhe total IU1'i>er cl fies In eoch dinoctOI)',
I lntlyz rtesi-s I total size"' eoch folder. m tne spedoecl folder ovmer I -
TextBox
'
Button
PictureBox
I
I .
!........................................!
Label
DataGridView TextBox
In this example, vve are going to be using several different controls, as you can see from the image above.
1. Drag/Drop each control onto a new empty form, you can use the layout above or create your own layout.
2. Let's start with the TextBox (textbox50) located in the upper left comer of the form, this vvill be vvhere
the user will enter the file path they want to analyze.
a. Set BackColor property to "MintCream"
b . Set MultiLine property to FALSE
c. Leave the text property blank.
d. Create three different events (right-click on textbox and choose Add Events, fron1 the selection
box check "TextChanged", "Enter" and "Leave", then click Create.
e. In tl1e editor for the TextChru.lged event insert the follo,ving code:
l $textbox50_TextChanged={
2 If ($textbox50.Text-ne "")
3 {
4 $buttonAnalyzeFileShares.Enabled =$true
5 }
6 }
318 I PowerShell Studio - A Comprehensive Guide
f. In the editor for the Enter event insert the following code:
7 $textbox50_Enter={
8 $WatermarkText_dir ='Enter Path (example\\server\myfiles or v:\myfiles)'
'9 if ($textbox50.Text -eq $WatermarkText_dir)
10 {
11 #Clear the text
12 $textbox50.Text = ""
13 $textbox50.ForeColor = 'WindowText'
14 }
15
16 }
g. In the editor for the Leave event insert the following code:
17 $textbox50_Leave={
18 $WatermarkText_dir ='Enter Path (example\ \server\myfiles or v:\myfiles)'
19 if ($textbox50.Text -eq "")
20 {
21 #Display the watermark
22 $textbox50.Text = $WatermarkText_dir
23 $textbox50.ForeColor = 'DarkGray'
24 $buttonAnalyzeFileShares.Enabled =$false
25 }
26
27 }
The Enter and Leave events are designed to display the WaterMark "Enter Path (exa1nple \\server\1nyfiles or
v :\nl)'files)" when the textbox is e1npty, and also to disable the "Analyze FileShares" button if empty.
3. Next let's work on the "Analyze FileShares" button (buttonAnalyzeFileShares). In this example, I 've
added an arrow iinage to the button but it isn't necessary, you ca11 add do this using the "linage" property
of the button, and adjusting the "IinageAlign" property.
a. Create a Click event for the button (right-click and choose Edit Default Event). Then go to the
editor and use the follo\viI1g code \Vithin the $buttonAnalyzeFileShares_ Click Event.
28 $buttonAnalyzeFileShares_Click = {
29 # First we clear the contents of the DataGridView
30 $datagridview22.Rows.Clear()
31 # Disable and change the text of the "Analyze Fileshares" button
32 $buttonAnalyzefileShares.Enabled =$false
33 $buttonAnalyzeFileShares.Text = " ... Processing"
34 $ErrorActionPreference = 'SilentlyContinue'
35 # Set the ProgressBarOverlay step and set value to O
36 $progressbaroverlayl .Step= l
37 $progressbaroverlayl .Value= 0
38 # Clear the Status Messages box
PowerShell Studio - Example Projects I 319
39
1111
40 $rich textbox81 .Text =
41 $richtextbox81.AppendText("Analyzing Directories .... Please Wait ' n")
42 [System.Windows.Forms.Application]::DoEvents()
43 # Grab the parent folder file path from the text box
44 $item = $textbox50.Text
45 $every= "-Every"
46 $FormatNumbers = "-Forma tNumbers"
47 # Script-level variables used with -Total.
48 [Ulnt64]$script:totalcount = 0
49 [Ulnt64]$script:totalbytes = O
50 #region Get Directory
51 function Get-Directory
52 {
53 param ($item)
54
55 if (Test-Path -Path $item -PathType Container)
56 {
57 $item = Get-Item -Path $item -Force
58 }
59
60 if ($item -and ($item -is [System.10.Directorylnfo]))
61 {
62 return $item
63 }
64
65 }
66 #endregion
67 #region Format-Output
68 # Filter that outputs the custom object with formatted numbers.
69 function Format-Output
70 {
71 process
72 {
73 $_ I Select-Object Path,
74 @{
75 Name ="Files"; Expression = {
76 "{O:NO}" -f $_.Files
77 }
78 },
79 @{
80 Name = "Size"; Expression = {
81 "{O:NO}" -f $_.Size
82 }
83 }
84 }
320 I PowerShell Studio - A Comprehensive Guide
85 }
86 #endregion
87 #region Get Stats
88 # Outputs directory statistics for the specified directory. With -recurse,
89 # the function includes files in all subdirectories of the specified
90 # directory. With -format, numbers in the output objects are formatted with
91 # the Format-Output filter.
92 function Get-DirectoryStats
93 {
94
95 param ($directory,
96 $recurse,
97 $format)
98 $1astaccess = $directory.LastAccessTime
99 $attrib = $directory.attributes
100 $directoryname = $direc tory.Fu11Name I Out-String
l0 l $files= $directory I Get-Childltem -Force -Recurse:$recurse I Where-
Object {
102 -not $_.PSlsContainer
103 }
104 [System.Windows.Forms.Application]::DoEvents()
105
106 if ($files)
107 {
108 $richtextbox8 l .A ppendText("Calculating $directoryname")
109 [System. Windows.Forms.Application] ::DoEven ts()
110 $output= $files I Measure-Object -Sum -Property Length I
Select-Object '
lll
@{
112 Name ="Path"; Expression = {
113 $directory.Fu11Name
114 }
115 },
116
@{
117 Name ="Files"; Expression = {
118 $_.Count; $script:totalcount +=$_.Count
119 }
120 },
121
@{
122 Name = "Size"; Expression = {
123 $_.S um; $script:totalbytes += $_.S um
124 }
125 }
PowerShe ll Studio - Example Projects I 321
126 }
127 else
128 {
129 $output="" I Select-Object '
130 @{
131 Name ="Path"; Expression = {
132 $directory. FullName
133 }
134 },
135 @{
136 Name = "Files"; Expression = {
137 0
138 }
139 },
140 @{
141 Name ="Size"; Expression = {
142 0
143 }
144 }
145 }
146
147 if (-not $format)
148 {
149 $dir =$output.Path
150 $File_count =$output.Files
151 $Dir_size = ([System.Math]::Round($output.size /1 MB, 4))
152 $owner= Get-Acl $dir I select -expand Owner
153 If ($File_count -eq "O" -and $Dir_size -e q "O")
154 {
155 $datagridview22.Rows.Add("$dir", "Access Denied or Empty
Fo Id er,
" '"', "'I)
156 }
157 else
158 {
159 $datagridview22.Rows.add ("$dir", "$File_counf', "$Dir_size MB",
"$1astaccess", "$attrib", "$owner")
160 }
161 [System.Windows.Forms.Application]::DoEvents()
162 }
163 else
164 {
165 $dir =$output.Path
166 $File_count= $output.Files
167 $Dir_size = ([System.Math]::Round($output.size /1 MB, 4))
168 $owner= Get-Acl $dir I select -expand Owner
169 If ($File_count -eq "O" -and $Dir_size -eq "O")
322 I PowerShell Studio - A Comprehensive Guide
170 {
171 $datagridview22.Rows .Add ("$dir", "Access Denied or Empty
Folder", "", '"')
172 }
173 else
174 {
175 $datagridview22.Rows.Add ("$dir", "$File_counf', "$Dir_size MB",
"$1astaccess", "$attrib", "$owner")
176 }
177 [System.Windows.Forms.Application] ::DoEvents()
178 }
179
180 }
181 #endregion
182 # Write an error if the item is not a directory in the file system.
183 $directory= Get-Directory -item $item
184 if (-not $directory)
185 {
186 $itempath = $item I Out-String
187 $richtextbox81 .AppendText("$itempath is not a directory in th e file system.")
188 $buttonAnalyzeFileShares.T ext= "Analyze FileShares"
189 $buttonAnalyzeFileShares.Enabled =$true
190 $textbox51 .Text = "Finished"
191 return
192 }
193
194 # Get the statistics for the first-level directory.
195 Get- DirectoryStats -directory $directory -recurse:$true -format:$true
196
197 # Get the subdirectories of the first-level directory and get the statistics
198 # for each of them.
199 $Targets= ($directory I Get-Childltem -Recurse -Directory I Measure-Object I %{
200 $_.Count
201 })
202 $progressbaroverlayl .Maximum= $Targets
203 $textbox5 l .Text= $targets
204 $directory I Get-Childltem -Force -Recurse I
205 Where-Object {
206 $_.PSlsContainer
207 } I ForEach-Object {
208 Get- DirectoryStats -directory$_ -recurse:$true -format:$true
209 $progressbaroverlayl .PerformStep()
21O $Targets= ($Targets - l)
211 $textbox51.Text =$targets
212
213 }
PowerShe ll Studio - Example Projects I 323
4. Click on the small triangle in the upper right comer of the DataGridView, select Add Column. Add the
following columns; FileShare Path, Total Files~ Total Size, Last Accessed, Attributes and Owner. For
each colum11 check both the Visible and Read Only check boxes.
~ -~
~ - Sliare
-P_alh
_ __.==~--
Tclal
-Res--==~-Tdal
-S -z-o--==~-lasl
~Q~ ----====---i'tttb.t
--M---======---
OWnor
---===~-~jl' ~rldV'iewTllSks
Choose Data Source: f{nOn'el ,,.;ijl
~-----==:___===,
-'dd Column 7 x Edll! Columns...
Oat~~
6 Name: leoum1 I 0
Type: IDetaG!<MewTedBoxColl.rrro "J
I
Header text; ~S!)aie Pmh I
0 Vioibie D Reac!Only D Frozen
Md l Leancd_ j
--
No\V. you cru1 nu1 the form, by going to the HOrvIB tab in the ribbon bar, and clicking on RUN. The fom1 should
be silnilar to the exainple belo\v
FaleShare Analyze
~ lWWllytos lt>e""""" loldew tNi )'OU seJy ond .. cl1lcl ,_to oblllln !he 1otll IUllb d ffos ii actl ~O<)I.
-..
~1 lotol sltoof each folder. and !ho oped:-ed loide<ownerf - ..
F:'otognons\2.4
4543
450
133.1083 MS
-
2.6C66MS
O<l/ 12/2016 02:50:12
-
O<l/ 12/2016 02'50;52
Cho!Ol)I
l:QctOl)I
-
JEfF.HP\Jdf
JEfF.HP\Jdf
Statua Mev
F:~\tO_GK_Gomebo... S 6).7795MB
- - -
O<l/12/2016 02:50:55 Chdory JEFFHP\Jdf
~ F:~Dll'"''8\>8411J\100v~,,,..,.... S!)1<!s Pack 201tl\5v8uletln
4 ~ """" Sl<iia.. ~~'<mageo'll!!'ve\iopd~
A
1H11l9MB
- -- -
O<l/12/2016 02;50:56 JEfF.HP\Jdf
- ~ f;~\va:l10\100v~""'""" ~Pool< 2010\Sv~
-- ChdQrf 4~ m.n =~~~ve\ollltU>loon
~F: ~\841ft- 100vll<Uln l'>riJm St)!Hl'lld< 2010\5v~
874 4546 MB O<l/12/2016 02;51:02 acectory JEFf.HP\Jdf
~ol)otes fiom Sktneq,rl\l!roW~eS_-~
F'otognons\Adive@Fle Re. 4 9m1MB O<l/12/2016 02l51;03 CirettOl)I JEFF-HP\Jdf Colc::dimg f,..__\v84lj)\1oov&.-.<1'reri.1!1 &vies Pool< 2010\5v~n
- --
JEFf.HP\Jo!f
4~ F1oi!rSlci->Box !\hvllm*t"""~\a<lt!lloc010t
F:~\Adobo 4 207.8692 MB 04/12/2016 02:51:0S thQoty ~ F;'f><ooi1,.\v8410\100"~ ~AA> Pock 2010\5vMom
Directay 4 Sly!e$ f1'oo! ~S... l\llrovo~IOOivele.-.~ ..
F:'\pn>gllmsVdobe O.aove - 1755 36i1l5.691 MB O<l/12/2016 02.51.17 JEffHP\.ltll ~ F:....O!l'OlilS\w8410\100v&.lot;i ..._.., ~ ~:201tl\5v8tllelio
F:\pcoglonsVdobe.C"lllivate.... 3 248.3463M8 O<l/12/2016 02~:4() Dnlclory JEff.HP\lolf 4 ~fiiiin SktnBoxi!'8me~i.liriive"'1se\blo9 .
---- Re~. lhaO<)I
~ F:~\v 84f(J\ 100vrulem ~ Sfy!os Peck .21110\5 ,.~.,
16915.8248 MS 04/12/2016 03.00:44 JEff.HP\.ltll 4~ -~Nnve~~Wsolttees
~ f> \!184\0\10011~ P,..,..,, ~ l'aci< 2010\5 vllo.IJoCii
203.0334 MS O<l/12/2016 03:03:01 ihc:tOl)I JEFFHP\Jel! 4~ '1Qm Sl(t,eo;. !lhv<o~~~'l>odc~
~-
Fc~\AdobeCam<raRa_ 29 73.3881 MB O<l/12/2016 03.03:04 Dm:IOl)I JEFf.HPIJ<lf ~;'<>o>gt.,1;s\v8"410\10llv~ P""*"" 9yleo PllCk 201q1Sv&Aelin
4~ Sklr!lloX~~'i:wo~~voru
f ' c<og!msVdobelJ!ttn>cm. 900 71 .~ 1 6MS 04/12/2016 03-03:06 Dttd0ty JEFfHP\Jdf ~ F;~\v84l0\100 v!Metin " ' - sty\e's Poi:l<.20'10\5 vOOl!em
F:~~S_o!U! rn1 65.5613 MB 04/ 12/2016 03-03:15 ~ooy JEff.HP\Jdf
4 ~ FiomSl<ilS... f\!eio~ '
~1':~\V~11]).100v~ ...,,..,,~Paei<201~v~
F:~~ , Co<J>o., 124 1.7MB OC/12/2016 03<C411 Di'ectO<)I JEFFHP\Jdf 4 ill)'lo. Hon> SIMBox l\OelOXPSOs
--- ~ F~(l).100v~ _.., ~ Plick 201o\5ve.Jii!in
F~_Poaor_ 10 4153428 MS O<l/12/2016 030412 DlectQrf JEfF.HP\Jdf StylOs l'1o!i! ~!lox \,.Got~
~:~\vlJ410\100v~ ~ Sl)JF~OISv!WetTn
F:~ 2923 22.5094 M.8 04/12/2016 03:<1418 ChdO<)I JEfF-HP\Jdf ~ Ski>b r:aolo~'ld.io
-- --- ~~\v'8410\100~~ ~Slyl.. f>'ICkj2010\5v~
22.0<l45 MB 04/12/2(l16 0304:38 CirettQrf JEfF.HP\Je!f
l.iyle's - Sktnllo!< ~=~
~F:~~l 100v~l'remlilm$tylM~2010\5~in
F"""l'l!!l)S~-'"""""" 6 6.59.lSMS O<l/12/2016 03:*.33 Drec:!Ol)I JEFFHP\Jelf
F;~
--- ----
317 74974 MB
- -
04/12/2016 ()3:()<14() D'rec!O<)I
j ol)le$ A'om SldnScx ~l.ciilo~oc:h
- JEffHP\Jelf ... ...
324 I PowerShell Studio - A Comprehensive Guide
Chapter 6
\ I
PowerShell Studio - Reference Guide I 327
REFERENCE GUIDE
The reference guide contains important information pertaining to not only Po,verShell Studio but also Windo,vs
Po,verShell. You will also find all the pertainient control properties for each control listed. in an easy to read table
fonnat.
One of the challenges faced \.vhen developing any Po,verShell script is that modules that reside on your local
development computer may or may not be available on the target computer that you user \.Vill be n1nning your script
from.
As a first step, you need to get the PowerShell cache information that PowerShell Stuido uses fro1n your target
1nachine. To inake this as si1nple as possible, SAPIEN has packed all the files required into a zip file. It's called
CacheExport.zip and you can find that in the PowerShell Studio product installation folder m1der "Redistributables".
Take CacheExportxxxx.zip file, copy it to a flash drive, a nehvork share or wherever you need it to be so you can
access it from the target machine. It is recommended that you unzip the file after you have copied it to the target
machine to avoid a few extra dialog boxes that would occur.
Start the CacheExport utility (CacheEA'J)Ort.exe). This process \Vas designed to be installation free, so anything that
needs to happen \.vill be done by the utility . Unless you have anything else SAPIEN already installed on that
machine, CacheExport will launch RegisterControls.exe. As this requires elevation you inay get a few corresponding
pro1npts. Please make sure to allo"v it to run, othenvise the utility \von't work.
Cad1e Export x
Export c:ache files to: J C:\Users\Jeff\pesktop\JEFF-HP.CacheExport
ID
Local Cache Stall.JS
Save I L Close ]
328 I PowerShell Studio - A Comprehensive Guide
Most likely you see a status as shown above. Click on "Rebuild all cache files" if anything is not present. If you
leave the CacheExport tool on your remote inachine, you can later on do this as needed if you install new versions
of any module(s) or additional n1odules or products on that system.
Save Close
Depending on platform and PowerShell versions installed this process takes a fe,v minutes to co1nplete. Once
finished, you should see so1nething like this:
PowerShell Studio - Reference Guide I 329
Click on the "Save" button to save the newly built cache files to an export file. The default
location for this is your desktop. The file is na1ned with your computers name and a .CacheExport
extension. Please do not modify the name of the file, because this naine is \V hat PowerShell
Studio will use to fi11d that remote 1nachine on a network. The CacheE>q)ort utility \Vill
automatically close after you click "Save".
Take that file a11d copy it back to your flash drive, network share or whatever location you can access fro1n your
develop1nent macltine.
After you have exported the remote cache from your target remote system, the next step is to i1nport the remote
cache file into PowerShell Studio located on your development syste1n.
x
> This PC > Desktop > v Cl Search Desktop p
OneDrive
c:3 This PC
Desktop istatus I-Status Graphics Jeff JeffHolder Cloud knowledgebase2 Mastering New folder
23 PowerShell
~ Documents
..J. Downloads
Ji Music
'- I Pictures
Videos New Graphics ReelSchematic ReelSchernaticl Source status display SURVIVEOUTDO SurviveOutdoor
:;_ OS (C:) OR Backup
- HP_RECOVERY (
_ Secondary (F:)
f
fj CD Drive (G:)
_ Data locker (H:)
SurviveOutdoor SurviveOutdoor Tungstenlube tungstenlube.co Work JEFF-HP.CacheEx
_ Datalocker (H:) o.; Book Product Labels m port
Open 11 Cancel
330 I PowerShell Studio - A Comprehensive Guide
Credentials
Username:
No"v, you have hvo options for connection to the re1note system, either Windows PowerShell remoting or RSEE
Remoting. Depending on your selection so1ne of the following options may not be available to you. If you plan on
using Windows Remoting to run scripts on this machine you may have to provide a valid user id and pass\vord for
that computer.
If you are using RSEE (Re1note Script Execution Engine) to connect to the remote inachine no credentials are
necessary. If you plan on just running or testing script on that remote machine and you already have Windo\VS
Remoting \ivorking, there is no need to install RSEE there. If on the other hand, Windows Re1noting is not an
option or you need to debug on that remote computer, installing the RSEE service on the target 1nachine is
reco1nmended.
Once you have the cache infor1nation imported you can select the machine
Local Madine
from the platform combo box:
Local Machine
JEFf +iP ~~----_,,,,___
Once you have selected this other machine as your target enviromnent you
..___.
""' Platform will see c1ndlets colored according to \Vhat exists on this machine but not
your local co1nputer.
RSEE is a complex tool a11d it interacts closely with Windows' security subsystems. RSEE is recornme11ded for use
only by experienced Windows adn1iitistrators wl10 f1tlly understand service deploy1nent and inanagement, cross-
co1nputer secmity and authenti.cation and, in the case of don1ain environn1ents, Group Policy objects and Active
Directory ad1ninistration. Apart fro1n tl1e guidelines in tllis nianual, SAPIEN Teclu1ologies caiu1ot assist you with
security issues caused by improper configuration nor can \Ve assist \Vith Active Directory, Group Policy, or local
computer configuration tasks.
RSEE is designed only for Windo,;vs Script Host (WSH) scripts in VBS (VBScript) or JS (JSc1ipt) files. It is not
designed for otl1er WSH scripts (including WSFs) nor is it designed for scripts \.Vritten in other languages (such as
batch KiXtart, and so forth).
7
RSEE DeJlloyment
RSEE's service component is packaged in a Microsoft Windows Installer (MSI) file and is sttitable for deployn1ent
via Group Policy. You can also 111anually install it on individual machlnes. Keep in 1nind t11at, once installed, the
se1v ice needs to be started in order to be useful. Tllis will occur auto1natically after restartiJ1g the computer on wltich
the service is installed (the service is set to strut auton1atically by default).
After deploying the service, there are a ntunber of configuration steps that you must take in order to properly
configure RSEE in your environment.
Identity
RSEE installs, by default, to log in u11der the privileged Loca.lSystem accou11t. This may be s11fficient for your
purposes. However when deployi11g scripts in PowerShell Studio, be sure not to specify any credentials in the
Launch dialog box. Also, be advised that the LocalSyste1n account may not be able to execute son1e scripts,
depending on their security require1nents.
332 I PowerShell Studio - A Comprehensive Guide
We recommend that you co1tligure the RSEE service to nm under a l1ser account tliat has adntinistrative privileges
on the local co1nputer. In a workgroup ei1vironment, this would be a local acco1mt, and we reconunend creating tlle
same local accom1t (with tlle same pass,vord) on all of your co1nputers, for consistency. In a don1ain enviro11filent,
'1Ve reconm1end creating a single domain. account '1Vhich has local adnunistrative rights on all co1nputers in the
do1nain, and using this accolmt to nm t11e RSEE se1v ice. Whenever the RSEE service is nllllling under a user
account, you must specify that account (and its pasS\:vord) when deploying scripts in PrirnalScript.
When using RSEE, you have the option to specify the credentials 11uder vvhicl1 tlle script should execute. Generally
speaking, you need to provide the sa111e credentials that the RSEE service is using to log on.
TCP Port
The RSEE se1v ice defaults to using TCP port 9987 for incon1ing com1ections, and TCP port 9988 for outgoing
connections. It is your responsibility to ensure that any local firewalls \:vill permit inco1ning traffic on tllis port. Keep
in n1ind that the Windoivs Fire\.vall (Windo,:vs XP SP 2 and later. and Windows Seiver 2003 SP 1 and later) can be
centrally configlrred via a do1naiI1 Group Policy object.
Both Po"VverShe11 Studio (as the RSEE client) and the RSEE service utilize InP01t ai1d OutPort. The service listens
to InPort for iI1conling connections and uses OutPort to send script output back to the client. The client reverses this:
scripts are sent via InPort ai1d results are received on OutP01t. The registry key above con.figures tl1ese ports for
both clients and the service.
Domain Tips
While manually configuring a few co1nputers in a workgroup is not a hardship, mai1ually corrfig1rri11g ai1 entire
don1ai.n of computers can be burde11So1ne. Al1 Active Directory do1nain environment provides a nu111ber of
capabilities for centraliziI1g and auto1nating this configuration, ho'1vever. While this section is not iI1tended as a
comprehensive t11torial in Active Directory (we recornmend tllat you consult an e~'Perienced Active Directory
ad1ni1tistrator or the appropriate docun1entatio11 if you need inore assistance), the following tips should help you
configure RSEE more easily:
Create a don1ain accou11t. Name this account son1ething like "RSEEUser" ai1d provide it with a strong
password per yo1rr organization's password policies.
Deploy the RSEE service. This cai1 be done by meai1s of a Group Policy object (GPO) linked to the
appropriate levels in the domain. The RSEE se1v ice defaults to running under the LocalSystem account
and it defaults to port 9987. The service's MSI is in tlle RSEE folder under your PrimalScript Enterprise
installation folder.
PowerShell Studio - Reference Guide I 333
Make the RSEE service account a local Ad1ninistrator. You can do tllis in a Group Policy object (GPO).
Bro"vse to Computer Configuration > Security Settings > Restricted Groups. Add a group
("Administrators") ru1d U1en add your RSEE domain account (a11d any other appropriate accounts) to the
group.
Configure the RSEE service. You need to configure the RSEE service to log 011 ' viU1 tl1e user account (ru1d
pass\vord) you created. This can either be done 1nanually or using a script. The book 1if;indoH'S
Adn1inistrator's A11ton1ation 1'oo/kit, for example, contains a script that can set the logon account and
pass,vord used by services nnming on multiple computers. Utilities like Senice Explorer
(W\V\V.scriptlogic.co1n) can perfonn the sa1ne task.
Select the TCP port. We provide a Group Policy object (GPO) administrative template (ADM file) that
you can import into a GPO a11d use to centrally configure the TCP port used by the RSEE service. Tllis
ADM file is located in the RSEE folder under your PrimalScript Enterprise installation folder.
UsingRSEE
RSEE no' v supports Po,versbell. To deploy the current script (only VBS and JS files are currently supported) to one
or more ren1ote co1nputers that have the RSEE service installed, click the RSEE button on the Seri.pt toolba.r. or
select Run Script on Re1note Co inputer from the Script menu.
RSEE perfom1s a quick scan of your script to look for con111umds tliat nrighl create a graplrical user element such
as U1e VB Script MsgBox() function. If it finds any of these functions, it displays a wanti11g message. Keep in 1ni nd
that scripts \Vill not nonnally be able to interact \riU1 the desktop en ironment on remote computers, n1eaning there
':vould be no \Vay for someone to respond to graphical elements such as MsgBox() or InputBoxO. Thus. these
ele1uents can cause the script to "hang" and stop respo11ding. RSEE does not perfom1 an exhaustive check for
graphical ele1nents: it is your responsibility lo ensure they're not used in your scripts. RSEE ' vill allow you lo
continue \Vitb graphical elements because you may have configured lhe RSEE service to interact \Vith the desktop
of U1e ren1ote computer. It's your decision.
Next is the RSEE Lat1nch dialog. The Launch dialog lists the computers \\here your script \Vill be deployed. Note
that tl1e Launch dialog a.l'vays preloads a default list of co1nputer11an1es at startup. Here's '\'hat you can do:
Click Launch lo run the sc1ipt on the computers "''hicb have a checklnark next to their na1ne.
Set or clear the cJ1eckbox next to one or inore computer na1nes. You can .leave nan1es in the list but clearing
their checkbox 'rill prevent RSEE f ro1n at1en1pting to run the script on them.
Click Close to close the Launc.11 dialog. Ifyou've changed the list of computer nan1es. yo111ll be prompted
to save your changes.
Use Load List and Save List to load an alternate list of computer names (from a text file) or saYe the current
list to a te:\.1 file. By default, Prima.lScript vvill look for a te}.1 file called Default.clt in the \SAPlEN\RSEE
Lists folder under your Documents folder. You \ Vill need to create the file youiself if you want a pre-loaded
list 'vhen you launchRSEE.
Use Select All and Unselect All to set or clear the checkbox next to all computer ruunes currently in the
list.
334 I PowerShell Studio - A Comprehensive Guide
Select a computer name and click Remove to remove it from the list.
Type a computer i1ame (1nust be resolvable to an IP address by your computer) or IP address and click +
to add that computer to the list
Specify a usernatne (user ID) and password. These will be used to run the script on tihe ren1ote con1puter,
and should generally 1natch the usen1a1ne that tl1e ren1ote RSEE senrice is usiJ1g to log in. Note: if the
usen1ame you specify is a local account on the remote computer(s). then just type tl1e use1name. If the
usen1rune is a do1nain account, specify the name in the fonnat user@domai11 The older domain\user format
is not supported.
When you click Launch, RSEE will execute the script on the ren1ote computer(s) . .Any output produced by the script
\vill be displayed in the Output tab vvithin the Po,.verSl1ell Stl1dio vvindovv. Note that the message "Socket connection
failed" i11dicates that RSEE was unable to connect to the RSEE service on a specified con1puter (eitl1erbecause the
co1nputer is not connected to the netvvork, bas a firewall blocking the RSEE service po1ts, or the RSEE seivice is
not installed).
RSEE deploys scripts asynchronously. That is, RSEE sends the sc1ipts out to th.e remote con1puters you've selected
and then displays \Vhatever results co1ne back. If your scripts produce no output, then you won't see any results in
PovverShell Studio.
It's possible for the RSEE seivice on a remote co111puter to n1n into a problem (particularly secu1ity-related ones)
that it can't report back: in these insta11ces, it vvill see1n to you (looking at PovverSbell Studio) as if nothing has
happened. Whenever possible, your sc1ipts should incorporate error-checking and -trappil1g: and should produce
appropriate output so that you get so1ne res1ilts back if the script executes conectly.
RSEE cannot be used to deploy a script for later execution. If you need to schedtile a script to execute on a remote
computer at a particular tin1e, use Windows' built-in Task Scheduler instead of RSEE. You can even write a script
utilizing the SCHTASKS.EXE comnw1d line tool tliat creates re1note scheduled tasks on multiple co1nputers.
Also. if an Output tab is already open in Po\verShell Studio, RSEE will utilize it rather tlian creating a nevv one.
You \!Vill need to 111anually select the tab to vie'v any RSEE results or error 1nessages.
RSEE Restrictions
In order to bring the output of re1note scripts back to your coinputer. U1e ren1ote RSEE senrice captl1res tl1e standard
conlffiand-line output of your scripts. That n1eans any sc1ipt output 1nust be created using the WScript.Echo 1nethod.
Do not use graphical user interface functions sucl1 as MsgBox() or InputBoxO. Because the RSEE se1vice doesn't
interact vvith the desktop, nobody will ever see these functio1is' dialog boxes and tl1e script vvill hang.
It is possible, if the RSEE service is .n1nning under the LocalSystem account, to configiue Wil1dows to allow the
service to interact with the desktop. You may vvish to e>..rperiment witl1 this configuration, but it is not a recom1nended
configuration because of the usual security restrictions on the LocalSystem account.
Any objects referer1ced by a script must be installed, registered, arid available on the rernote inachil1e where RSEE
executes tl1e script.
At tltis time, RSEE can only be used to execute Windo,vs Script Host scripts. RSEE explicitly launches scripts tmder
CScript.exe \Vhich must be available on the re1note computers.
Most otl1er restrictions in RSEE are actually Windows sectlrity restrictions. When the RSEE service launches, it
does so using the credentials you configure in Windo\.vs' service 111anager. When the RSEE service receives a script,
it creates a brar1d-ne\.v process usi11g whatever credentials you enter into tl1e RSEE Launch dialog. The following
figure illustrates this process a11d tl1e tlrree sets of credentials involved:
SCRIPT
CREDENTIAL #2 USED
RSEE SERVICE
CREDENTIAL #3
Always bear in mind that your scripts execute under the sectlrit)' credentials you provide (Credentials #2 il1 the
diagra1n). Tltis process does require your attention, as several things can go \.Vrong if you're not careful:
If, in the Lau11ch dialog, you specify credentials (#2 il1 the diagrai11) that the RSEE se1v ice account (#3 in
the diagrain) doesn't have perntission to use in a ne'v process launch, then script execution will fail.
Practically speaki11g, the credentials you provide in the Lam1ch dialog (#2 in the diagram) need to be the same as
the credentials the RSEE service uses to log in (#3 in the diagTam).
If the RSEE service accotmt (#3 in the diagra1n) doesn't have appropriate rights (including "Log on as a
service"), tl1en the RSEE service will not be able to start.
If your script tries to do so1nething that the Launch credentials (#2 il1 the diagrain) don't have permission
to do-such as log into a database or access a file share-then you'll receive an error. Depending on the
exact situation, this may or may not be co1mnunicated back to you in PowerShell Studio.
If your script tries to pe1fonn an illegal operation-such as specifying alternate credentials in a WMI
connectio11 (which is illegal because the script is executing locally on the re1note macltine, ai1d local
connections to WMI aren't allowed to use alternate credentials)-you'll receive ai1 error. Again, depending
on the exact circumstances, this error inay or n1ay not be fed back to you in Po\verShell Studio.
336 I PowerShell Studio - A Comprehensive Guide
These and other similar situations are not problems 'vith RSEE; they are inherent conditions of the Windows
operating system ru1d its security subsyste1ns. Whenever you encounter an error with RSEE, bear these conditions
in inind and think about the possible security ramifications of what your script is trying to do.
RSEE encrypts scripts during trans1nission to help keep the1n secure. RSEE does not implement ru1y sort of IP
filtering capability ('vhich might, for exa1nple, allow you to ensure that only your co1nputer can utilize RSEE on
re1note servers). Instead~ \Ve reco1n111end using Windo\vs' o'vn built-in IP filtering (available as part of Windo,vs'
IPSec features) . Using this filtering,.you can ensure that only specified IP addresses are allo\ved to collllnunicate on
the TCP ports used by the RSEE service, thus restricting who can contact that service and utilize RSEE.
STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) detennine how a process manages legacy
COM objects and tl1eir collllnunication with inultiple threads. I \Vill not go into the detail, but you need not concern
yourself 'vith the inner workings of COM objects, other than to reme1nber that STA is required for some of the GUI
controls to function correctly.
The follo"ving controls require STA mode. Othenvise, they do not appear.
FolderBrowserDialog
SaveFileDialog
OpenFileDialog
STA mode is not so1nething you normally have to consider when writing scripts, but it is something that you should
be a'vare of if you are creating GUis tools. Most GUis will n111 fine in MTA mode, but as a rule, you should always
n1n your GUI scripts in STA
You can make sure that your Windows PowerShell scripts require STA vvhen running. If you add the
following comn?.ent to your script, PowerShell Studio and Prima/Script run the script in STA mode: #
o/oForceSTAo/o = True
PowerShell Studio - Reference Guide I 337
PSSCRIPTANAL YZER
~ Check Syntax PSSc1iptAnalyzer is a PowerShell 1nodule developed by the PowerSl1ell Tean1 at Microsoft
and checks the quality of Windo,vs PowerSl1ell code by n1nning against a set of rules. The
' ~ Venfy Salpt
ntles are based on PowerShell best practices which have been identified by the PowerShell
,, ~ Analyze Saipt team and PowerShell Co1n1nunity.
Analyszs
PSScriptAnalyzer is built into Po'\>verShell Studio for convenience of use, located lmder the
"Tools" tab, in the Analysis section, and na1ned "Analyze Script".
We you click on "Analyze Script", PSScriptAnalyzer will scan your Po"verShell code, and return a report of any
findings similar to the report below:
SCRIPTPATH IN HOST
Many PowerShell users utilize code as shown belo"v to determine \.Vhere the running script resides:
Unfortunately, if the script nms inside a custon1 host, such as PowerShell Studio 's intenlal host, for a good
number of debuggers and the SAPIEN PowerShell host from the PowerShell Studio packager, the MyInvocation
variable contains an empt)r path member.
There is no docu1nented way to set My Invocation fro1n a custom host and any atten1pts contacting Microsoft iI1
this matter only resulted in confinnation that any atte1npt to do so would be ove1writte11 anyway. It see1ns
unreasonable to eA--pect the Po,verShell tea1n to change the API anytime soon. And even then, changing the current
behavior nlight prove m1desirable since it could potentially break existing scripts.
That of coluse leaves everyone implementing a custom host with a dile1nma. The SAPIEN Po"verSl1ell hosts no"v
all contain a variable called $Hostlnvocation \Vhich has the same interface as My Invocation and provides the
desired infoanation.
338 I PowerShell Studio - A Comprehensive Guide
So, if you are running your script inside any SAPIEN PowerShell host you can use code like tbis to determine
where your script is:
There are ti1nes, especially when using the ColorDialog control and you need to translate the HEX# color i1m11ber
to a usable format for controls and fonns. If only basic colors are used, then the translation fro1n HEX# is not needed.
To translate the color picked from the ColorDialog control use the following example:
1 $buttonChangeColor_Click = {
2 # Open the ColorDialog Box
3 $colorDialogl .ShowDialog()
4 # Grab the color that the user selects
5 $BackColor = $colordialog l .Color.Name
6 #Translate the HEX# to a System Drawing Color for the Form Background
7 $BackColor = [System.Drawing.ColorTranslator]::FromHtml('#' + $BackColor)
8 # Apply the color to the form
9 $form l .BackColor = $BackColor }
REQUIRE ADMINISTRATOR
There are many times that you need your form to run with elevated privileges. The standard "vay has always been
to place the follo\iving code either at the start of your script, or at the start of the Fonn_Load event.
1 If (-NOT
([Security. Principa l. Windows Principal] [Security. Principal. Windowsldentity] ::G etCurren t() ) .lsln Role ( [
Security.Prin cipal. WindowsBuiltlnRole] "Administrator"))
2 {[void] [System.Windows.Forms.MessageBox]::Show('This form must be Run As Administrator!",
"Error Message")
3 $FORM l .close()
4 }
PowerShell Studio - Reference Guide I 339
NOTE: this is one of those rare occasions when code does not require that it be started by an event eitl1er directly
or indirectly.
If the user is not n1nning tl1e form as ad1ninistrator they will receive an error inessage popup, and the form will
close. Tbis inethod works "vith all PowerShell versions and provides you a ineans to display a custon1error111essage.
Beginning with PowerSbell 4.0 you cottld also use:
1 #requires -runasadministrator
NOTE: Keep in mind this will reqttire that all users that run your form '\ivill need to have at least PowerShell
version 4 installed.
CONTROL PROPERTIES
BUTTON
AccessibilityObject
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets the default action description of the co11trol for use by
accessibility client applications.
AccessibleDescription Gets or sets tl1e description of the control used by accessibility client
applications.
AccessibleName Gets or sets the name of the control used by accessibility client
applications.
Accessible~ole Gets or sets the accessible role of the control
AllowDrop Gets or sets a value indicating \.vhetl1er the control can accept data that
the user drags onto it.
Anchor Gets or sets tl1e edges of the container to \Vhicl1 a control is bound and
determines how a control is resized with its parent.
AutoEUipsis Gets or sets a value indicating vt'hether the ellipsis character (... ) appears
at tl1e iight edge of tl1e control, denoting that the control text eA1:ends
beyond the specified length of the control.
AutoScrollOffset Gets or sets where tlus control is scrolled to in ScrollControllnto Vie\.v.
AutoSize Gets or sets a value that indicates whether the control resizes based on
its contents.
AutoSizeMode Gets or sets the mode by which the Button automatically resizes itself.
BackColor Gets or sets the background color of the control.
Backgroundlmage Gets or sets tl1e backgrotu1d image displayed in the control.
Background Im ageLayou t Gets or sets the background image layout as defined in the lmageLayout
ent101eration.
BindingContext Gets or sets the BindingContext for the control.
Bottom Gets the distance, in pi\:els, benveen the bottom edge of the control and
the top edge of its contai11er's client area.
Bounds Gets or sets tl1e size and location of the control il1cluding its nonclient
elements, in pixels, relative to the parent control.
340 I PowerShell Studio - A Comprehensive Guide
CanEuablelme Gets a value incticating whether the lmeMode property can be set to an
active value. to enable IME support.
CanFocus Gets a value indicating '~hetl1er U1e control can receive focus.
CanRaiseEvents Detennines if events can be raised on the control.
CanSelect Gets a value indicating \ V hetl1er the control can be selected.
Catlture Gets or sets a vaJue indicating \'V heU1er the control has captltred the
mouse.
CausesValidation Gets or sets a value indicating 'vhether the control causes validation to
be performed on any controls that require validation \vhen it receives
focus.
ClientRectan gle Gets the rectangle that represents the cliet1t area of the control.
ClientSize Gets or sets the 11eight and width of the client area of tl1e control.
Com1anyName Gets the ruun.e of the co1npru1y or creator of the application containing
the control.
Container Gets the IContainer that contains the Component.
ContainsFocus Gets a value indicating \vhether the co11trol, or one of its child controls.
currently has the input focus.
ContextMenu Gets or sets the shortcut men11 associated with the control.
ContextMenuStrip Gets or sets the ContextMenuStrip associated "'-itb thls control.
Controls Gets the collection of controls contained \\1ithin the control.
Created Gets a , ralue indicating whether the control bas been created.
CreateParams Gets a CreateParams on U1e base class 'vhen creating a 'vindo,v.
Cursor Gets or sets U1e cursor U1at is displayed \hen the mouse pointer is over
the control.
DataBindings Gets the data bit1dings for the control.
DefaultCursor Gets or sets the default cursor for the control.
Defau ltlmeMode Gets the default Input Method Editor (IME) mode supported by this
control.
DefaultMargin Gets the space. in pixels. that is specified by default bet,yeen controls.
DefaultMaximumSize Gets the length ruid heigl1t in pixels. tliat is specified as U1e default
maximun1 size of a control.
Defau ltMinimu mSize Gets the length and height in pixels. tliat is specified as the defa1tlt
111inin111m size of a control.
DefaultPadding Gets U1e internal spacing, in pixels, of tl1e contents of a control.
DefaultSize Gets the default size of the control.
DesignMode Gets a value that indicates ivl1ether the Co1nponent is currently in design
n1ode.
DialogResult Gets or sets a vaJue that is rettuned to the parent forn1 when the button
is clicked.
DisplayRectangle Gets the rectangle that represents the display area of the control.
Disposing Gets a value indicating \:vbether the base Control class is in tl1e process
of disposing.
Dock Gets or sets which control borders are docked to its parent co11trol and
determines ho':v a control is resized ':vith its parent.
Dou bleBuffered Gets or sets a value indicating \vhether this control should redravv its
surface using a secondary buffer to reduce or prevent flicker.
Enabled Gets or sets a value indicating \Vhether the control c ai1 respond to user
interaction.
PowerShell Studio - Reference Guide. I 341
[
Events Gets the list of event handlers tl1at are attached to this Component.
FlatAppearance Gets the appearance of the border and the colors used to indicate check
state and 1nouse state.
FlatStylc Gets or sets the flat style appearance of the button control.
Focused Gets a valu.e indicating whether the control l1as inpt1t focus.
Font Gets or sets the font of the text displayed by the control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
Handle Gets the window handle that the control is bound to.
Has Children Gets a value indicating whether the control contains one or more child
controls.
Height Gets or sets the heigl1t of the control.
Image Gets or sets the image that is displayed on a button control.
ImageAlign Gets or sets the alig1nnent of the ilnage on the button control.
lmagelndex Gets or sets the image list index value of the image displayed on the
button control.
lmageKey Gets or sets the key accessor for the i n1age in the ImageList.
lmageList Gets or sets the ImageList that contains the Image displayed on a button
control.
lmeMode This API supports the product infrastructure and is not intended to be
used directly from your code. Gets or sets the Input Method Editor
(IME) 1node supported by this control. This property is not relevant for
this class.
ImeModeBase Gets or sets the IME 1node of a control.
InvokeRequired Gets a value indicating \.Vhether tl1e caller must call an invoke 1nethod
\;vhen making method calls to the control because the caller is on a
different thread tllaD the one the control was created on.
lsAccessible Gets or sets a value il1dicating whether the control is visible to
accessibility applications.
lsDefault Gets or sets a value indicating wbetl1er tl1e button control is tl1e default
b11tton.
IsDisposed Gets a value indicating ':vhether the control bas been disposed of.
IsHandleC reated Gets a value indicating whether tl1e control has a 11andle associated v1ith
it.
lsMirrored Gets a value indicating whether the control is mirrored.
LayoutEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the dista11ce, in pixels, between tl1e left edge of the control
and the left edge of its container's che11t area.
Location Gets or sets tl1e coordilla.tes of the upper-left corner of the control
relative to the upper-left corner of its container.
Margin Gets or sets the space benveen controls.
Ma.~imumSize Gets or sets the size that is the upper lin1it that GetPreferredSize can
specify.
MioimumSize Gets or sets the size that is tl1e lower Jimit that GetPreferredSize can
specify.
Name Gets or sets the name of the control.
Padding Gets or sets padding within the control.
Parent Gets or sets the parent container of the control.
342 I PowerShell Studio - A Comprehensive Guide
PreferredSize Gets the size of a rectangular area into 'vhicb the control can fit.
P roductName Gets the product nan1e of the assembly contai ning the control.
ProductVersion Gets the ~version of the assembly containing the control.
Recreatin gHandle Gets a value indicati11g whether the control is currently re-creating its
handle.
Region Gets or sets the \Vi11do'v region associated \Vith the control.
RenderRightToLcft Obsolete.This property is now obsolete.
ResizeRedra\v Gets or sets a value i.ndicating \Vhether the control redra,vs itseJf ivhen
resized.
Right Gets the distance, in pi.xels bet,veeu the right edge of the control and
the left edge of its container's clier1t area.
RigbtToLeft Gets or sets a value indicating whether control's elements are aligned to
support locales using right-to-left fonts.
ScaleCbildren Gets a value that determines the scaling of child co11trols.
SholvFocusCues Gets a value indicating whether the control should display focus
rectangles.
Sbo\\1Keyboard
Cues Gets a value indicating ~v.hether the user interface is in the appropriate
state to show or hide keyboard accelerators.
Site Gets or sets the site of tl1e control.
Size Gets or sets the height and \tVidth of the control.
TabIndex Gets or sets tl1e tab order of the control within its container.
TabStop Gels or sets a value indicating wl1ether U1e user can give the focus to
this control using the TAB key.
Tag Gets or sets the object that contaiI1s data about the control.
Te.~t Gets or sets the text associated \Vith this control
TextAJign Gets or sets the alignment of the text on the button control.
TextlmageRclation Gets or sets the position of text and image relative to each other.
Top Gets or sets the distance. in pixels, benveen the top edge of the control
and the top edge of its container's client area.
TopLevelControl Gets the parent control that is not parented by another Windows Fonns
control. Typically, this is the outermost Form that the control is
contained in.
U seComp atibleTextRendering Gets or sets a value that detennines 'vhelher to use U1e Graphics class
(GDI+) or the TextRenderer class (GDI) to render te~1.
UseMne.m onic Gets or sets a value indicating whether t11e first character that is
preceded by an ampersand (&) is used as the mnemonic key of the
control.
UseVisu alS tyleBackColo r Gets or sets a value that detennines if the backgrot1nd is dra,;vn using
visual styles. if supported.
U scW aitCursor Gets or sets a value indicating \vhether to use the 'vail cursor for the
current control and all child controls.
Visible Gets or sets a value indicating 'vhether t11e control and all its child
controls are displayed.
Width Gets or sets tl1e "vidlh of the control.
WindowTarget T.his API supports tl1e product infrastn1cture and is not intended to be
used directly from your code. This property is not releYanl for this class.
PowerShell St udio - Reference Guide I 343
CHART
Accessibil~rO bject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActiooDescri1ltioo Gets or sets U1e defaull action description of the control for use by
accessibility client applications.
AcccssibleDescription Gets or sets the description of tl1e control used by accessibility client
applications.
AccessibleN ame Gets or sets the name of the control used by accessibility clienl
applications.
AccessibleRole Gets or sets the accessible role of the control
Allo"Dro1> Gets or sets a value indicating \vhetller the control can accept data that
the user drags onto it.
Anchor Gets or sets the edges of the container to \Vhich a control is bound and
dete.nnines h O\.Y a control is resized '''ith its parent.
Annotations Gets or sets the name of the control used by accessibility client
applications
Anti Aliasing Gets or sets a value that detennines \hether anti-aliasing is used \\ihen
tex.'t and graphlcs are drawn.
AutoScrollOffset Gets or sets ' vhere this control is scrolled to in ScrollControlintoVie,v.
AutoSize Gets or sets a alue that i11dicates \Vhether the control resizes based on
its contents.
BackColor Gets or sets the backgrotmd color of the control
BackGrad ientS tyle Gets or sets the orientation for the background gradient of a Chart
control. Also. determines \Vhether a gradient is used.
Backgroundlmage Gets or sets the backgrotmd image displayed in the control.
Backgrou ndlmageLayout Gets or sets the background image layout as defined it1 the ImageLayout
enumeration.
BackBatchStvle
Gets or sets the hatching sty le of the Chart control.
Backlmage Gets or sets the background ilnage of the Chart control.
BacklmageAlignment Gets or sets the background image alignment used for the Unscaled
dra,ving tnode.
BacklmageTranspareotColor Gets or sets the color of the Chart control that will be displayed as
transparent.
BacklmageW ra1>Mode Gets or sets the dra\ving rnode for the background image of the Chart
control.
BackSecondarvColor
Gets or sets the secondary color of the chart backgrolUld.
BindingContext Gets or sets tl1e BindingContext for the control.
BorderColor This API supports the product infrastructure and is not intended lo be
used directly from your code. Gets or sets the color of the chart border.
BorderDashStyle
Gets or sets the style of U1e border.
Bo rderLineColor Gets or sets the color of the border line.
BorderLineDashStyle Gets or sets the style of the border line.
BorderLineWidth Gets or sets the \Vidtl1 of the border fu1e.
BorderSkin Gets or sets a BorderSkin object. which provides border skin
functionality for the Chart control.
BorderWidth This API supports tl1e product infrastructure and is not intended to be
ltsed directly from your code. Gets or set s the "'tidth of the chart border.
344 I PowerShell Studio - A Comprehensive Guide
Bottom Gets the distance, iu pixels, benveen the botton1 edge of the control and
the top edge of its co11tainer's client area.
Bounds Gets or sets the size and Location of the control including its nonclient
elements, in pixels, relative to the parent control.
BuildNumber Tllis API supports the product i1lfrastn1cture and is not intended to be
used direcUy from your code. Gets U1e build number of U1e Cliart
control.
CanEoablelme Gets a value indicating \Vhether the ImeMode property can be set to an
active value, to enable 1ME support.
Can Focus Gets a value indicating \Vhetber the control can receive focus.
CanRaiseEveots Detennines if events can be raised on t11e control.
Can Select Gets a value indicating whether the control can be selected.
Capture Gets or sets a value indicating \Vbether tbe control has captured the
111ouse.
Cau sesValidation Gets or sets a value indicating whether the control causes validation to
be performed on any controls that require validation \Vhen it receives
focus.
ChartAreas Gets a read-only ChartAreaCollection object that is used to store
CbartArca objects.
ClientRectaogle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height and width of the client area of the control.
CompanyName Gets the name of the company or creator of the application containing
the control.
Container Gets the IContainer that contains the Component.
ContainsFocus Gets a value indicating ' vhether the control, or one of its cllild controls,
currently has the iJ1put focus.
ContextMenu Gets or sets the shortcut menu associated \.Vilh the control.
ContextMenuStrip Gets or sets the ContextMenuStrip associated \vitl1 tllis control.
Controls Gets the collection of controls contained ,;vithin the control.
1
Created Gets a value indicating whether tl1e control has been created.
CreateParams Gets a CreateParan1s on the base class \Vhen creating a \Vindo,v.
Cursor Gets or sets the cuJsor lhat is displayed \Vhe11 the n1ouse pointer is over
the control.
DataBindings Gets the data bindings for the control.
DefaultCursor Gets or sets the default ctrrsor for tl1e control.
DataManipulator Gets a DataManipulator object that provides methods and properties
that handle data.
DataSource Gets or sets the data source for the Chart object.
DefaultimeMode Gets t11e default Input Method Editor (IME) mode supported by this
control.
DcfaultMargin Gets the space. in pixels, that is specified by default benveen co11trols.
DefaultMa1imumSize Gets the length and height, in pL'{els. that is specified as U1e default
maximUln size of a co11trol.
DefaultMioimu mSize Gets the length and height in pLxels. that is specified as the default
1ni nin11rm size of a control.
DefaultPadding Gets the internal spacing, in pixels, of the contents of a control.
DefaultSize Gets the default size of the control.
PowerShell Studio - Reference Guide I 345
DesignMode Gets a value that indicates whether the Component is currently in design
n1ode.
DialogResult Gets or sets a val.ue that is returned to the pare11t fonn 'vhen the button
is clicked.
DisplayRectangle Gets the rectangle that represents the display area of the control.
Disposing Gets a value indicating ivhether the base Control class is in the process
of disposing.
Dock Gets or sets 'vhich control boiders are docked to its parent control and
detenniJ1es ho'v a control is resized 'vitl1 its parent.
DoubleBuffercd Gets or sets a value indicating "vl1ether this control should redra,;v its
surface using a secondary buffer to reduce or prevent flicker.
Enabled Gets or sets a value indicating 'vhether the control can respond to user
interaction.
Events Gets the list of event hru1dlers that are attached to Ulis Component.
Focused Gets a value indicating " hether the control has input focus.
Font Gets or sets the font of the text displayed by ll1e control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
Handle Gets the ivindo"' handle U1at the control is bound to.
HasChildren Gets a value indicating 'vhether the control contains one or n1ore child
controls.
Height Gets or sets the height of the control.
Images Gets or sets fue image that is displayed on a button control.
lmeMode This API supports the product infrast1ucture and is not intended to be
used directly from yom code. Gets or sets the Input Method Editor
(IME) 1node supported by this control. This property is not relevant for
this class.
ImeModeBase Gets or sets the IME mode of a control.
InvokeRequiretl Gets a value indicating 'vhellier the caller n1ust call an invoke method
when making method calls to the control because the caller is on a
different thread than the one the control 'vas created on.
IsAccessible Gets or sets a value indicating 'vhether the control is visible to
accessibility applications.
IsDisposed Gets a value indicating ':vhelher the control has been disposed of.
IsHandleCreated Gets a value indicating whether the control has a handle associated \ViU1
it.
IsMirrored Gets a value indicating whether the control is n'rirrored.
IsSoftSbadOlVS Gets or sets a flag that detennines if a smootll gradient is applied when
shado,vs are dra,v11
LayoutEngine Gets a cached insta11ce of the control's layout engine.
Left Gets or sets the distance, ill pi~els between the left edge of the control
and the left edge of its container's client area.
Legends Gets or sets a LegendCollectior1 tliat stores all Legend objects 11Sed by
the Chart control
Location Gets or sets the coordinates of the upper-left comer of the control
relative to the upper-left comer of its container.
Margin Gets or sets the space beh~1 een co11trols.
MaximumSize Gets or sets the size that is the upper linlit that GetPreferredSize can
specify.
346 I PowerShell Studio - A Comprehensive Guide
MinimumSize Gets or sets the size that is the lower limit that GetPreferredSize can
specify .
Name Gets or sets the nan1e of the control.
Padding Gets or sets padding "vithin the control.
Palette Gets or sets the palette for the Chart control.
PaletteCustomColors Gets or sets an array of custom palette colors.
Parent Gets or sets the parent container of the control.
PreferredSize Gets the size of a rectangular area into "vhich the co11trol can fit.
Printing Gels a read-only PrintingMru1ager object used for printing a chart.
ProductName Gets U1e product name of the assembly containing the control.
ProductVersion Gets the version of the asse111bly containing the control.
RecreatingHandle Gets a value indicating \Vhelher the control is currently re-creating its
hru1dle.
Region Gets or sets the \Vindo\v region associated with t11e contTol.
RenderingD1>iX This API supports the product infrastn1cture and is not intended to be
used directly from your code. Gets or sets the 11orizontal resolution of
the Chart renderer.
Renderin gDpiY Gets or sets the vertical resolution of the Chart renderer.
RenderRightToLeft Obsolete.This property is now obsolete.
ResizeRedraw Gets or sets a value indicating whether the control redra,vs itself when
resized.
Right Gets the distance, in pi.'<els, benveen the right edge of the control and
the left edge of its container's client area.
RightToLeft Gets or sets a value indicating whether control's elements are aligned to
support locales using right-to-left fonts.
ScaleChild ren Gels a value that determines the scaling of child controls.
Scrializer Gets a ChartSerializer object Uiat is used for chart serialization.
Series Gets a SeriesCollection objecL which contains Series objects.
Sho"'FocusCues Gets a value indicating "vhether the control should display focus
rectangles.
ShowKeyboardCues Gets a value indicating v.rhether the user interface is in the appropriate
state to sho\v or hide keyboard accelerators.
Site Gets or sets the site of the co11trol.
Size Gets or sets the height aJld width of the control.
SuppressExceptions Gets or sets a flag that detennines \vhether non-critical exceptions
should be suppressed.
TabIndex Gets or sets the tab order of the control ,,,;thin its container.
TabStop Gets or sets a value indicating whether the user ca11 give the focus to
this control using the TAB key .
Tag Gets or sets the object that contains data about the control.
Text Gets or sets the text associated \Vith this control.
TextAntiAIiasingQu ality Gets or sets the TextA.11tiAliasingQuality type to use 'vhen applying
anti-aliasing to text.
Titles Gets or sets a TiUeCollection object that is used to store all Title objects
used by tl1e Chart control.
Top Gets or sets the distance in pixels. between the top edge of the control
ru1d the top edge of its container's client area.
PowerShell Studio - Reference Guide I 347
To1>LevelControl Gets the parent control that is not parented by another Windo\vs Fom1s
control. Typically, this is the outermost Form that the control is
contained in.
UseWaitCursor Gets or sets a value it1dicating \hether to use the vvait cursor for the
curre11t control and all child controls.
Visible Gets or sets a value indicating \Vhether the control and all its child
controls are displayed.
Width Gets or sets the width of the control.
WindowTarget This API supports the product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
CHECKBOX
PROPERTY DESCRIPTION
ActualHeight Gets the rendered height of this ele1nent.
ActualWidth Gets the rendered widtl1 of this element.
AJlowDrop Gets or sets a value iJ1dicating vvhether tlris element can be used as the
target of a drag-and-drop operation. This is a dependency property.
ArcAnyTouchcsC a1l tu red Gets a value that indicates 'vhether at least one touch is captured lo this
element.
AreAnyTouchesCapturedWithin Gets a value that indicates whether at least one touch is captured to this
ele1nent or to a11y child ele1nents in its visual tree.
ArcAnyTouchesDirectlyOver Gets a value that indicates 'vhether at least one tot1ch is pressed over this
element.
AreAnyToucbesOver Gets a value that indicates \Vhetber at least one toucl1 is pressed over tlris
element or any clrild elements in its visual tree.
Background Gets or sets a b1ush that describes tbe background of a control.
BindingGrou1l Gets or sets the BindingGroup that is 11sed for the element.
Bitm apEffect Obsolete.Gets or sets a bitinap effect U1at applies directly lo the rendered
content for this element. This is a dependency property.
Binn apEffectlnpu t Obsolete. Gets or sets an input source for the bitmap effect tl13t applies
directly to the rendered content for this element. Tlris is a dependency
property.
Bo1-clerBrush Gets or sets a brush that describes the border backgrotu1d of a co11trol.
Bo rderTh ickness Gets or sets the border tllickness of a control.
CacheModc Gets or sets a cached representation of the UIEle111ent.
ClickMode Gets or sets "hen the Click event occurs.
Clip Gets or sets U1e geotnetry used lo define the outline of the contents of an
ele1nent. This is a dependency prope1ty.
ClitlToBounds Gets or sets a value indicating whether to clip the content of this element
(or content coining from the child elements of this eleme11t) to fit into the
size of ll1e containing element. This is a dependency pl2P_erty.
Command Gets or sets the con1mand to invoke \Vl1en this button is pressed.
CommandBindings Gets a collection of ConunandBinding objects associated with this
element. A Com1nandBinding enables command handlingfor this
348 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
element, and declares ilie linkage between a command~ its events, and the
handlers attached by this element.
CommandParamcter Gets or sets the parameter to pass to the Conunand property.
Command Target Gets or sets the element on which to raise the specified corn1nand.
Content Gets or sets the conlent of a ContentContTol.
ContentStringFormat Gets or sets a composite string that specifies 11ow to fom1at U1e Content
property if it is displayed as a string.
ContentTemplate Gets or sets the data template used to display the content of U1e
ContentControl.
ContentTemp lateSelector Gets or sets a ten1plate selector that enables all application 'vriter to
provide custom template-selection logic.
Co ntextMenu Gets or sets the context n1enu element tliat should appear ,~henever the
context n1enu is requested through user interface (U1) from within tlris
ele1nent.
Cursor Gets or sets the cursor that displays "1hen the mouse pointer is over this
element.
Data Context Gets or sets the data conte:\.1 for an element " 1l1en it participates in data
binding.
Defau JtStyleKev
Gets or sets the key to use to reference the style for this control. 'vhe11
then1e styles are used or defined.
DepcndencyObjectTyJlC Gets the DependencyObjectType that \vraps the CLR type of this
instance.
DesiredSize Gets the size that this element computed during the measure pass of the
layout process.
Disflatchcr Gets the Dispatcher tlris DispatcherObject is associated \Vith.
Effect Gets or sets the bitniap effect to apply to U1e UIElement. This is a
dependency property.
Flo,, Direction Gets or sets the direction that text ru1d other user interface (UI) ele111ents
flo'v '~iU'lin any parent ele1nent t11at controls tl1eir .layout.
Focusable Gets or sets a value U1at indicates whether the element can receive focus.
This is a dependency property.
FocusVisuals tyle Gets or sets a property that enables customization of appearance, effects,
or other style characteristics that will apply to Uris elen1ent \vhen it
capttrres keyboard focus.
FontFamily Gets or sets the font faurily of the control.
FontSize Gets or sets the font size.
Fonts tretcb Gets or sets the degree to whicl1 a fo11t is condensed or e:x.'J)anded on the
screen.
FontStyle Gets or sets the font style.
FontWeight Gets or sets U1c 'veight or thickness of the specified font.
ForceCursor Gets or sets a value U1at indicates whether this Frame\vorkElement
should force the user interface (UI) to render the cuJsor as declared by U1e
Cursor property.
Foregrottod Gets or sets a brush tl1at descnbes the foregrotLnd color.
HandlesScrolling Gets a value that indicates 'vhether a control supports scrolling.
HasAnimatedPrope11ies Gets a value indicating \Vhether this element has any a11in1ated properties.
Has Content Gets a value that indicates \vheil1er the ContentConuol contains content.
HasEffectiveKe~boardFocus Gets a value that indicates ,;vhether the UIElement has focus.
Height Gets or sets tl1e suggested 11eigl1t of the element.
PowerShell Studio - Reference Guide I 349
PROPERTY DESCRIPTION
HorizontalAlignment Gets 01 sets the horizontal alignment characteristics applied to this
element when it is composed within a parent element. such as a panel or
items control.
HorizontaJContentAlignment Gets or sets the ho1izontal alignme11t of the conhol's conte11t.
InheritanceBehavior Gets or sets lhe scope limits for property value inheritance, resource key
loo.k11p. and RelativeSource FindAncestor lookup.
InputBindings Gels Lhe collection of input bindings associated \Vi.th t11is cle1nent.
In1>utScope Gets or sets the contex.1 for input used by this FrameworkElement.
IsArrangeVaJid Gets a value indicating whether the co1nputed size and position of child
elements in this element's layout are valid.
IsChecked Gets or sets \Vltelber the ToggleButton is checked.
IsEnabled Gets or sets a value indicating vvheU1er tllis elerne11t is enabled in the user
interface (Ul). Tllis is a dependency property.
lsEnabledCore Gets the value of the IsEnabled property.
IsFocused Gets a value that detennines \lvhether this element has logical focus. This
is a dependency property.
lsHitTestVisible Gets or sets a value that declares \Vhether this element can possibly be
retun1ed as a hit test result fron1 so1ne portion of its rendered content.
This is a dependency property.
IsInitialized Gets a value U1at indicates vvbether Lhis e.le1nent has been initialized.
either dl1ring processing by a XAML processor. or by e:\.rplicitly having
its Endlnit n1ethod called.
lslnputMethodEnabled Gets a value indicating \vhether an input method system. such as an Input
Metl1od Editor (Il\1E), is enabled for processing U1e input to this element.
IsKeyboardFocused Gets a value indicating \Vhether tllis ele1nent has keyboard focus. Tllis is
a dependency property.
IsKe, 1boardFocu sWithin Gets a value indicating \vl1ether keyboard focus is anyvvhere \\rithin the
element or its visual tree child elements. This is a dependency property .
IsLoaded Gets a value that indicates vvhether this e.le1nent has been loaded for
presentation.
IsManipulationEnabled Gets or sets a value that indicates whether manipulation eve11ts are
enabled on this UIElen1ent.
lsMeasu reValid Gets a value indicati11g whether the cu1Tent size returned by layout
measlrre is valid.
lsMouseCapmred Gets a value indicatil1g \Vhether the mouse is captured to tlris elen1ent.
This is a dependency property.
lsMouseCaptu reWithin Gets a value lJ1at detennines whether inouse capture is held by this
element or by child elements in its visual tree. Tllis is a dependency
property.
IsMouscDirectlyOver
Gets a value that indicates whether tl1e position of the mouse pointer
corresponds to hit test results. which take element compositing into
account. This is a dependency property.
lsMotiseOver Gets a value indicating whether the mouse pointer is located over tlris
element (including child elements in the visual tree). This is a
dependency property.
lsPressed Gets a value that indicates whether a ButtonBase is c1trrently activated.
lsSealed Gets a value that indicates \;vbether this instance is c1uTently sealed (read-
only).
350 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
IsS tylusC aptured Gets a value indicating "vhether the stylus is captured by this element.
This is a dependency property.
IsStyJusCaptu_reWithin Gets a value that detem1ines whether stylus capttrre is held by this
e1e111ent, or an element \vithiJ.1 the ele1ne11t bounds and its visual tree. This
is a dependency property.
lsStvlu
sDi rectlyOver
Gets a value that indicates \vhether the stylus position co1Tesponds to hit
test resltlts. \vhich take element compositing into accoWlt. This is a
dependency property.
lsStylusOvcr
Gets a value indicating whether the stylus cursor is located over this
elen1ent (including visual child ele1nenls). This is a dependency property.
IsTabSto1> Gets or sets a value that indicates whether a control is included in tab
navigation.
IsTllreeState Dete1nrines \hether the control suppo1ts two or three states.
IsVisible Gets a value indicating whether this element is visible it1 the user
interface (Ul). This is a dependency property.
Language Gets or sets localization/globalization language illfo11natio11 that applies
to an ele1nent.
LayoutTransform Gets or sets a graphics transformation that should apply to this element
when layout is performed.
Logical Child rcn Gets an entunerator to the content control's logical child elements.
Margin Gets or sets the outer inargin of an element.
MaxHeight Gets or sets the ina~1num height constraint of the element.
MaxWidth Gets or sets the maximum '""idtb constraint of the element.
MinHeigbt Gets or sets t11e mini1nm11 height constraint of the elen1ent.
MinWidth Gets or sets the m.i:nilnmn width constraint of the element.
Name Gets or sets the identifying name of the element. The naine provides a
reference so that code-behind, such as event handler code. can refer to a
inark-up element after it is consti11cted duiit1g processing by a XAM1.,
processor.
Opacity Gets or sets the opacity factor applied to the entire UIEle1nent when it is
rendered in tl1e user interface (Ul). This is a dependency property.
OpacityMasi{ Gets or sets an opacity mask, as a Bn1sl1 implementation that is applied to
any aJpha-cliannel 1nasking for the rendered content of tltis ele1nent. This
is a dependency property.
OveITidesDefauJtStyle Gets or sets a value that indicates whether tltis ele1nent incorporates sty le
properties from theme styles.
Padding Gets or sets t11e padding inside a control.
Parent Gets the logical pare11t element of this element.
Persistld Obsolete.Gets a value that uniquely identifies this element.
RenderSize Gets (or sets, but see Remarks) the final render size of tltis element.
RenderTransform Gets or sets transform information that affects the rendering position of
this elen1e11t. This is a dependency property.
RenderTransform Origin Gets or sets the center point of any possible render transfonn declared by
RenderTransfonn. relative to U1e bounds of the elen1en.t. This is a
dependency property.
Resources Gets or sets the locally-defined resource dictionary .
Sna1>sT0DevicePixels Gets or sets a value that detem1ines \Vhether rendering for this ele1nent
should use device-specific pixel settings during re11dering. This is a
dependency property.
PowerShell Studio - Reference Guide I 351
PROPERTY DESCRIPTION
Style
Gets or sets the style used by this element '''hen it is rendered.
StJlu sPluglns Gets a collection of all stylus plug-in (custon1ization) objects associated
\vith this ele111ent.
Tab Index Gets or sets a value that determines the order in which elements receive
focus when tl1c user navigates Ulfough controls by using the TAB key.
Tag Gets or sets an arbitrary object value that can be used to store custom
infonnation about this ele1nent.
Template Gets or sets a control template.
TemplatedParent Gets a reference to the template parent of this element. This property is
not relevant if the ele1nent was not created through a template.
ToolTip Gets or sets the tool-tip object that is displayed for this element in the
user interface (UT).
TouchesCaptured Gets all toucl1 devices tlIBt are captured to this element.
TouchesCaptu redWithin Gets all touch devices that are capluTed to this element or any child
elements in its visual tree.
TouchesDirectlyOver Gets all touch devices that are over this element.
TouchesOvcr Gets all touch devices that are over this eleinent or auy child ele1nents in
its visual tree.
T rj ggers Gets the collection of triggers established directly on this eleme11t or in
child ele1nents.
Uid Gets or sets tl1e turique identifier (for localization) for Uris element. This
is a dependency prope1ty.
UseLayoutRounding Gets or sets a value that indicates whether layout rounding should be
applied to this element's size and position during layout.
VerticaJAJignmeut Gets or sets the ve1tical alig111nent characteristics applied to tllis ele1nent
\Vben it is coniposed \Vithin a parent elen1ent such as a panel or ite111s
control.
VerticalContentAlignment Gets or sets U1e vertical alignment of the control's content.
Visibility Gets or sets the user i11terface (UT) visibility of this elen1enl. This is a
dependency property.
VisuaIBitmapEffect Obsolete. Gets or sets the BitmapEffect value for the Visual.
VisualBitmapEffectlnput Obsolete. Gets or sets the Bit:JnapEffectlnput value for the Visual.
PROPERTY DESCRIPTION
-------
VisuaJTextRenderingMode Gets or sets the TeA-1RenderingMode of the Visual.
Visual Transform Gets or sets the Transform value fo r the Visual.
VisualXSnappingGuidelines Gets or sets the x-coordinate (vertical) guideline collectio11.
VisualYSnap11ingGuidelines Gets or sets the y-coordb.1ate (horizontal) guideline collection. ------<
Width Gets or sets tl1e width of the element.
CHECKEDLISTBOX
AccessibilityObject
. - .
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets the default actio11 desc1iption of the control for use by
accessibility client applications.
AccessibleDescription Gets or sets the descriptio11 of the control used by accessibility clie11t
applications.
AccessibleName Gets or sets the nan1e of the control used by accessibility client
applications.
AccessibleRole Gets or sets the accessible role of the control
Allo,vDrop Gets or sets a value indicating whetl1er the control can accept data that
tl1e user drags onto it.
Allo,vSelection Gets a value indicating \Vhether the ListBox currently enables
selection of list iten1s.
Anchor Gets or sets the edges of the container to which a control is bound and
detemlines how a control is resized \ith its parent.
AutoScrollOffset Gets or sets where this control is scrolled to in ScrollControllnto Vie\.v.
Auto Size This API suppo11s the product infrastructure and is i1ot intended to be
used directly fro111 your code. This prope11y is not releva11t for this
class.
BackColo.r Gets or sets the backgTound color for the control.
Bacl<groundlmage This API supports the product infrastructlrre and is 11ot intended to be
used directly from your code. This property is not relevru1t to this
class.
BackgroundlmageLayout This API supports the product infrastructure and is i1ot intended to be
used directly from your code. Gets or sets the background image
layout for a ListBox as defined in the ImageLayout en1uneration.
BindingContext Gets or sets the BindingContext for the control.
BorderStyle
Gets or sets the type of border that is drawn around tl1e ListBox.
Bottom Gets the distance, in pixels, between tJ1e botto1n edge of the control
and the top edge of its container's client area.
Bounds Gets or sets the size and location of the control including its nonclient
elements, in pixels, relative to the parent control.
CanEnablelme Gets a value indicating \V hether the lmeMode property can be set to an
active value, to enable IlvlE support.
CanFocus Gets a value indicating whether the control cai1 receive focus.
CanRaiseEvents Determines if events can be raised on the control
Can Select Gets a value indicating "vhether the control can be selected.
PowerShell Studio - Reference Guide I 353
Capture Gets or sets a value indicating \Vhether the control has captured the
1nouse.
CausesValidation Gets or sets a value indicating \Vhetber the control causes validation to
be performed on any controls that require validation \vben it receives
focus.
Checkedlndices Collection of checked indexes in tllis CheckedListBox.
Checkeditems Collection of checked items in this CJ1eckedListBox.
CbcckOoCHck Gets or sets a value indicating \Vhether the check box should be
toggled \hen an ite111 is selected.
ClieotRectan gle Gets the Iectangle that represents the client area of the control.
C lieotSize Gets or sets the height and \Vidth of the client area of the control.
ColumnWidth Gets or sets the \Vidth of colmnns in a multicoJwnn ListBox.
Com 1>an~rN ame Gets the 1ian1e of the company or creator of the application containing
the control.
Container Gets the !Container that contains the Component.
Contain,SFocus Gets a value indicating \vhether the controL or one of its child
controls. currently has tl1e input focus.
CootextMenu Gets or sets the shortcut menu associated with the control.
ContextMenuStrip Gets or sets t11e ContextMenuStrip associated \Vith Olis control.
Controls Gets the collection of co11trols contained 'vithin the co11trol.
Created Gets a value indicating \vhetber the control has been created.
CreateParams Gets the required creation parameters \Vhen the control handle is
createcl
Cursor Gets or sets tJ1e cursor that is displayed when the mouse pointer is
over the control.
Custom Tab Offsets Gets the \Vidth of the tabs bet,veen the items in the ListBox.
DataBindings Gets the data bindings foI the control.
DataManager Gets the CurrencyManager associated with this control.
DataSourcc Gets or sets the data soruce for the control.
Defau ltCu r so r Gets or sets the default cursor for the control.
DefaultlmeMode Gets the default I11put Method Editor (IME) mode supported by the
control
DefaultMargin Gets the space. in pixels. that is specified by default between controls.
DefaultMaximumSize Gets U1e lengU1 and height in pixels, that is specified as tJ1e default
niaxitnun1 size of a control.
DefaultMinimumSize Gets the lengtl1 and heighL in pixels, that is specified as the default
rninimum size of a control.
DefaultPadding Gets the internal spacing. in pL'{els. of the contents of a control.
DefaultSize Gets the default size of the control.
DesignMode Gets a value tl1at indicates \.Ybether the Co1nponent is currently in
design mode.
DisplayMember Gets or sets a string that specifies a property of the objects contained
in tl1e list box ~r bose conte11ts you \Vant to display.
DisplayRectangle Gets the rectangle that represents tl1e display area of the control.
Disposing Gets a value indicating \Vhether the base Control class is in tl1e process
of disposing.
Dock Gets or sets which control borders are docked to its parent control and
deten1rines how a control is resized ~itl1 its parent.
354 I PowerShell Studio - A Compre he nsive Guide
DoubleButfered Gets or sets a value indicating whether th.is control should redra\v its
surface using a secondary buffer to reduce or prevent flicker.
DralvMode This API supports the product infrastn1cture and is not intended to be
used directly from your code. Gets a value indicating the mode for
drawing elements of the Cl1eckedListBox. This property is not
relevant to tllis class.
Enabled Gets or sets a vaJue indicating Vi'hether tl1e control can respond to user
interaction.
Events Gets the list of event handlers that are attached to this Co1nponent.
Focused Gets a value indicating \hether the co11trol has input focus.
Font Gels or sets the font of the text displayed by the control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
Format.Info Gets or sets the IFormatProvider tl1at provides custom formatting
behavior.
ForrnatString Gets or sets the fom1at-specifier c11aracters that indicate ho' v a value is
to be displayed.
FormattingEnabled Gets or sets a value indicating '1Yhether fonnatting is applied to the
DisplayMen1ber property of tl1e ListControl.
Handle Gels the window handle t11at the control is bound to.
Has Children Gets a value indicating \Vhether the control contains one or more child
controls.
Height Gets or sets the height of tl1e control.
HorizontaJExtcnt Gets or sets the \vidth by 'vhich the horizontal scroll bar of a ListBox
can scro.ll.
HorizontalScrollbar Gets or sets a value indicating "\\'hether a horizontal scroll bar is
displayed in tl1e control.
ImeMode Gets or sets the Input Method Editor (IME) mode of the control.
ImeModcBase Gets or sets the IME mode of a control
IntegralHeigbt Gets or sets a value indicating \hether the control should resize to
avoid showing partial items.
InvokeRequired Gets a value indicatingwhetl1er the caller must call an invoke met11od
when making method calls to the control because t11e caller is on a
different Urread lhan the one the control \Vas created on.
IsAccessible Gets or sets a value indicating \\'heU1er the control is visible to
accessibility applications.
lsDisposed Gets a value indicating \Vhether the control has been disposed of.
lsHandleCreated Gets a value indicating \vhether the control bas a handle associated
witl1 it.
lsMirrored Gets a value indicating whether tl1e control is mirrored.
ltemHeight Gets the height of the item area.
Items Gets the collection of ite1ns in this CheckedListBox.
LayoutEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the dista11ce. in pixels. bet'1veen the left edge of the control
and the left edge of its container's client area.
Location Gets or sets the coordinates of the upper-left corner of the control
relative to the upper-left comer of its container.
Margin Gets or sets U1e space bet1veen controls.
PowerShell Studio - Reference Guide. I 355
MaximumSize Gets or sets the size that is the upper lirnit that GetPieferredSize can
specify.
MinimumSize Gets or sets the size that is tl1e lo,ver limit that GetPreferredSize can
specify.
MultiColu mo Gets or sets a value indicating whether the ListBox supports multiple
coln1nns.
Name Gets or sets the name of the control.
Padding Gets or sets padding within the CheckedListBox. This property is not
relevant to this class.
Parent Gets or sets the pare11t container of the control.
Pret'erredHeight Gets the combined heigl1t of all items in the ListBox.
PreferredSize Gets the size of a rectangular area into 'tV.hich the control ca11 fit.
ProductName Gets the product naine of the assembly contailting the control.
ProductVersion Gets the version of the assembly containing the control.
Recreatin gHancUe Gets a value indicating \hether the contTol is currently re-creating its
handle.
Region Gets or sets the \Vil1dovv region associated with the control.
RenderRightToLeft Obsolete.This property is no'v obsolete.
ResizeRedraw Gets or sets a value indicating wl1ether the control redraws itself when
resized.
Right Gets the distance, in pixels, between the right edge of the control and
the left edge of its container's client area.
RightToLeft Gets or sets a value indicating whether text displayed by the control is
displayed from right to left.
ScaleChildren Gets a value that detennines the scaling of child controls.
ScrollAl,vaysVisible Gets or sets a value indicating whether the ve1tical scroll bar is sho,;vn
at all times.
Selectedlndex Gets or sets the zero-based index of the currently selected iten1 in a
ListBox.
Selectedlnclices Gets a collection that contains the zero-based indexes of all cu1Tently
selected items in the ListBox.
Selectedltem Gets or sets the currently selected ite1n in the ListBox.
Selected Items Gets a collection containing the currently selected ite1ns in the
ListBox.
SelectedValue Gets or sets tl1e value of the me111ber property specified by tl1e
V alueMember property.
Selection Mode Gets or sets a value specifying tl1e selection mode.
Sho'vFocusCues Gets a value indicating \.Vl1ether the control shottld display focus
rectangles.
ShowKeyboard Cues Gets a value indicating whether the user interface is in the approp1iate
state to sho,;v or hide keyboard accelerators.
Site Gets or sets the site of the control.
Size Gets or sets the he~ght and width of the control.
Sorted Gets or sets a value indicating whether the items in the ListBox are
sorted alphabetically.
Tab Index Gets or sets the tab order of tl1e control within its container.
TabStop Gets or sets a value indicating whether the user can give the focus to
this control using the TAB key.
356 I PowerShell Studio - A Comprehensive Guide
I
Tag Gets or sets the object that contains data about the control.
Text Gets or searches for the teA1 of the currently selected item i11 the
ListBox.
ThreeDCheckBoxcs Gets or sets a value indicating whether the check boxes have a
Syste1n.Windows.Fonns.ButtonState of Flat or Normal.
Top Gets or sets the distance. in pixels, between the top edge of tl1e control
and tl1e top edge of its container's client area.
Toplndex Gets or sets the index of the first visible item in the ListBox.
TopLeveJControl Gets the parent control that is not parented by another Windo,vs
Forms control. Typically, this is the outermost Form that the control is
contained in.
UseCompatibleTextRendering Gets or sets a value that determines whether to use the Graphics class
(GDI+) or the TextRenderer class (GDI) to render text.
UseCustomTab Offsets Gets or sets a value indicating whether the ListBox recognizes and
eJ\'J)ands tab characters when it dra\vs its strings by using tl1e
CustomTabOffsets integer array.
UseTabStops Gets or sets a value indicating whether the ListBox can recognize and
eA'}Jand tab characters \vhen drawing its strings.
UseW aitCursor Gets or sets a value indicating whether to ttse t11e \.Vait cursor for the
current control and all child controls.
ValucMember Gets or sets a string that specifies the property of the data sou1ce fron1
which to draw the value.
Visible Gets or sets a value indicating 'vhetber the control and all its clllid
controls are displayed.
Width Gets or sets the vvidth of the control.
Window Target This API supports tl1e product infrastruct11re and is not intended to be
used directly from your code. This property is not relevant for this
class.
COLORDIALOG
AIJowFullOpen
Gets or sets a value indicating whether tl1e user can use the dialog box to define custom
colors.
AnyColor Gets or sets a value iI1dicating vvhether the dialog box displays all available colors in the set
of basic colors.
CanRaiseEvents Gets a value indicating whether the component can raise an event.
Color Gets or sets the color selected by the user.
Container Gets the !Container that contains the Component.
Custom Colors Gets 01 sets the set of custom colors shown in the dialog box.
DesignMode Gets a value that indicates whetl1er the Component is cu1Te11tly in design inode.
Events Gets the list of event ha11dlers that are attached to this Co111ponent.
Full Open Gets or sets a value indicating whether tl1e controls used to create custo1n colors are visible
when tlle dialog box is opened
Instance This API supports the product infrastructure and is not intended to be used diJectly fro1n
your code. Gets the m1derlying window instance handle (HINSTANCE)
PowerShell Studio - Reference Guide I 357
r
Options This API s11pports the product infrastmchue and is not intended to be used directly from
your code. Gets values to initialize the ColorDialog.
SholvHel1> Gets or sets a value indicating \Vhetl1er a Help button appears in the color dialog box.
Site Gets or sets the ISite of tl1e Component.
SolidColorOnly Gets or sets a value indicating whether the dialog box will restrict users to selecting solid
colors only.
Tag Gets or sets an object tl1at contains data abot1t the control.
COMBO BOX
ContcxtMenu Gets or sets the context n1enu element that sl1ould appear whenever the
context men11 is req11ested through user interface (UI) fro1n within this
element.
Cursor Gets or sets the cursor that displays when the 1nouse pointer is over this
element.
Data Context Gets or sets the data context for an eleme11t when it paiticipates in data
binding.
DefaultStyleKey
Gets or sets the key to use to reference the style for this control, when
theme styles are used or defined.
DependencyObjectType Gets the DependencyObjectType that wraps the CLR type of this instance.
DesiredSize Gets the size that this eleme11t co1nputed duriI1g the measure pass of the
layout process.
Dis1Jatcher Gets the Dispatcher this Dispatcl1erObject is associated \vith.
DisplayMcm herPath Gets or sets a path to a value on the source object to serve as the visual
representation of the object.
Effect Gets or sets the bitmap effect to apply to the UIElen1ent. This is a
dependency property
FlowDirection Gets or sets the direction that tex1 and other user interface (UI) elements
flow \.Vithin any parent elen1ent tl1at controls their layout.
Focusable Gets or sets a value that indicates whether the element can receive focus.
This is a dependency property
FocusVisualStyle Gets or sets a property that enables customization of appearance, effects,
or other style characte1istics tl1at will apply to this ele1nent when it
captures keyboard focus.
FontFamily Gets or sets the font fanlily of the control.
FontSize Gets or sets the font size.
FontStretc.h Gets or sets the degree to which a font is condensed or expanded on the
screen.
FontStyle Gets or sets the font sty le.
FontWeight Gets or sets the weight or thickness of the specified font.
ForceCursor Gets or sets a value that indicates whether this Fra1nework.Ele1nent should
force the user interface (U1) to render the cursor as declared by the Cursor
property.
Foreground Gets or sets a bn1sh that describes the foreground color.
GroupStyle Gets a collection of GroupStyle objects that define the appearance of each
level of groups.
Gron pStyleSelector Gets or sets a nlethod that enables you to provide custo1TI selectio11 logic
for a GroupStyle to aQply to each group in a collection.
HandlesScrolling Gets a value that indicates 'vl1ether a combo box supports scrolling.
(Overrides Control.HandlesScrolling.)
HasAnim ateclP roperties Gets a value indicating whetl1er this element has any anin1ated properties.
HasEffecti.veKeyboardF ocu s Gets a value that indicates wl1ether the ComboBox bas focus. (Ovenides
UIElement.HasEffectiveKeyboardFocus.)
Hasltems Gets a value tl1at indicates wl1ether the Items Control contains items.
Height Gets or sets the suggested heigl1t of the element.
PowerShe ll Studio - Refere nce G uid e I 359
is currently open.
IsEditable Gets or sets a value that enables or disables editing of the te~1 in text box
of the ComboBox.
ls Enabled Gets or sets a value indicating \Vhether this element is enabled in the user
interface (UI). This is a dependency property
IsEnabledCore Gets a value that becon1es U1e return value of IsEnabled in derived classes.
IsFocused Gets a value tl1at determines whether tllis ele1nent has logical focus. Tltls
is a dependency propercy
IsGrouping Gets a value that indicates \Vhether U1e co11trol is using grouping.
IsIDtTestVisible Gets or sets a value that declares \Vbether this ele1ne11t can possibly oe
ret11med as a hit test result fro111 son1e portion of its rendered co11tent. This
is a dependency property
Islnitialized Gets a value that indicates \Vhether this elen1ent has been initialized, either
during processing by a XAML processor. or by e:'\.'J)licitly having its
Endlnit method called.
Isln1)utMethodEnabled Gets a valu.e indicating 'vhelher an input metl1od syste~ such as an Input
Method Editor (IME) is enabled for processing the input to this element.
lsKcyboardFocu scd Gets a alue indicating whetl1er this element bas keyboard focus. This is a
dependency property
lsKeyboardFocusWithin Gets a value indicating whether keyboard focus is an)"vhere ''rithin the
element or its visual tree clrild ele1nents. This is a dependency property
lsLoaded Gets a value that indicates 'vhetl1er tltis ele1nent has been loaded fo r
presentatioJL
IsManipulationEoab led Gets or sets a value tl1at indicates ' vbetl1er 1nanipulation events are
enabled on this UIElement
lsMeasu reValid Gets a value indicating \\hether the current size returned by layout
n1easure is valid.
lsMouseCaptured Gets a value indicating whether the mouse is captured to this element.
This is a dependency property
IsMouseCaptu reWithin
IsMouseDirectlyOver
Gets a value tl1at indicates whether the position of the mouse pointer
corresponds to hit test results. which take element compositing into
account. This is a dependency property
Gets a value indicating whetl1er the rnouse pointer is located over this
eletnent (including cltild elen1ents in the visual tree). This is a dependency
property
360 I PowerShell Studio - A Comprehensive Guide
lsReadOnJy Gets or sets a value tl1at enables selection-only n1ode. in \Vhich tl1e
contents of the co1nbo box are selectable but not editable.
IsSealed Gets a value that indicates \Vhether this instance is currently sealed (read-
only).
lsSelectionBoxHighlighted Gets \Vbether the SelectionBoxltem is higltligbted.
IsS tylusCaptured Gets a value indicating \Vhether the stylus is captured by this element.
This is a depende11cy property
IsStylusCa1>tureWithin Gets a value Uiat detennines \vbether stylus capture is held by this
element. or an element within the elen1ent bounds and its visual tree. This
is a dependency property
lsStylusDirectlvOver
Gets a value that indicates \Nhether the stylus position corresponds to hit
test results. which take elen1ent compositing into account. This is a
dependency property
lsStylusOver
Gets a value indicati11g \vhether the stylus cursor is located over this
elen1ent (including visual child elements). This is a dependency property
IsSyochrooizedWithCurrentlte Gets or sets a value U1at in.dicates \V11eU1er a Selector should keep the
m Selectedlte1n synchronized \Vitb the current item in U1e Items property .
ls Tab Stop Gets or sets a value that indicates \vhether a control is included in tab
navigation.
IsTcxtSearchC aseSensitive Gets or sets a value that indicates whether case is a condition \Vhen
searchmg for items.
IsTeA-tSearchEnabled Gets or sets a value that indicates 'vhether Te~1Search is enabled on the
ItemsControl instance.
lsVisible Gets a value indicating vvhetber this element is visible in the user interface
(UI). Tllis is a dependency property
ItemBin din gGrou p Gets or sets the BindingGroup tl1at is copied to each ite1n in the
ItemsControl.
ltemContainer<rtnerator Gets tl1e ItemContainerGenerator tl1at is associated \' ith the control.
1
ltemCootainerStyle Gets or sets the Style that is applied to the container element generated for
each item.
ItemContainerSt)1leSelector Gets or sets custo1n sty le-selection logic for a style U1at cru1 be applied to
each generated container element.
Items Gets the collection used to generate the content of the ItemsControl.
ItemsPanel Gets or sets the template that defines the panel that controls the layout of
items.
ItemsSource Gets or sets a collection used to generate the content of the ItemsControl.
ltemStriogFormat Gets or sets a con1posite string U1at specifies ho\v to fom1at the itenlS in
the Iten1sControl if they are displayed as slril1gs.
Item Template Gets or sets the DataTemplate used to display each iten1.
Item Tern t>lateSelecto r Gets or sets the custom logic for choosing a te1nplate used to display each
item
Language Gets or sets localization/globalization language infonnation that applies to
an ele1nenl.
LayoutTransform Gets or sets a graphics transfon11ation t11at sho1tld apply to this element
\Vhen layout is performed.
LogicaJCbildren Gets an enumerator for tJ1e logical child objects of the ItemsControl
object.
PowerShell Studio - Reference Guide. I 361
StaysOpenOnEdit Gets or sets whether a ComboBox tl1at is open and displays a drop-down
contTol will re1nain open vvhen a user clicks the Te~1Box.
Style Gets or sets the style used by this element when it is rendered.
StylusPluglns Gets a collection of all stylus plug-i11 (customization) o~jects associated
'vith this elen1ent.
Tablndex Gets or sets a value that detennines the order in \hi.ch elements receive
focus when the user navigates through controls by using the TAB key.
Tag Gets or sets an arbitrary object value that can be used to store custom
information about this elen1ent.
Template Gets or sets a control ten1plate.
Tem11latedParent Gets a reference to the template parent of this element. This property is
not relevant if the element was not created through a template.
Text Gets or sets the text of the currently selected ite1n.
ToolTi11
TouchesCaptured Gets all touch devices that are captured to this element
TouchesCapturedWithin Gets all touch devices that are captured to this element or any cllild
elements i11 its visual tree.
ToucbesDirectlyOver Gets all touch devices that are over tlris element
TouchesOver Gets all touch devices that are over tlris ele1nent or any child ele1nents in
its visl1al tree
Gets the collection of triggers established directly on tills element, or in
child elements.
Uid Gets or sets the tmique identifier (for localization) for tlris ele1nent. Tlris is
a dependency property.
U seLayoutRounding Gets or sets a value that indicates wl1ether layout rounding should be
applied to tlris ele1nent's size a11d position during layout.
VerticalAJign ment Gets or sets t11e vertical alig1unent characteristics applied to this element
when it is composed within a parent ele1nent sucl1 as a panel or items
control.
VerticalContentAlignment Gets or sets tl1e vertical alig1unent of the conttol's content.
Visibility Gets or sets the user interface (UI) visibility of this element. Tlris is a
dependency p..!Q,Perty
VisuaJBitmapEffect Obsolete.Gets or sets the BitmapE:ffect value for the Visual.
VisuaJBitmapEffectlnput Obsolete. Gets or sets the Bit11iapEffecth1put value for the Visual.
Visu aJBitmapScalin gMode Gets or sets the BitniapScalingMode for the Visual.
VisualCacheMode Gets or sets a cached representation of the Visual.
VisuaJChildrenCount Gets tl1e number of visual clrild ele111ents within tlris elen1ent.
Visu alClearTypeHint Gets or sets tl1e ClearTypeHiut that determines bow ClearType is rendered
in the Visual.
VisualCli11 Gets or sets tl1e clip region of the Visual as a Geometty value.
VisualEdgeMode Gets or sets the edge mode of the Visual as an EdgeMode value.
VisualEffect Gets or sets t11e bitinap effect to apply to the Visual.
Visual Offset Gets or sets tl1e offset value of the visual object
PowerShell Studio - Reference Guide I 363
CONTEXTMENUSTRIP
AutoScrollPosition This API supports the product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
AutoSize Gets or sets a value indicatil1g whether the ToolStripDropDown
autornatically adjusts its size \Vhen the form is resized.
BackColor This API supports the product infrastn1cture and is not intended to be
used directly frorn your code. Gets or sets U1e backgrow1d color for tl1e
ToolStrip.
Baclwoundlmage Gets or sets the background image displayed in the control.
BackgroundlmageLayou t Gets or sets the background image layoltt as defined irn. the lmageLayout
enumeration.
BindingContext Gets or sets the binding contex1 for the ToolStrip.
Bottom Gets the distance, in pi'{els: between the bottom edge of the control and
the top edge of its container s client area.
Bounds Gets or sets the size and location of the control including its nonclient
elements, in pL"els, relative to the parent control.
CanEnablelme Gets a value indicating whether the ImeMode property can be set to an
active value, to enable IME support.
CanFocus Gets a value i11dicating whether the control can receive focus.
Can Overflow This API supports the product infrastructure and is not intended to be
used directly from yotrr code. Gets or sets a value indicating 'vhether the
items in a ToolStripDropDo\vn can be sent to an overflo'\v menu.
CanRaiseEvents Determ.ines if events can be raised on the control.
CanSelect Gets a value indicating whether tl1e control can be selected.
Ca)lture Gets or sets a value indicating \.Vhether tl1e control has capt1rred the
mouse.
CausesValidation Gets or sets a value indicating \.vhether the ToolStrip causes validation to
be performed on any controls that require validation \.Vhen it receives
focus.
ClicntRectangle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height and width of the client area of the control
CompanyName Gets the name of the company or creator of the application containing
the control.
Container Gets the IContainer that contains the Con1ponenl.
ContainsFocus Gets a value indicati11g whether the control. or one of its cJlild controls,
currently has the input focus.
ContextMeou This API supports the product infrastn1.cture and is not intended to be
used direcUy from your code. This property is not relevru1t to this class.
ContextMenuStrip This API supports the product infrastn1cture a11d is not intended to be
used directly from your code. This property is not relevant to this class.
Controls This API supports tl1e product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
Created Gets a value indicating whether the control has been created.
CreateParams Gets paran1eters of a ne\v \Vindow.
Cursor Gets or sets the ctrrsor that is displayed \vhen the mouse pointer is over
the ToolStrip.
DataBindi.ngs Gets the data bindings for the control.
DefaultCu rsor Gets or sets tl1e default cursor for tJ1e control.
DefauJtDock Gets the docking location of the TooIStrip. indicating which borders are
docked to the co11tainer.
PowerShell Studio - Reference Guide I 365
TopMost Gets or sets a v alue indicating whether the form should be displayed as a
topmost form.
UseW aitCursor Gets or sets a value it1dicating whether to use the vvait cursor for the
current control and all child controls.
VerticalScroll This API supports the product infrastn1cture and is not intended to be
used directly from your code. This property is not relevant for this class.
Visible Gets or sets a value indicati11g \:vhether tl1e ToolStripDropDown is
visible or hidden.
VScroll Gets or sets a value indicating whether the vertical scroll bar is visible.
Width Gets or sets the \:vidth of the control.
Window Target This API supports the product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
ColumnHeadersBorderStvle
Gets the border style applied to the colunm headers.
ColumnHeadersDefauJtCeUS tvlc
Gets or sets the default colnn111 header style.
ColumnHeadersHcight Gets or sets the heigh~ in pixels, of the column headers ro\v
ColumnHeadersHeightSizeMode Gets or sets a value indicating \vl1ether tl1e height of the coltum1
headers is adjustable and whether it can be adjusted by the user
or is automatically adjusted to fit the contents of the 11eaders.
ColumoHeadersVisible Gets or sets a value indicating \Nhether tJ1e colu1m1 header TO\V
is displayed.
Columns Gets a collection tliat contains all the columns in the control.
CompanyName Gets the na1ne of tbe co1npany or creator of the application
contai ning the control.
Container Gets U1e !Container that contains tl1e Component. (Inherited
fron1 Co1nponent.)
ContainsFocu s Gets a value indicating v.rhether the control: or one of its child
controls, currently has the input focus.
ContextMenu Gets or sets the shortcut menu associated ' vith the control.
ContextMenuStrip Gets or sets U1e Conte>.1.MenuStrip associated \vith th.is control.
Controls Gets the collection of controls contained within the control.
Created Gets a value indicating \-vhether the control has been created.
CreateParams Gets the required creation parameters \hen the control handle
is created.
CurrentCell Gets or sets the currently active cell.
CurrentCellAdd ress Gets the ro'v and colunm indexes of the currently active cell.
CurrentRo'v Gets the rO\ containing the current cell.
Cursor Gets or sets the c1usor that is displayed \-vhen the mouse pointer
is over the control.
DataBindings Gets 01e data bindings for the control.
DataMember Gets or sets the nan1e of the list or table i11 the data source for
\;vhich the DataGridVievv is displaying data.
DataSource Gets or sets the data source that the DataGridVie\v is displaying
data for.
DefaultCellStyle Gets or sets the default cell style to be applied to the cells in the
DataGridVie\v if no other cell style properties are set.
DefaultCursor Gets or sets the default cursor for the control.
Defau ltlmeMode Gets the default Input Method Editor (IME) mode supported by
the control.
DefaultMargin Gets the space. in pixels~ that is specified by default bet,veen
co11trols.
DefaultMaximumSize Gets the length and height, in pixels, that is specified as the
default 1naximttn1 size of a contro 1.
Defau ltMinimu mSize Gets t11e length and height, iJ1 pixels, that is specified as the
default ininimun1 size of a control.
DefaultPadding Gets the inten1al spacing, in pixels, of the contents of a control.
DefaultSize Gets 01e default initial size of tl1e control. (Overrides
Control.DefaultSize.)
DesignMode Gets a value that indicates \Vl1ether the Component is currently
in design mode.(lnherited from Con1ponent.)
DisplayRectanglc Gets the rectangle that represents the display area of the control.
(Ovenides Co11trol.DisplayRectangle.)
PowerShell Studio - Reference Guide. I 371
[
Disposing
Gets a value indicating whether the base Control class is in the
process of disposing.
Dock Gets or sets which control borders are docked to its parent
control and detennines how a control is resized with its parent.
DoubleBufferecl Gets or sets a value indicating whether this control should
redraw its surface using a secondacy buffer to reduce or prevent
flicker.
EditingControl Gets the control hosted by the current cell, if a cell with an
editing control is in edit inode.
EditingPanel Gets the panel that contains the EditingControl.
EditMode Gets or sets a value indicating ho'\ to begin editing a cell.
Enabled Gets or sets a value indicating whether the control can respond
to user interaction.
EnableHeadersVisu alSty.les Gets or sets a value indicating whether r0\\1 and column headers
use the visuaJ styles of tl1e user's c11rrent then1e if visual styles
are enabled for the application.
Events Gets the list of event handlers that are attached to this
Component. (Inherited from Component.)
FirstDis1>layed Cell Gets or sets the first cell currently displayed in the
DataGridVie,v; typically, this cell is in tl1e upper left con1er.
FirstDi.splayedScrollingColumnHiddenW Gets the vvidth of the portion of the column that is currently
idtb scrolled out of view ..
FirstDis1>layedScrollingColumnlndex Gets or sets the index of the colunm that is the first col1u1m
displayed on the DataGridVievv.
Fi rstDisplayedScrollingRowIndex Gets or sets the index of the row that is the first row displayed
on the DataGridView.
Focused Gets a value indicating vvhether the control has input focus.
Font Gets or sets the font of the te)..1: displayed by the DataGridVievv.
(Overrides Control.Font.)
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of tl1e DataGridView.
(Overrides Control.ForeColor.)
GridColor Gets or sets the color of the grid lines separating tl1e cells of the
DataG1idView.
Handle Gets tl1e window handle tliat the control is bom1d to.
Has Children Gets a value indicating whether tl1e control contains one or
more child controls.
Height Gets or sets tl1e heigl1t of the control.
Ho rizontalScrol lBar Gets the horizontaJ scroll bar of the control
HorizontalScrollingOffset Gets or sets the number of pixels by vvhich the control is
scrolled 11orizontally.
lmeMode Gets or sets the Input Method Editor (IME) lnode of the control.
lmeModeBase Gets or sets the IJ\1E mode of a control.
lnvokeRequired Gets a value il1dicating whether the caller must call an invoke
method whe11 making method calls to the control because the
caller is on a different thread than the one the control vvas
created on.
IsAccessible Gets or sets a vaJue indicating whether the control is visible to
accessibility ap_plications.
372 I PowerShell Studio - A Comprehensive Guide
TabStop Gets or sets a value indicating \Vhether the user cai1 give the
focus to this control using the TAB key.
Tag Gets or sets the object that contains data abot1t the control.
Text This API supports the product infrastructure and is not inte11ded
to be used directly fron1 yotu code. Gets or sets the text
associated with the control. (Overrides Control.Text.)
Top Gets or sets the distance, in pi.xels, between tl1e top edge of the
control and tl1e top edge of its container's client area.
To1>LeftHeaderCell Gets or sets the header cell located in the upper left corner of
the DataGridView control.
TopLevelControl Gets the parent control that is not parented by another Windo\.VS
Forms control. Typically, this is the outermost Form that the
control is contained in.
UserSetCu rso r Gets the default or user-specified value of the Cursor property.
UseWaitCursor Gets or sets a value indicating whether to use the wait cursor for
the current control and all child controls.
VerticalScrollBar Gets the vertical scroll bar of the control.
VerticalScrollingOffset Gets the nnmber of pLxels by which the control is scrolled
vertically.
VirtualMode Gets or sets a value indicating \.vl1ether you have provided your
O\.VO data-1nanagement operations for tl1e DataG1idView
control.
V.i sible Gets or sets a value indicating whether the control and all its
child controls are displayed.
Width Gets or sets the \.vidth of the co11trol.
Window Target This API supports the product infrastructure and is not intended
to be used directly from your code. This property is not relevant
for this class.
DATETIMEPICKER
PROPERTY DESCRIPTION
AccessibilityObject Gets the AccessibleObject assigned to the control.
Accessi.bleDefaultActionDescripti Gets or sets the default action description of the control for use by
on accessibility client applications.
AccessibleDescri1Jt.ion Gets or sets the description of the control used by accessibility clie11t
applications.
AccessibleN ame Gets or sets the name of the control used by accessibility client
applications.
Accessiblellole Gets or sets the accessible role of the control
Allo,vDro1J Gets or sets a value indicating whether the control can accept data that
the user drags onto it.
Anchor Gets or sets the edges of the container to which a control is bound and
detenni nes ho'\ a control is resized with its parent.
AutoScrollOffset Gets or sets where this control is scrolled to in ScrollControllnto Vie\.
PowerShe ll Studio - Refere nce Guide I 375
PROPERTY DESCRIPTION
Auto Size This API supports U1e product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
BackColor Gets or sets a value indicating the background color of the
DateTimePicker control. (Overrides Control.Back.Color.)
Backgroundlmage This API supports the product in:frastJ.ucture and is not ir1tended to be
used directly from your code. Gets or sets the background image for the
control. (Overrides Control.Backgroundlmage.)
Backgrou ndlmageLayout This API suppo1ts the product infrastructure and is not intended to be
used directly from y oUI code. Gets or sets the layout of the background
image of the DateTimePicker control.(Overrides
Control.Backgro1mdlmageLayout.)
BindingContext Gets or sets the B.indingContext for tl1e control.
Bottom Gets the distance, in pixels. benveen the bottom edge of tbe control and
the top edge of its container's client area.
Bounds Gets or sets the size and location of tl1e co11trol iI1cluding its nonclient
elements, in pixels. relative to the parent control.
CalendarFont Gets or sets the font style applied to the calendar.
CalendarForeColor Gets or sets the foreground color of the calendar.
CalendarMonthBackground Gets or sets the background color of the calendar n1ontb.
C alendarTitleBackColor Gets or sets tbe background color of the calendar title.
CalendarTitleForeColor Gets or sets the foregroru1d color of tbe calendar title.
CalcndarTrailin gForcColor Gets or sets the foreground color of the calendar t railing dates.
CanEnablelme Gets a value indicating whether the lmeMode property can be set to an
active value, to enable lME support.
CanFocus Gets a value indicating \vhether the control can receive focus.
CanRaiseEvents Detennines if e\rents can be raised on tbe control.
Can Select Gets a value indicating \Vhetber tbe control can be selected.
Capture Gets or sets a value indicating '"bether the control bas captured the
1nouse.
CausesValidation Gets or sets a value indicating \Vhether the control causes validation to be
perfom1ed on any controls that require validation \Vhen it receives focus.
Checked Gets or sets a value indicating \Vhether tl1e Value property has been set
\Vith a valid date/tin1e value and the displayed value is able to be
updated.
ClientRectangle Gets the rectangle that represents the client area of tlie control.
ClientSize Gets or sets the height and width of the client area of the control.
ComJJanyName Gets the name of the co1npa11y or creator of llie applicati.011 contairling
the control.
Container Gets the !Container that contains the Compo11ent. (Inherited from
Component.)
ContainsFocus Gets a value indicating 'vl1elher the control, or one of its child controls,
currently has the input focus.
ContextMenu Gets or sets the shortcut 1nenu associated witl1 the control.
ContextMenuStritl Gets or sets tl1e ContextMenuStrip associated 'vitb tllis control.
376 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
Controls Gets the collection of controls contained \:Vithin the control.
Created Gets a value indicating whether the control has been created.
CreateParams Gets the required creation parameters when the co11trol band.le is
created.(Overrides Control. CreateParams.)
Cmsor Gets or sets the cursor that is displayed when the mouse pointer is over
the co11tro l.
Custom.Format Gets or sets the custom date/time format string.
DataBindings Gets the data bindings for the co11trol.
DefaultCursor Gets or sets the default cursor for the control.
DefaultlmeMode Gets the default Input Method Editor (Thffi) mode supported by the
control.
DefaultMargin Gets the space, in pi,"{els, that is specified by default bet\tveen controls.
DefaultMaximumSize Gets the length and height, in pixels, that is specified as the default
maximum size of a control.
DefaultMinimumSize Gets the lengtl1 ai1d height, in pixels, that is specified as the default
nlinimtlffi size of a control.
DefaultPadding Gets the internal spacing, in pixels, of the contents of a control.
Defau It Size Gets the default size of the control. (Overrides Control.DefaultSize.)
DesignMode Gets a value that indicates whetl1er the Component is currently in design
mode.(lnherited from Component.)
DisplayRectangle Gets the rectangle that represents the display area of the control.
Dis1>osing Gets a value indicating whether the base Control class is in the process of
disposing.
Dock Gets or sets wltich control borders are docked to its parent control and
determines ho"v a control is resized \:Vith its parent.
DoubleBuffered This API supports the product infrastructure and is not intended to be
used directly from your code. Gets or sets a value indicating \:vhether the
control should redra"v its surface using a secondary buffer. Setting this
property has no effect on the DateTimePicker control. (Overrides
Co11trol.DoubleBuffered.)
DropDo,vnAlign Gets or sets the aligm11ent of the drop-down calendar on the
DateTitnePicker control.
Enabled Gets or sets a value indicating wl1ether the control can respond to user
interaction.
Events Gets the list of event handlers that are attached to this
Component. (Inl1e1ited fron1 Component.)
Focused Gets a value indicating whether the control has input focus.
Font Gets or sets the font of the text displayed by the control.
FontHeight Gets or sets the 11eight of the font of the control.
ForeColor This API supports the product infrastructure and is not iI1tended to be
used directly fJon1 yotlf code. Gets or sets the foreground color of the
DateTimePicker control. (Overrides Control.ForeColor.)
Format Gets or sets t11e fonnat of the date and tilne displayed in the control.
Handle Gets the window handle that the control is botmd to.
PowerShell Studio - Reference Guide I 377
PROPERTY DESCRIPTION
Has Children Gets a value indicating whether the control contains one or more child
controls.
Height Gets or sets the height of the control.
lmeMode Gets or sets the h1pt1t Method Editor (IME) mode of the control.
ImeModeBase Gets or sets the IME mode of a control.
Invol\.eRequired Gets a value indicating whether tl1e caller must call an invoke method
when making method calls to the control because the caller is on a
different thread than the one the control was created on.
IsAccessible Gets or sets a value indicating whether the control is visible to
accessibility applications.
IsDisposed Gets a value indicating whether the control has been disposed of.
IsHandleCreated Gets a value indicating whetl1er the co11tro1 has a 11andle associated with
it.
IsMirrored Gets a value indicating whether the control is mirrored.
Layou tEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the distance, in pixels, between the left edge of the control
and the left edge of its container's client area.
Location Gets or sets the coordi1iates of the upper-left con1er of the control relative
to the upper-left corner of its container.
Margin Gets or sets the space between controls.
Ma."\:Date Gets or sets the maximum date and tin1e tl1at can be selected in the
control.
Ma."timumDateTime Gets the maximtu11 date value allovved for the DateTi111ePicker control.
MaximumSize Gets or sets the size that is the upper lin1it that GetPreferredSize can
specify.
MinDate Gets or sets the mi11imu1n date and time that can be selected in the
control.
Minimu mDateTime Gets tl1e 1ni1li111tun date vaJue allo,ved for the DateTimePicker control.
MinimumSize Gets or sets the size that is the lower limit that GetPreferredSize can
specify.
Name Gets or sets the llafile of the control.
Padding This API supports the product infrastructure and is not intended to be
used directly from your code. Gets or sets the spacing between the
contents of the DateTimePicker control and its edges.
Parent Gets or sets the parent co11tainer of the control.
PreferredHeight Gets the preferred height of the DateTimePicker control
PreferredSize Gets tl1e size of a rectru1gular area into which the control can fit.
ProductName Gets the product name of tl1e assembly containing the control.
ProductVersion Gets tl1e version of the assembly co11taining the control.
RecreatingHandle Gets a value iI1dicafu1g whether tl1e control is cturently re-creating its
11anclle.
Region Gets or sets the vvindow region associated ~vith the control.
RenderRightToLeft Obsolete.This property is now obsolete.
378 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
ResizeRedraw
- - - - - - - -
Gets or sets a
- -
value
- - - -
indicati11g
-\V
- -
hether
-the control redra\.vs itself when
resized.
Right Gets the distance, in pixels, betwee11 the right edg~ of the control and the
left edge of its container's client area.
RightToLef't Gets or sets a value indicating \.vl1etber control's elemen ts are aligned to
support locales using right-to-left fonts.
RightToLeftLayout Gets or sets \.vhether the contents of t11e DateTi1nePicker are laid out
from 1igl1t to left.
ScaleChildren Gets a value that detennines the scaling of child controls.
ShowCheckBox Gets or sets a value indicating wl1etber a check box is displayed to the
left of the selected date.
Show FocusCues Gets a value indicating \vbether the control should display focus
rectangles.
Sho\vKeyboard Cues Gets a value indicating \vhether the user interface is in the appropriate
state to show or hide keyboard accelerators.
Sho\vUpDown Gets or sets a value indicating whether a spin button control (also known
as an up-down control) is used to adjust the date/tilne value.
Site Gets or sets the site of the control.
Size Gets or sets tl1e height and widtl1 of the control.
Tablndex Gets or sets the tab order of the control '1vithin its co11tainer.
TabStop Gets or sets a value indicating \.vhether the user can give the focus to this
control using the TAB key.
Tag Gets or sets the object that contains data about the control
Text Gets or sets the text associated \.vitl1 this control. (Overrides
Control. TeA't.)
Top Gets or sets the distance, in pixels, bet'Ween the top edge of the control
and the top edge of its container's client area.
TopLevelControl Gets the parent control that is not parented by a11other Wi11dows Fon11S
control. Typically, this is the outer1nost Form that tl1e control is
contained in.
UseW aitCursor Gets or sets a value indicating wl1ether to use the wait cursor for the
current control and all child controls.
Value Gets or sets tlle date/tiine value assigned to tl1e control.
Visible Gets or sets a value indicating vvl1ether the control and a.11 its child
controls are displayed.
Width Gets or sets the width of the control.
Winclo,vTarget This API supports the product infrastructure and is not intended to be
used directly from your code. This property is not relevant for this class.
DOMAINUPDOWN
PROPERTY DESCRIPTION
-- ---
AccessibilityObject Gets the AccessibleObject assigned to tl1e control.
Accessi b leDefaultActionDescription Gets or sets the default action description of the control for use by
accessibility client ap_plications.
PowerShell Stu dio - Reference Guide. I 379
PROPERTY DESCRIPTION
AccessibleDesc1iption Gets or sets the description of the control used by accessibility
client applications.
Accessible.N"aine Gets or sets the name of the co11trol used by accessibility client
applications.
AccessiblelloJe Gets or sets the accessible role of the control
ActiveControl Gets or sets the active control on the container control.
AllowDrop Gets or sets a value indicating whether the control cai.1 accept data
that the user drags onto it.
Anchor Gets or sets the edges of the container to ':vhich a control is botu1d
and determines how a control is resized \.vith its parent.
AntoScaleDimensions Gets or sets the dimensions that the control was designed to.
AutoScaleFacto r Gets the scaling factor ben;vee11 tl1e Cll1Te11t and design-time
auto111atic scaling din1ensions.
AutoScaleMode Gets or sets the automatic sca1ing mode of the control.
Auto Scroll This API supports the product infrastructure and is not intended to
be used directly from your code. Gets a value indicating whether
the container will allow the user to scroll to any controls placed
outside of its visible boundaries.
Auto Scro IIMargin This API supports the product infrastructure and is not intended to
be used directly fro111 yol1r code. Gets or sets the size of the auto-
scroll margin.
AutoScrollMinSize This API supports the product infrastn1cture ru1d is not intended to
be used directly fro1n your code. Gets or sets the rnitlimun1 size of
the auto-scroll area.
AntoScrollOffset Gets or sets where tl1is control is scrolled to in
Scroll ControllntoVievv.
AutoScroJIPosition Gets or sets tl1e location of the auto-scroll position.
AutoSize Gets or sets a value indicating whether the control should
automatically resize based on its contents.
Auto Validate Gets or sets a value that indicates whether controls in tllls
contai11er will be automatically ' 'alidated when the focus changes.
BackColor Tills API supports the product infrastn1cture and is not intended to
be used directly from your code. Gets or sets the background color
for tlle teA1 box portion of the spin box (also knovv11 as ru1 up-down
control).
Backgroundlm age Th.is API suppo1ts tlle product infrastn1cture and is not intended to
be used directly from yot1r code. Gets or sets the background
irnage for the UpDownBase.
BackgroundlmageLayou t This API supports the product infrastn1cture and is not intended to
be used directly from your code. Gets or sets the layout of tlle
Backgroundlmage of the UpDo,vnBase.
Bin dingContext Gets or sets the BindingContext for the control.
Borders tyJe Gets or sets the border sty le for the spin box (.also kno\v-n as an up-
down control).
Bottom Gets tl1e distance. in pixels, bet\veen the bott om edge of the
control and the top edge of its container's client aiea.
380 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
Bounds Gets or sets the size and location of the control including its
nonclient elements, in pi,"'{els, relative to the parent control.
CanEnablelme Gets a value indicating whether the ImeMode pi-operty can be set
to an active value, to enable IME support.
CanFocus Gets a ,ralue indicating whether the control can receive foct1s.
CanRaiseEvents Determines if events can be raised on the control.
CanSelect Gets a value indicating whether the control can be selected.
Capture Gets or sets a value indicati11g whether the control has captured
the n1ouse.
CausesValidation Gets or sets a value indicatil1gwl1ether the control causes
validation to be performed on any controls that require validation
when it receives focus.
ChangingText Gets or sets a value indicating ~vhether tl1e text property is being
changed ii1ten1ally by its parent class.
Clie.ntRectan gle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height and width of the client area of the control.
CompanyName Gets the name of the company or creator of the application
containing the control.
Container Gets the !Container that contaiI1s the Component.
Contai.nsFocus Gets a value indicating whether the control, or one of its child
controls, currently lias the input focus.
ContextMenu This API supports the product infrastn1cture and is not intended to
be used directly fro1nyour code. Gets or sets the shortcut menu
associated with the spin box (also known as an up-dovvn control).
ContextMenuStrip Gets or sets the shortcut menu for the spin box (also k11own as an
up-down control).
Controls Gets the collection of controls contained within the control.
Created Gets a value indicating whether the control lias been created.
CreateParams This API supports the product infrastructure and is not intended to
be used directly fro1n your code. Gets the required creation
paraineters when the control handle is created.
Cu r1entAu toScaleDimensions Gets the current run-tilne dimensions of the screen.
Cursor Gets or sets the cursor that is displayed vvhen the mouse pointer is
over the control.
DataBindings Gets the data bindings for the control.
DefauJtC'ursor Gets or sets the default cursor for tl1e control
DefaultlmeMode Gets the default Input Method Editor (IME) mode supported by
t11e control.
DefaultMargin Gets the space, in pi,"'{els, that is specified by default bet\veen
controls.
DefaultMaximumSize Gets the length and height, in pixels, that is specified as the default
tnaximmn size of a control.
DefaultMi.nimumSize Gets the lengtl1 and height, in pixels that is specified as the default
minimtun size of a control
DefaultPadding Gets the internal spacing, in pixels of the contents of a control.
PowerShell Studio - Reference Guide I 381
PROPERTY DESCRIPTION
DefaultSize Gets the default size of tl1e control.
DesignMode Gets a value that indicates \ivl1ether the Component is c1mently in
design mode.
Dis11layRectangle Gets the rectangle that represents tl1e virtual display area of the
control.
Disposing Gets a value indicating whether the base Control class is in the
process of disposing.
Dock Gets or sets which control borders are docked to its parent control
and deten1lines how a control is resized with its parent.
DockPadding This API supports the product infrastructure and is not intended to
be used directly from yo11r code. Gets the dock padding settings
for all edges of the UpDownBase control.
DoubleBuffered Gets or sets a value indicating \:vhetber this control should redraw
its surface using a secondary buffer to reduce or prevent flicker.
Enabled Gets or sets a value indicating whether the control can respond to
user interaction.
Events Gets tl1e list of event handlers that are attached to this Component.
Focused Gets a value indicating wbetl1er the control has input focus.
Font Gets or sets the font of the teA1 displayed by the control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the spin box (also known as
an up-down control).
Handle Gets t11e vvindo\iv liandle t11at the contro1 is bo1md to.
H.asChildren Gets a value indicati.I1g whetl1er the control contains one or more
child controls.
Height Gets or sets the height of the control.
HorizontaJScroll Gets the characteristics associated \Vitl1 the horizontal scroll bar.
HScroll Gets or sets a value indicating whether the 11orizontal scroll bar is
visible.
ImeMode Gets or sets the Input Method Editor (IME) mode of the contTol.
ImeModeBase Gets or sets t11e IME mode of a control.
lntercepU\rroW'l(eys Gets or sets a value indicating ,;vhetl1er the user can use t11e UP
ARROW and DOWN ARROW keys to select values.
JnvokeRequired Gets a value indicati.11g whetl1er tl1e caller n1ust call an invoke
metl1od when making method calls to the control because the
caller is on a different thread than the one the control was created
on
IsAccessible Gets or sets a value indicating ,;vhether the control is visible to
accessibility applications.
IsDisposed Gets a value indicating whether tl1e control has been disposed of.
IsHandleCreated Gets a value indicating whether tl1e coutrol lias a handle associated
\Vith it.
IsMirrored Gets a value indicating whether tl1e control is mirrored.
Items A collection of objects assigned to tl1e spin box (also known as an
up-do\.vn control).
382 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTIC>N
LayoutEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the distance, in pixels, between the left edge of the
control ru1d tJ1e left edge of its container's client area.
Location Gets or sets the coordinates of t11e upper-left comer of the control
relative to the upper-left comer of its container.
Margin Gets or sets the space ben-;veen controls.
MaximumSize Gets or sets the maximum size of the spin box (also kno"vn as an
up-down control).
MinimumSize Gets or sets the rninimum size of the spin box (also know11 as an
up-down control).
Name Gets or sets the name of the control.
Padding This API supports the product infrastn1cture and is not intended to
be used directly fro111 your code. Gets or sets the spacing between
the Domai11UpDown control's co11tents and its edges.
Parent Gets or sets the parent container of the control.
ParentForm Gets the form that the container control is assigned to.
PreferredBeight Gets tl1e heigl1t of the spin box (also known as an up-d.ovvn
control).
PreferredSi1,e Gets the size of a rectangular area into \Vhi.ch the control can fit.
ProductName Gets the product name of the assembly containing the control.
ProductVersion Gets the version of the assembly containing the control.
Read Only Gets or sets a value indicati11g wl1ether the text can be changed by
tl1e use of the up or do,vn buttons only.
RecreatingHandle Gets a value indicating \vhether the control is currently re-creating
its handle.
Region Gets or sets the window region associated ' vith the co11trol.
RenderRightToLeft Obsolete.Tins property is now obsolete.
ResizeRed1aw Gets or sets a value indicating whether the control redraws itself
when resized.
Right Gets the distru1ce, in pixels, behveen the right edge of the control
and the left edge of its container's client area.
RightToLeft Gets or sets a value indicating whether control's elements are
aligned to support locales using right-to-left fo11ts.
ScaleChildren Gets a value that detennines the scaling of child controls.
Selectedlndex Gets or sets the index value of the selected item.
Selectedltem Gets or sets the selected item based on the index value of the
selected item in the collection.
Show Focus Cues Gets a value indicating whether the control should display focus
rectangles.
Show Keyboard Cues Gets a value indicating \V hether the user interface is in the
approp1iate state to sho\<v or hide keyboard accelerators.
Site Gets or sets the site of the control.
Size Gets or sets tl1e height and width of the control .
PowerShell Studio - Reference Guide I 383
PROPERTY DESCRIPnON
Sorted Gets or sets a value indicating whether the jtem collection is
sorted.
Tablndex Gets or sets the tab order of the co11trol \Vithir1 its container.
TabStOJl Gets or sets a value indicating whether the user can give the focus
to this control using the TAB key.
Tag Gets or sets the object that contains data about the control
Text Gets or sets the text displayed in the spin box (also known as an
up-do\>vn control).
TextAlign Gets or sets the aligru:nent of the text in the spin box (also known
as an up-down control).
Top Gets or sets the distance~ in p.Lxels, bet"\veen the top edge of the
control and the top edge of its container's client area.
To1>LeveJControl Gets t11e parent control that is .not parented by another Windo\;vs
Fo1IDS control. Typically this is the outer1nost Form that the
control is contained in.
UpDownAlign Gets or sets the alignment of tl1e up and down buttons on the spin
box (also known as an up-down control).
UserEdit Gets or sets a value indicating \Vhether a value has been entered by
the user.
UseW aitCu rsor Gets or sets a value indicating vvhether to use the wrut cursor for
the current control and all child controls.
VerticalScroll Gets the cliaracteristics associated wit11 the ve1tical scroll bar.
Visible Gets or sets a value indicating whetl1er tl1e control and all its child
controls are displayed.
VScroll Gets or sets a value indicating \Vhetber the vertical scroll bar is
visible.
Width Gets or sets the width of the control.
Window Target This API supports the product infrastructure and is not intended to
be used directly fron1 yo11r code. This property is not relevant for
this class.
Wrap Gets or sets a value indicating wbetlier the collection of items
continues to the first or last item if the user continues past the end
of the list.
ERRORPROVIDER
Blinl<Rate Gets or sets the rate at wllich the error icon flashes.
Blinl<S tyle Gets or sets a value inrucating when tl1e e1ror icon flashes.
CanRaiseEve Gets a value indicating vvhether the component can rruse an event.
nts
Container Gets the I Container tl1at contfilns the Con1ponent.
ContainerCon Gets or sets a value indicating the parent control for this ErroIProvider.
trol
DataMember Gets or sets the list '1vithin a data so1uce to n1onitor.
384 I PowerShell Studio - A Comprehensive Guide
DataSource Gets or sets the data source that the ErrorProvider inonitors.
DesignMode Gets a value that indicates \Vhether the Component is c1rrrently in design inode.
Events Gets the list of event handlers that are attached to this Component.
Icon Gets or sets the Icon tl1at is displayed next to a control when a11 error description string has
been set for the control.
RightToLeft Gets or sets a value that indicates whether the component is used in a locale that supports
right-to-left fonts.
Site Gets or sets the ISite of tl1e Component.
Tag Gets or sets an object that contains data about the component.
FILESYSTEMWATCHER
PROPERTY DESCRIPTION
CanRaiseEvents Gets a value indicating whether the component can raise an event.
Container Gets tl1e IContainer that contains the Compo11ent.
DesignMode Gets a value that indicates whetl1er the Con1ponent is cturently in design mode.
EnableRaisin gEvents Gets or sets a value indicating whether the component is enabled.
Events Gets the list of event handlers that are attached to this Compo11ent.
Filter Gets or sets the filter string used to detenuine what files are n1onitored in a
directory.
IncludeSubdirectories Gets or sets a value indicating whether subdirectories within the specified path
should be monitored.
InternalBufferSize Gets or sets the size (in bytes) of tl1e il1temal buffer.
Notify
Filter Gets or sets tl1e type of changes to watch for.
Path Gets or sets the patl1 of the directory to watch.
Site Gets or sets ai1 ISite for the FileSystemWatcher.
SyuchronizingObject Gets or sets the object used to inarshal tl1e event handler calls issued as a result of
a directory change.
FLOWLAYOUTPANEL
PROPERTY DESCRIPTION
AccessibilityObject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescri11tion Gets or sets tl1e default action description of tl1e
control for use by accessibility client applications.
AccessibleDescri11tion Gets or sets the description of the control used by
accessibility client applications.
AccessibleN rune Gets or sets the na1ne of tl1e control used by
accessibility client applications.
AccessibleRole Gets or sets the accessible role of the control
AllowDro11 Gets or sets a value indicating \hetber the control can
accept data that the user drags onto it.
PowerShell Studio - Reference Guide I 385
FOLDERBROWSERMODERNDIALOG
PROPERTIES DESCRIPTION
Container Gets the I Container t11at contains the Co1nponent.(Inherited fro1n Component.)
Description Gets or sets the descriptive text displayed above tl1e tree view control in the dialog
box.
RootFolder Gets or sets the root folder \.vhere tl1e browsing struts fro1n.
SelectedPatb Gets or sets the path selected by the user.
Sholl1Ne,vFolderButton Gets or sets a value indicating whether the New Folder button appears in the folder
browser dialog box.
Site Gets or sets the ISite of the Co111ponent.
Tag Gets or sets an object that contains data about tl1e control.
FONTDIALOG
Name Description
AllowScriptChange Gets or sets a value indicating \hether the user can change the cliaracter set specified in
the Script combo box to display a character set otl1er than tlle one currently displayed.
Allows imulations Gets or sets a value indicating whether the dialog box allows graphics device inte1face
(GDI) font simulations.
Allo,vVectorFonts Gets or sets a value i11dicating whether the dialog box allo\>vs vector font selections.
Allo,vVe11icalFonts Gets or sets a value indicating \vhether the dialog box displays both vertical and
horizontal fonts or only horizontal fonts.
CanRaiseEvents Gets a value indicating wl1ether tl1e compo11ent can raise an event. (Inherited from
Component.)
Color Gets or sets the selected font color.
Container Gets the !Container that contains tl1e Component. (Inherited from Component.)
DesignMode Gets a value that indicates whether the Component is currently in design inode. (Inherited
fron1 Co1npo11ent.)
390 I PowerShell Studio - A Comprehensive Guide
Name Description
Events Gets tbe list of event handlers that are attached to this Component. (lnl1erited fro1n
Component.)
FixedPitcb 0 nly Gets or sets a value indicating whether the dialog box allo,vs only the selection of fixed-
pitch fonts.
Font Gets or sets the selected font.
FontMustExist Gets or sets a value indicating wl1ether the dialog box specnies an error condition if the
user atten1pts to select a font or style that does not exist.
MaxSiz,,e Gets or sets tl1e maximum point size a user can select.
MinSize Gets or sets tbe 111ini1num point size a user can select.
01>tions This API supports the product infrastructure and is not intended to be used directly from
your code. Gets values to initialize the FontDialog.
Scripts Only Gets or sets a value indicating 'vhether the dialog box allows selection of fonts for all
non-OEM and Symbol character sets. as 'veil as the ANSI character set.
Show Apply Gets or sets a value indicating whether tl1e dialog box contains ai1 Apply butto11.
ShowColor Gets or sets a value indicating whether the dialog box displays the color choice.
Sho,vEffects Gets or sets a value indicating whether the dialog box contains controls that allow the
user to specify strikethrough, tmderline. and text color options.
Sbo,vHelp Gets or sets a value indicating whether the dialog box displays a Help button.
Site Gets or sets the ISite of the Co1nponent. (Inherited fro1n Coniponent.)
Tag Gets or sets an object that contains data about the control. (Inherited from
CommonDialog.)
GROUP BOX
PROPERTY DESCRIPTION
Actu alHeight Gets the rendered hei_ght of this element.
ActualWidtb Gets the rendered \vidth of this element.
Allo,vDrop Gets or sets a value indicating 'vbether this element can be used as the
target of a drag-and-drop operation. This is a dependency property.
AreAnyTouchesCaptu red Gets a value that indicates \Vhether at least one toucl1 is captured to tllis
element.
AreAnyTouchesCapturedWith Gets a value that indicates whether at least one touch is captured to tllis
m element o.r to any child elements inits visual tree .
AreAnyToucbesDirectlyOver Gets a value that indicates whether at least one touch is pressed over this
element.
AreAnyToucbesOver Gets a value that indicates whetl1er at least one touch is pressed over this
element or any child elements in its visual tree.
Bacl<ground Gets or sets a bn1sh that desc1i bes the background of a control.
BindingGroup Gets or sets the BindingGroup that is used for the element.
BitmapEffect Obsolete.Gets or sets a bitmap effect that applies directly to the rendered
content for this element. This is a dependency property.
PowerShell Studio - Reference Guide I 391
PROPERTY DESCRIPTION
BitinapEffectln1Jut Obsolete. Gets or sets an input source for the bitmap effect that applies
directly lo the rendered co11tent for this eleme11t. This is a dependency
property.
BorderBrusb Gets or sets a bntsh t11at describes the border background of a control.
BorderTbickness Gets or sets the border thickness of a control.
CacheMode Gets or sets a cached representation of the UIElen1ent.
Clip Gets or sets the geo1netry used to defme the outline of the contents of an
elen1ent. This is a dependency property .
Cli1JT0Bounds Gets or sets a ' 'alue indicating '"hether to clip the content of this element
(or content co1ning frorn the child elements of U1is ele111ent) to fit into the
size of the containing element. This is a dependency property .
CommandBindings Gets a collection of CommandBinding objects associated \ith this elen1ent.
A Con1I0andBindil1g enables comnlalld ha11dling for this element. a11d
declares the linkage behveen a cornn1and, its events, and the handlers
attached by this element.
Content Gets or sets the content of a ContentC011trol. (Inherited from
ContentControl.)
ContentStringFormat Gets or sets a composite stting thar specifies ho'v to format the Co11tent
property if it is displayed as a string.(lnherited from ContentControl.)
ContentTemplate Gets or sets the data ten1plate used to display the content of the
ContentCo nlTol. (Inherited fro1n ContentControl.)
ContentTemplateSelector Gets or sets a template selector that enables an application \.Yriter to provide
custom te1nplate-selection logic. (Inherited from Conte11tControl. )
ContextMenu Gets or sets the context n1enu elen1ent that should appear \Vhenever the
context tnenu is requested tluough user interface (UI) fro1n \Vithin Utls
element.
Cursor Gets or sets the cwsor that displays 'vhen the mouse pointer is over this
element.
DataContext Gets or sets U1e data context for an e1e1nent when it participates in data
binding.
DefaultStyleKe~1 Gets or sets the key to use to reference the style for this control. \vhen
the1ne styles are used or defined.
De1>en dencyObjectTy1>e Gets the DependencyO~jectType that ' vraps the CLR type of tllis ilistai1ce.
(Inherited from DependencyObject.)
Desired Size Gets the size tl1at tltis element co1nputed during the n1easure pass of the
layout process.
Dispatcher Gets the Dispatcher Ulis DispatcherObject is associated ' vith. (lnl1eriled
from DispatcherObject.)
Effect Gets or sets U1e bitn1ap effect to apply to U1e UIEle1nenl. This is a
dependency propetty.
FlowDirection Gets or sets the direction that text and other user interface (UI) ele1ne11ts
flov. ,,ithin any parent element that controls their layout.
1
Focusable Gets or sets a value that indicates \Yhether the ele1nent can receive focus.
This is a dependency property.
FocusVisualStyle
Gets or sets a property that enables customization of appearance, effects, or
other sty le cl1aracteristics that 'vill apply to this ele1nent "vhen it captures
keyboard focus.
FontFamily
Gets or sets the font fanrily of the co11trol.
FontSizc Gets or sets the font size.
392 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
FootStretch Gets or sets the degree to which a font is condensed or expanded on the
screen.
FootStvle
Gets or sets the font st)rlc.
FootWcight Gets or sets the \Veight or thickness of the specified font.
ForceCursor Gets or sets a value that indicates \Vhetl1er tllis Fratne,vorkElement should
force the user interface (UI) to render the cursor as declared by the Cursor
property .
Foreground Gets or sets a brush that describes the foreground color.
BandlesScrolling Gets a value that indicates \.Vhether a control supports scrolling.
HasAnimatedPrope11ies Gets a value indicating \Vhether U1is element has any animated properties.
BasContcnt Gets a value that indicates v,; hether the ContentControl contains content.
(Inherited fron1 ContentControl.)
HasEffectiveKc, boarclFocus
1
Gets a value that indicates '"11ether the UIElement has focus.
HasHeader Gets a value that indicates whether the header is null.
Header Gets or sets the data used for tlle header of each control.
HcadcrStiingFormat Gets or sets a composite string that specifies hO\Vlo fomial the Header
propert)' if it is displayed as a string.(In11erited fron1
Headered ContentControl.)
BeaderTempJate Gets or sets the template used to display t11e content of the control's header.
HcaderTcmplateSelcctor Gets or sets a data template selector that provides custon-a logic for
choosing the template used to display the header.
Height Gets or sets the suggested height of tlle ele1nent.
HorizontalAJignment Gets or sets t..he horizontal alignment characteristics applied to Uris eleinent
\Vhen it is con1posed \vitllin a parent element. such as a panel or itenlS
control.
HorizontalContentAlignment Gets or sets the horizontal aligrunent of the control's content.
InheritanceBehavior Gets or sets the scope limits for prope1ty value inheritance, resource key
lookup. and RelativeSource FindAncestor lookup.
lnputBindings Gets the collection of input bindings associated with this element.
lnputScope Gets or sets the context for input used by Uris Frame,vorkElement.
IsArrangeValid Gets a value indicating 'vhether the computed size and position of child
ele1nents in this ele1nent's layout are valid.
lsEnabled Gets or sets a value indicating ,~v hether this element is enabled in the user
interface (UI). This is a dependency property.
lsEnabledCore Gets a val ue that becomes the return value of IsEnabled ]11 derived classes.
lsFocused Gets a value tlial detennines \Vbether this element has logical focus. This is
a dependency property.
IsHitTcstVisible Gets or sets a value that declares ' vhether this ele1nent can possibly be
returned as a bit test result from some portion of its rendered content. Th.is
is a dependency property.
lslnitialized Gets a value that indicates '~1 hether this element bas been initialized, either
during processing by a XAML processor. or by explicitly having its End.I1lit
nlethod caJled.
IslnputMethodEnabled Gets a value indicating whether an input method system, such as an Input
Method Editor {IME), is enabled for processing the input to this element.
IsKeyboardFocused
Gets a value indicating ivhether this element bas keyboard focus . This is a
dependency property .
IsKeyboardFocusWitbin Gets a value indicating 'vJ1ether keyboard focus is anywhere " ;ithin U1e
ele1nent or its vjsual tree child elen1ents. This is a dependency property.
PowerShe ll Studio - Refere nce G uid e I 393
PROPERTY DESCRIPTION
lsLoaded Gets a value that indicates vvhether this element has been loaded for
presentation.
IsManipulationEnabled Gets or sets a value that indicates \Vhether n1anipulation events are enabled
on this UIEle111ent.
lsMeasu reV alid Gets a value indicating \Vhether the current size returned by layoul n1eastue
is valid.
IsMouscCaptured Gets a value indicating \ Vhether the 1nouse is captured to Uris element. This
is a dependency property.
IsMouseC aptu reWithin Gets a value that dete111rines \Vhether 1nouse capture is held by Uris eletnent
or by child elements in its visual tree. This is a dependency property.
IsMouseDirectlvOver
Gels a value that indicates \Yhelher tl1e position of the mouse poi11ter
corresponds to hit test results, \Vhich take element compositing into
account. This is a dependency property.
l sMouseOver Gets a value ii1dicating whether the tnouse pointer is located over this
element (including child elements in the visual tree). This is a dependency
property.
IsSealed Gets a value Ulat indicates \vhether this instance is currently sealed (read-
onJy).(lnJ1erited fro1n DependencyObject.)
IsS tylusC ap tured Gets a value indicating \vhether tl1e stylus is captured by this element. This
is a dependency property .
IsStylusCa1,tureWithin Gets a value that detennines \Vhetl1er stylus capture is held by this ele1nent,
or an element \itirin U1e elen1ent bounds and its visual tree. This is a
dependency property.
IsStylusDirectlyOver Gets a value that indicates whether the Sl)rlus position corresponds to hit
test results. \Vhich take element compositing into account. This is a
dependency property.
IsStytusOver Gets a value indicating \vhether the stylus cursor is located over this
element (including visual child elen1ents). This is a dependency property.
IsTabStop Gets or sets a value that indicates \Vhether a control is included in tab
navigation.
IsVisible Gets a value indicating whether this ele1nent is visible in the user interface
(UI). This is a dependency properly.
Language Gets or sets localization/globalization language information that applies to
an ele1nent.
LayoutTransform
Gets or sets a graphics transformation that should apply to this elen1enl
when layout is performed.
LogicalChildren Gets an enunierator to the logical child elements of the ControlTemplate.
Margin Gets or sets the outer 1nargin of an element.
MaxHeight Gets or sets the inaxin1wn height constraint of the elen1ent.
MaxWidth Gets or sets the nmxin1wn \tYidth constraint of the element.
MinHeight Gets or sets the n1 ini mum height constraint of the element.
MinWidth Gets or sets the minimu1n widtl1constraint of the element.
Name Gets or sets the identifying naine of tbe ele1nent. The name provides a
reference so that code-behind. such as event handler code. can refer to a
n1arkup element after it is constructed during processing by a XAML
processor.
Opacity Gets or sets the opacity factor applied to the entire UIEle1nent lvhen it is
rendered iI1 the user interface (Ul). Tllis is a depe11dency property.
394 I PowerShell Studio - A Comprehensive Guide
PROPERTY DESCRIPTION
OpacityMask Gets or sets an opacity n1ask, as a Bn1sh iJnplen1entation that is applied to
any alpha-channel masking for the rendered content of this element. This is
a dependency property .
OverridesDefau ltStyle
Gets or sets a value that indicates \Vhetl1er tlris element incorporates style
properties from theme styles.
Padding Gets or sets the padding inside a control.
Parent Gets the logical parent ele1nent of this element.
Persistld Obsolete. Gets a value that uniquely identifies this element.
RenderSize Gets (or sets, but see Renwks) U1e final render size of tlllis element.
RenderTransform Gets or sets transform infor1nation that affects the rendering position of this
element This is a dependency property.
RenderTransf o rmOrigi n Gets or sets the center point of any possible render transfonn declared by
RenderTransfonn. relative to the bounds of the element. This is a
depende11cy property.
Resources Gets or sets U1e locally-defmed resource dictionary.
SnapsToDevicePixcls Gets or sets a value that determines "\\ hether rendering for this ele1nent
1
PROPERTY DESCRIPTION
--
VisualBitmapEffectlnpnt
-- ---
Obsolete.Gets or sets the BitmapEffectlnput value for the Visual.
Visu aJBitmapScalin gMode Gets or sets the BittnapScalingMode for the Visual.
Vi.su aJCacheMode Gets or sets a cached representation of the Visual.
VisuaIChildrenCount Gets the number of visual child ele1nents \Vithin this ele1nent.
VisoalClearTypeBint Gets or sets the ClearTypeHint that detemlines how ClearType is rendered
in the Visual.
Visual Clip Gets or sets the clip region of the Visual as a Geometry value.
VisualEdgeMode Gets or sets the edge mode of the Visual as an EdgeMode value.
VisualEffect Gets or sets the bitmap effect to apply to the Visual.
VisuaIOffset Gets or sets tbe offset value of the visual object.
VisualOpacity Gets or sets the opacity of the Visual.
VisuaIOpacityMasl{ Gets or sets tbe Brush value that represents the opacity inask of the Visual.
VisuaJParent Gets the visual tree parent of the visual object.
VisualScrollableAreaClip Gets or sets a clipped scrollable area for the Visual.
VisualTextHintingMode Gets or sets the TeA1:HintingMode of the Visual.
Visu alTextRende1ingMode Gets or sets tbe TeA1RenderingMode of the Visual.
VisualTransform Gets or sets tbe Transfon11 value for the Visual.
VisualXSnappingGuidelines Gets or sets the x-coordinate (vertical) guideline collection.
VisualYSnap1>ingGuidelines Gets or sets they-coordinate (horizontal) guideline collection.
Width Gets or sets the width of the element.
HELPPROVIDER
PROPERTY DESCRIPTION
C anRaiseEvents Gets a value indicating whether tl1e component can raise an event.
Container Gets the IContai11er that contains the Co1nponent.
Design Mode Gets a value that indicates whether the Component is currently in design mode.
Events Gets the list of event handlers that are attached to this Co1nponent
HelpNamesi>ace Gets or sets a value specifying the name of the Help file associated with this HelpProvider
object.
Site Gets or sets the I Site of the Component
Tag Gets or sets the object that contains supplemental data about the HelpProvider.
IMAGELIST
LABEL
Actuameight
'
Gets tbe rendered height of this element.
ActuaJWidth Gets the rendered width of tlris ele111ent.
AllowDrop Gets or sets a value indicating \:vhether this element can be used as the
target of a drag-and-drop operation. This is a dependency property.
AreAnyTouchesC a1>tu red Gets a value that indicates -vvhether at least one touch is captured to
this element.
AreAnyTouchesCa1>tu red Within Gets a value that indicates \.Vhether at least one touch is captured to
this element or to any clrild elements in its visual tree.
AreAnyTouchesDirectlyOver Gets a value that indicates whether at least one toucl1 is pressed over
this element.
AreAnyTouchesOver Gets a vallte that indicates whether at least one touch is pressed over
tlris element or any cltlld elements in its visual tree.
Background Gets or sets a bn1sh that describes tl1e background of a control.
BindingGroup Gets or sets the BindingGroup that is used for tl1e element.
Bitm a1>Effect Obsolete.Gets or sets a bittnap effect tl1at applies directly to the
rendered content for this ele.ment. Tltls is a dependency property.
BitmapEffectlnput Obsolete. Gets or sets an input source for the bitmap effect tl1at
applies directly to the rendered content for tlris element. This is a
dependency property.
BorderBrush Gets or sets a bn1sh tl1at describes the border backgrolmd of a control.
Bo rderThiclrness Gets or sets the border thick11ess of a control.
CacheMode Gets or sets a cached representation of the UIBle111ent.
Clip Gets or sets the geometry used to define the outline of the contents of
an elen1ent. This is a dependency property.
Cli1>T0Bounds Gets or sets a value iI1dicating whether to clip tl1e content of tllis
ele1nent (or content coining from the clilld ele1nents of tllis ele1nent)
to fit into tl1e size of the containing ele1nent. This is a dependency
property.
CommandBindings Gets a collection of ConnnandBinding objects associated with this
element. A Co1nmai1dBinding enables command handling for this
ele1nent, and declares tl1e linkage between a co1nmand, its events, and
tl1e handlers attached by tltls element.
Content Gets or sets the content of a Conte11tControl.
ContentStringFormat Gets or sets a composite string that specifies how to format tl1e
Content property if it is displayed as a string.
PowerShell Studio - Reference Guide I 397
ContentTemplate Gets or sets t11e data template used to display the content of the
ContentControl.
ContentTemplateSelector Gets or sets a template selector that enables an application \Vriter to
provide custom template-selection logic.
ContextMenu. Gets or sets the context 1nenu element that should appear whenever
tl1e conteA1: menu is requested through user inte1face (UI) from ';vithin
this element.
Cursor Gets or sets the cursor that displays when tl1e mouse pointer is over
this element.
DataContei'1 Gets or sets the data conteA1: for a11 element when it participates in
data binding.
DefaultStyleKey Gets or sets the key to use to reference the style for this control, when
theme styles are used or defined.
De11en dencyOb jectType Gets the DependencyObjectType that \vraps tl1e CLR type of this
insta11ce.
DesiredSize Gets the size that this element computed during tb.e meas1rre pass of
tl1e layout process.
Dispatcher Gets the Dispatcher this DispatcberObject is associated witl1.
(Inherited from DispatcherObject.)
Effect Gets or sets the bittnap effect to apply to the UIElement. This is a
dependency property.
FlolvDirection Gets or sets the direction tl1at teA1: and other user il1terface (Ul)
elen1ents flo"v witlrin any parent ele1nent that controls tl1eir layout.
Focusable Gets or sets a value that indicates 'vhether the element ca11 receive
focus. Tlris is a dependency property.
FocusVisualStyle Gets or sets a property that enables custo1nization of appearance,
effects, or otl1er sty le characte1istics that \Vill apply to this element
when it captures keyboard focus.
FontFamily Gets or sets the font family of the control.
FontSize Gets or sets the font size.
FontStretch Gets or sets the degree to wlrich a font is condensed or eA'Pailded on
the screen.
FontStyle Gets or sets the font style.
FontWeight Gets or sets the weight or tlrickness of the specified font.
F 01ceCu rso i Gets or sets a value tllat indicates whether this FrameworkEle1nent
should force the user interface (UI) to render tl1e ctrrsor as declared by
tl1e Cursor property.
Foreground Gets or sets a brush that describes the foreground. color.
Han dlesScrolling Gets a value that indicates whether a control supports scrolling.
HasAnimatedP ro11e11ies Gets a value indicating ,;vhether tlris element has any anitnated
pr~perties.
HasContent Gets a value that indicates whether the ContentControl contains
content.
HasEffectiveKeyboardFocus Gets a val11e that indicates whether the UIElement has focus.
Height Gets or sets the suggested height of the element.
398 I PowerShell Studio - A Comprehensive Guide
IsSealed Gets a value tl1at indicates whether this instance is ctuTently sealed
(read-only).
IsS tylusC aptured Gets a value indicating whether the stylus is captured by this element.
This is a dependency property.
IsStylusCa1JtureWithin Gets a value that detennit1es whether stylus capture is held by this
element. or an ele1nent within the element bounds ai1d its visual tree.
This is a dependency prope1fy.
IsStylusDiiectlyOver Gets a value that indicates whether the stylus position corresponds to
hit test results whicl1 take element compositing into account. This is a
dependency property.
IsStylusOver Gets a value indicating whether the stylus cursor is located over this
element (including visual child eleme11ts). This is a depende11cy
property.
IsTabStop Gets or sets a value that indicates whether a control is included in tab
navigation.
IsVisible Gets a value indicating \.vhether this element is visible in the user
interface (UI). This is a dependency property.
Language Gets or sets localization/globalization language information that
applies to an element.
LayoutTransform Gets or sets a graphics transformation that should apply to this
ele1nent when layout is perfonned.
LogicalChildren Gets an enumerator to tl1e content control's logical child eleme11ts.
Margin Gets or sets the outer nlargin of an element.
MaxHeight Gets or sets the maximum height constraint of the element.
MaxWjdtb Gets or sets the niaximmn width constraint of the element.
MinHeight Gets or sets the nlini1ntun height constraint of the ele1nent.
MinWidth Gets or sets the minimum "vidth constrai11t of the elen1ent.
Name Gets or sets the ide11tifying nan1e of the element. The naine provides a
reference so that code-behind, such as event handler code, can refer to
a markup element after it is constructed dtrring processing by a
XA11L processor.
Opacity Gets or sets the opacity factor applied to the entire UIEle1nent when it
is rendered in the user interface (UI). This is a dependency property.
OpacityMasi< Gets or sets an opacity mask, as a Bn1sb inlplen1entation that is
applied to ru1y alpha-cbannel maslcing for the re11dered content of this
elen1ent. This is a dependency property.
OverriclesDefaultStyle Gets or sets a value that indicates whether this element incorporates
style properties from theme styles.
Padding Gets or sets the padding inside a control.
Parent Gets the logical parent element of this element.
Persistld Obsolete. Gets a value that uniquely identifies this ele1nent.
RenderSize Gets (or sets, but see Ren1arks) tl1e final render size of this ele1nent.
RenderTransform Gets or sets transform infom1ation that affects the rende1ing position
of this ele1nent. This is a dependency pr~perty.
400 I PowerShell Studio - A Comprehensive Guide
RenderTransformOrigin Gets or sets the center point of any possible render transform declared
by RenderTransfonn, relative to the bounds of the element. This is a
dependency property.
Resources Gets or sets the locally-defined resom:ce dictionary.
Soa1>sT0DevicePixels Gets or sets a value that detennines \Vhether re11deri11g for this
element should use device-specific pi,xel settings during rendering.
Th.is is a dependency property.
Style Gets or sets the style used by this element when it is rendered.
StylusPlu gins Gets a collection of all stylus plug-in (customization) objects
associated \Vith th.is ele1nent.
Tablndex Gets or sets a value tl1at detennines the order in which ele1nents
receive focus \Vl1e11 the user navigates through controls by using the
TAB key.
Tag Gets or sets an arbitTary object value that can be used to store custon1
info1mation about this ele1nent.
Target Gets or sets the element that receives focus when the user presses the
label's access key .
Template Gets or sets a control template.
Tem1>latedParent Gets a reference to the ten1plate parent of this ele1nent. This properly
is not relevant if the element was not created through a template.
ToolTi(l Gets or sets the tool-tip object that is displayed for tlris ele1nent in the
user intetface (UI).
TouchesCaptured Gets all touch devices that are captlired to this elernent.
TouchesCapturedWithin Gets all touch devices that are captured to this ele1nent or any child
elernents in its visual tree.
TouchesDirectlyOver Gets all touch devices tl1at are over this element.
ToucbcsOver Gets all touch devices that are over this elen1ent or a11y child ele1nents
in its visual tree.
Triggers Gets the collection of triggers established directly on this ele1nent, or
in child eleme11ts.
Uid Gets or sets the unique identifier (for localizatio11) for this ele1n.ent.
This is a dependency property .
U seLayoutRounding Gets or sets a value that indicates \vhether layout rounding should be
applied to this element's size and position duril1g layout.
VerticalAJign ment Gets or sets the vertical alignn1ent characteristics applied to tlris
ele1nent when it is co1nposed within a parent element such as a panel
or ite1ns control.
VerticalContentA1ignment Gets or sets tl1e vertical alignment of the control's content.
Visibility Gets or sets the user interface (UI) visibility of this ele1nent. This is a
dependency property .
Visu alBitmapEffect Obsolete.Gets or sets the BitmapEffect value for the Visual.
VisualBitmapEffectln put Obsolete.Gets or sets the BitmapEffectlnput value for the Visual.
VisualBitmapScalingMode Gets or sets the BitmapScalingMode for the Visual.
VisualCacheMode Gets or sets a cached representation of the Visual.
VisualChildrenCount Gets the number of visual child elements vvitbin this element.
PowerShell Studio - Reference Guide I 401
LINKLABEL
Backgroundlm age This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets the image rendered
on tlle background of the control.
Backgrou ndlmageLayout This API supports the product infrastn1cttue and is not intended to
be used directly fro1n yoru code. This property is not relevant fo r
this class.
Bin clingContext Gets or sets tl1e BindingConte~'t for the control.
BorderStvle
Gets or sets the border sty le for the control.
Bottom Gets the distance, in pixels, between the botto1n edge of the
control and the top edge of its contail1er's client area.
Bounds Gets or sets the size and location of the control including its
nonclient elements, il1 pi-xels relati,re to the parent co11trol.
CanEnablelme Gets a value indicating ' vhet11er the lmeMode property can be set
to an active value, to enable IME support.
CanFocus Gets a value indicating "'hether the control can receive focus.
CanRaiseEvents Detennines if events can be raised on the control.
CanSelect Gets a value indicatil1g \vbether the control can be selected.
Ca11ture Gels or sets a value indicating \Vhether the control has captured
the mouse.
CausesValidation Gets or sets a value indicating whether the control causes
validation to be performed on any controls that require validation
when it receives focus.
ClientRectangle Gets the rectangle that represents the client area of the control.
ClicntSizc Gets or sets the height and \vidth of the client area of the control.
CompanyName Gets the name of the company or creator of the applicatio11
containing the control.
Container Gets the !Container that contains the Component.
ContainsFocus Gets a value indicating whetl1er the control, or one of its child
controls, currently has the input focus.
ContextMenu Gets or sets the shortcut n1enu associated \Vit11 U1e control.
ContextMenuStrip Gets or sets the ContextMenuStrip associated \vith this control.
Controls Gets the collection of controls contained wiUlin U1e control.
Created Gets a value indicating '\iVhet11er the control has been created.
CreateParams Gets the required creation parruneters "vhen the control handle is
created.
Cursor Gets or sets the cursor that is displayed when the mouse pointer is
over the co ntro I.
DataBindings Gets the data bindmgs for the control.
Defau ltCurso r Gets or sets the default cursor for the control.
DefaultlmeMode Gets the default Input Method Editor (lME) 1node supported by
this control.
Defau ltMargin Gets tl1e space. in pixels. that is specified by default bern1een
controls.
Defau ltMa:\'in:tumSize Gets the lengtl1 and beighL in pixels. that is specified as the default
1naxin1u111 size of a control.
Defau ltMinimumSize Gets the lengtl1 and height, in pixels, that is specified as the default
minimum size of a control.
Defau ltPadding Gets the internal spacing, in pixels, of the contents of a control.
PowerShell Studio - Reference Guide. I 403
Left Gets or sets the distance, in pi'<els, bet\veen the left edge of the
control and the left edge of its container's client area.
LinkArea Gets or sets the range in the te:\.1 to treat as a link.
LinkBebavior Gets or sets a value that represents the behavior of a link.
LinkColor Gets or sets the col or used '~1hen displaying a norm.al link.
Links Gets the collection of links contained \Vithin tl1e Link.Label.
LinkVisited Gets or sets a value it1dicating whether a link should be displayed
as though it ,;\ere visited.
Location Gets or sets the coordinates of the upper-left comer of the control
relative to the upper-left comer of its container.
Margin Gets or sets the space between controls.
Maximu mSize Gets or sets the size that is the upper limil that GetPreferredSize
can specify.
MinimumSize Gets or sets the size that is the lotvver limit that GetPreferredSize
can specify.
Name Gets or sets t11e name of the control.
OverrideCu rsor Gets or sets the mouse pointer to use when the 1no11se pointer is
~ ithin the bounds of the Link.Label.
Padding Gets or sets the interior spacing, in pixels, between the edges of a
LinkI.abeJ and its contents.
Parent Gets or sets the parent container of the control.
P refcrredHeight Gets the preferred height of the control.
PreferredSize Gets tl1e size of a rectangular area into which the control can fit.
Preferred Width Gets the preferred width of the control.
ProductName Gets the product nalne of the assen1bly contai1tlng the control.
ProductVersion Gets tl1e version of tl1e assembly containing the co11trol.
RecreatingHandle Gets a value indicafu1g \)y'hether the control is currently re-creating
its handle.
Region Gets or sets the "vindo,, region associated '~ith the control.
RenderRightToLeft Obsolete.This pToperty is no~ obsolete.
RenderTrans1>arent Obsolete.Indicates whether the container control background is
rendered on tl1e Label.
ResizeRedraw Gets or sets a value indicating 'vhether the control redra,vs itself
" .hen resized.
Right Gets the distance. in pixels, between tl1e right edge of ll1e control
and the left edge of its container's client area.
RightToLcft Gets or sets a value indicating 'vhether control's elements are
aligned to support locales using right-to-left fonts.
Scale Children Gets a value that detennines the scaling of child controls.
ShowFocusCues Gets a value indicating whether the control should display focus
rectangles.
Sho'vKeyboard
Cues Gets a value indicating \>Vhether the user interface is in the
appropriate state to sho"v or hide keyboard accelerators.
Site Gets or sets the site of U1e control.
Size Gets or sets the 11eigl1t and 'vidth of the control.
Tab Index Gets or sets the tab order of the control ,,ithin its container.
TabStOJ> Gets or sets a value that indicates ' vhether the user can tab to the
LinkLabel.
PowerShell Studio - Reference Guide I 405
Tag Gets or sets tbe object tbat contains data about the control.
Text Gets or sets the teA't displayed by the Linkl .abel.(Overrides
Label.Text.)
TextAlign Gets or sets the alignment of text in the label.
To1> Gets or sets the distance, in pixels, bet,;veen the top edge of the
control and the top edge of its container's client area.
TopLevelControJ Gets tl1e parent control that is not parented by another Windows
Fonns control. Typically, this is tbe outennost Form that the
control is contained u1.
UseCom1>atibleTextRendering Gets or sets a value that detennines \Vhether to use the Graphics
class (GDI+) or the TextRenderer class (GDI) to render text.
U seMnemonic Gets or sets a value indicating \Vhether the control interprets an
ampersand character(&) in the control's Text prope1ty to be an
access key prefix character.
UseW aitCu rso r Gets or sets a value indicating whether to use the \.Va.it ctrrsor for
tbe current control and all child controls.
Visible Gets or sets a value indicating ':vhether the control and all its child
controls are displayed.
VisitedLinkColor Gets or sets the color used when displaying a link that that 11as
been previously visited.
Width Gets or sets the width of the control.
Window Target Tins API supports the product infrastructure and is not inte11ded to
be used directly from your code. This property is not relevant for
this class.
LISTBOX
Bin dingGrou 1> Gets or sets the BindingGroup U1al is used for U1e element.
Bitm atlEffect Obsolete.Gets or sets a bitnlllp effect that applies directly to the
rendered content for Utls ele1ne11t. Tlris is a dependency property .
BitmapEffcctlnput Obsolete. Gets or sets an input source for the bitmap effect that applies
directly to the rendered content for tlris ele1nent. This is a dependency
property.
BorderBrush Gets or sets a bn1sb that describes tJ1e border background of a control.
Bo rderThickness Gets or sets the border thickness of a control.
CacheMode Gets or sets a cached representation of the UIElement.
Clip Gets or sets the geo1net.ry used to define the outline of the contents of an
element. This is a dependency property.
ClipToBounds Gets or sets a value indicating \hether to clip tl1e content of tllis
element (or content coining from the child elements of this element) to
fit into the size of the containing element. This is a dep endency
property.
Command Bindings Gets a collection of Command.Binding objects associated with this
ele1nent. A Comrnand.Binding enables conunand handling for this
element, and declares the linkage between a command, its events, and
U1e handlers attached by t1Jis element.
CootextMenu Gets or sets the context n1enu elen1ent U1at should appear whenever the
context n1enu is requested Urrough user interface (U I) fron1 \Vithin Ulis
element.
Cursor Gets or sets the cursor that displays when the mouse pointer is over this
element.
Data Context Gets or sets the data context for an element ' vhen it participates in data
binding.
DefaultStyleKey Gets or sets the key to use to reference the style for this control. 'vhen
theme styles are used or defined.
Depen dencyObjcctType Gets the DependencyObjectType that \vraps the CLR type of Utis
instance. (Inherited fromDependencyObject.)
Desired Size Gets tl1e size that this element computed dtuing the measrne pass of the
layout process.
Dispatcher Gets the Dispatcher this DispatcherObject is associated with. (Inherited
fro tn Dispatcl1erObject.)
DisplayMemberPath Gets or sets a path to a valt1e on the source object to serve as the visual
representation of the object.
Effect Gets or sets the bitmap effect to apply to the UIElement. This is a
dependency property.
Flo,vDirectioo Gets or sets the direction that text and other user interface (UI) elements
flow \vithin any parent element that controls their layout
Focusable Gets or sets a value that indicates wbetJ1er the eleinent can receive
focus. This is a depe11dency property.
FocusVisualStvle
Gets or sets a property that enables customization of appearance,
effects. or otl1er sty le characteristics U1at \.Vill apply to this ele1nent when
it captures keyboard focus.
FontFamily Gets or sets U1e font fan1jly of tJ1e control.
FontSize Gets or sets the font size.
FontStretch Gets or sets the degree to \vhicb a font is condensed or expanded on the
screen.
PowerShell Studio - Reference Guide I 407
FontStvle
Gets or sets the font style.
FontWeigbt Gets or sets the weight or thickness of the specified font.
ForceCursor Gets or sets a value that indicates \Vhether this Frame,vork.Element
should force tl1e user interface (UI) to render the cursor as declared by
the Cursor property .
Foreground Gets or sets a bn1sh that describes the foreground color.
Gron pSt~1 le Gets a collection of GroupStyle objects that define the appearance of
each level of groups.
G rou 1>StyleSelector Gets or sets a method that enables you to provide custom selection logic
for a GroupStyle to apply to each group in a collection.
HaocllesScrolling Gets a value that indicates \Yhether the ListBox supports
scrolling.(Ovetrides Contro l.HandlesScrolling.)
HasAoimatedPrope11ies Gets a value indicating \:Vhetber this elernent has any anilnated
properties.
HasEffectiveKeyboardFocus
Gets a value that indicates 'vbether the UIElement ltas focus.
Hasltems Gets a value that indicates \Vhether the Iten1sControl contains iterns.
Height Gets or sets the suggested heig11t of the element.
HorizontaWignmeot Gets or sets the ho1izontal alignment characteristics applied to this
elen1ent when it is composed \vitbin a parent element, such as a panel or
items control.
HorizontaJContentAlignmeot Gets or sets the horizontal alignment of the control's content.
InberitanceBeha,rior Gets or sets the scope limits for property value inheritance. resotuce key
lookup. and ReJativeSource Find.Ancestor lookup.
InputBindin gs Gets the collection of input biJ1clings associated vviith this ele1nent.
InputScope Gets or sets the context for mput used by this Frame\vorkElement.
IsArrangeValid Gets a value indicating \vheU1er the computed size and position of child
elements in this elen1ent's layout are valid.
l sEnabled Gets or sets a value indicating 'vheU1er this elen1e11t is enabJed in the
user interface (UI). This is a dependency property.
IsEnabledCore Gets a value that becornes the return value of IsEnabled il1 derived
classes.
IsFocused Gets a Yalue that determines '""hether this element has logical focus.
This is a dependency property.
IsGrouping Gets a value that indicates whether the control is using grouping.
IsHitTestVisiblc Gets or sets a value th.at declares \VbeU1er this eleme11t can possibly be
rettimed as a hit test result from some portion of its rer1dered content.
This is a dependency property.
Islnitialized Gets a value that indicates \Vhether this element has been ffiitialized,
either durmg processing by a XAML processor. or by explicitly having
its Endlnit meU1od called.
IsinputMetbodEnabled Gets a value indicating \vhether an input n1etbod systern. sucl1 as an
Input Method Editor (IME), is enabled for processing the input to this
element.
IsKe:vboardFocu
sed Gets a value indicating whether this element has keyboard focus. This is
a dependency property.
IsKeyboardFocu sWithin Gets a value indicating \vhether keyboard focus is an)'\vhere witllffi the
elen1ent or its visual tree child ele1nents. Th.is is a dependency property .
IsLoaded Gets a value tl1at indicates \vhetber this ele1nent has been loaded for
presentation.
408 I PowerShell Studio - A Comprehensive Guide
IsMani pu lationEn ab led Gets or sets a value that indicates \Vhether m.anipulation events are
enabled on this U1Ele1nent.
IsMeasureValid Gets a value indicating \VheU1er the current size returned by Layout
measure is valid.
I sMou seCaJltured Gets a value indicating \Vhetber the n1ouse is capt1ued to tllis ele1nent.
This is a dependency property .
lsMouseCa1>tu reWithin Gets a value that deternlines \vhether n1ouse capture is held by this
element or by child elements in its visual tree. This is a dependency
property.
IsMou seDirectlyOver
Gets a value that indicates \vl1ether the position of the mouse pointer
corresponds to hit test results. \\hich take elernent con1positing into
account. This is a dependency property.
lsMouseOVer Gets a value indicating \Vhether the mouse pointer is located over this
element (including child elements in U1e visual tree). Tb.is is a
dependency property.
lsSealed Gets a value that indicates whether this instance is currently sealed
(read-only).(Inherited fro1n DependencyObject.)
lsStylusCaptured Gets a value indicating ,vhether the stylus is captured by this eleme11t.
This is a dependency property.
IsStylusCa1>tureWithin Gets a value that determines whether stylus capture is held by this
elernent. or an element \Vithin the elen1ent bounds and its visual tree.
This is a dependency property.
IsS tylu sDirectlyOver Gets a value that indicates \Vhether the stylus position corresponds to hit
test results, which take element compositing i11to account. This is a
dependency property.
IsStvlusOver
Gets a value indicating whether the stylus cursor is located over this
element (including visual child ele1nents). TJlis is a dependency
property.
IsSynchronizedWithCurren.titem Gets or sets a value that indicates 'vhether a Selector should keep the
Selectedltem synchronized 'vith the current ite111 in the Iten1s property .
(Inherited fro1n Selector.)
IsTabStop Gets or sets a value tbat indicates \Vhether a control is included in tab
navigation.
IsTextSearchCaseSensitive Gets or sets a value that indicates \VhetJ1er case is a condition \Vhen
searclling for items.
IsTextSearcbEnabled Gets or sets a value that indicates ' vhether TextSearch is enabled on tbe
ItemsControl instance.
lsVisible Gets a value indicating \Vhetber this element is visible in the user
interface (UI). This is a dependency property.
ltemBiudingGroup Gets or sets the BindingGroup that is copied to eacl1 item in the
ItemsControl.
ltemContainerGenerator Gets the ItemContainerGenerator that is associated \vith the control.
ItemContaine1S tvle
Gets or sets the Style that is applied to the container eletnenl generated
for each item.
Item ContainerStyleSelector Gels or sets custon1 style-selection logic for a style that can be applied
to each generated container element.
Items Gets the collection used to generate the content of the ItemsControl.
ltcmsPancl Gets or sets the template that defines the panel that controls the layout
of ite1ns.
PowerShell Studio - Reference Guide I 409
ltemsSou rce Gets or sets a collection used to generate the content of the
ltemsControl.
ItemStringFormat Gets or sets a con1posite string tl1at specifies ho\:v lo format the itenis in
the ItemsControl if they are displayed as strings.
Item Template Gets or sets the DataTe1nplate used to display each iten1.
ItemTcmplateSelector Gets or sets the custom logic for choosing a template used to di5play
each item.
Language Gets or sets localization/globalization language information that applies
to an element.
LayoutTransform
Gets or sets a graphics transfomiation that should apply to this elernent
' ' hen layout is performed.
1
LogicaJChild ren Gets an enu111erator for tl1e logical child objects of the ItemsControl
object.
Margin Gets or sets the outer 1nargin of an element.
Max Height Gets or sets the maximum height constraint of the element.
MaxWidth Gets or sets the maximw11 \\1idth constraint of the e len1ent.
MinHeight Gets or sets the rninimun1 height co11Straint of the elernent.
MinWidth Gets or sets the minirnum \Vidth constraint of the element.
Name Gets or sets the identifying naine of the element. The name provides a
reference so that code-behind. such as event handler code. can refer to a
n1arkup ele1nent after it is constructed during processing by a XAML
processor.
01>acity Gets or sets the opacity factor applied to the entire UIEle1nent when it is
rendered in the user interface (Ul). This is a dependency property.
OpacityMas k Gets or sets a11 opacity mask. as a Brush i1nple1nentation that is applied
to any alpha-channel ulllsking for the rendered content of this element.
This is a dependency property.
OverridesDefaultStyle
Gets or sets a value that indicates \vhether this ele1nent incorporates
sty le properties from theme styles.
Padding Gets or sets the padding inside a control.
Parent Gets tl1e logical parent eleme11t of this element.
PersistId Obsolete.Gets a value U1at uniquely identifies Ulis ele1nent.
RcndcrSize Gets (or sets, but see Remarks) the final render size of this element
RenderTransforrn Gets or sets transform infor1nation U1at affects the rendering position of
this element. This is a dependency property.
RenderTransformOrigin Gets or sets tl1e center point of any possible render transfonn declared
by RenderTransfonn, relative to tl1e bounds of tb.e element. This is a
dependency property.
Resources Gets or sets the locally-defined resource dictionary.
Selectedlndex Gets or sets the index of the first item in the current selection or reti1ms
negative one (-1) if the selection is e1npty. (Inherited fron1 Selector.)
Selectedltem Gets or sets tl1e first item in the current selection or reh1ms null if the
selection is en1pty (Inherited from Selector.)
Selectedltems Gets the currently selected items.
SelectedValue Gets or sets the value of the Selectedltem, obtained by using
SelectedValuePath. (Inherited from Selector.)
SelcctedValuePatb Gets or sets the path that is used to get the SelectedValue fro1u the
Selecteditem. (Inherited fro1n Selector.)
410 I PowerShe ll St udio -A Comprehe nsive Guide
StylusPlu gins Gets a collection of all stylus plug-in (custo1nization) objects associated
\ith this ele1nent.
Tablndex Gets or sets a alue that determines the order in which elements recei e
focus \Vhen the user navigates throug11 controls by using the TAB key.
Tag Gets or sets an arbitrary objectvalue that can be used to store custom
infomiation about Ulis element.
Template Gets or sets a control template.
TemplatedParent Gets a reference to the template parent of this element. This property is
not relevant if the element was not created through a template.
ToolTip Gets or sets tbe tool-tip object that is displayed for this elerne11t in the
user interface (Ul).
TouchesCaptwed Gets all touch de,rices that are capttued to this element.
TouchesCaptu redWithin Gets all touch devices that are capt1ued to this elen1ent or any ch.ild
elements in its ,-isual tree.
Tou cbesD irectlyOver Gets all touch devices that are over this element.
ToucbesOver Gets all touch devices that are over this elen1ent or any child elements in
its visual tree.
Triggers Gets the collection of triggers established directly on this element, or in
child elen1ents.
Uid Gets or sets the unique identifier (for localization) for this ele1nent. This
is a dependency property .
UseLayoutRounding Gets or sets a va1ue that indicates ,vJ1ether layout rounding should be
applied to this element's size and position dtuing layout
VerticalAlignment Gets or sets the vertical alignment characteristics applied to this element
\Vhen it is cornposed \\ithin a parent ele1ne11t such as a panel or ite1ns
control.
VerticalContcntAlignment Gets or sets the vertical aligim1ent of the control's content.
Visibilitv Gets or sets the user interface (Ul) visibility of this elen1ent. This is a
dependency property.
VisualBitma11Effcct Obsolete. Gets or sets the BitmapEffect value for the Visual.
VisualBitmapEffectlnput Obsolete.Gets or sets the Biln1apEffectlnput value for the Visual.
VisualBitma_pScalingMode Gets or sets the BitmapScalingMode for U1e Visual.
VisualCacheMode Gets or sets a cached representation of the Visual.
VisuaJCbildrenCount Gets the nun1ber of visual child ele1nents \vi thin tlris ele1ne11t.
VisualClearTy1leHint Gets or sets the CJearTypeHint that deternunes how ClearType is
rendered in U1e Visual.
VisualCli1J Gets or sets tl1e clip region of the Visual as a Geometry value.
VisualEdgeMode Gets or sets the edge tnode of the Visual as an EdgeMode Yalue.
VisualEffect Gets or sets the bitmap effect to apply to tl1e Visual.
VisualOtiset Gets or sets the offset value of the visual object.
Visual Opacity Gets or sets the opacity of the Visual.
VisuaJOpacityMask Gets or sets the Bn1sh value that represents the opacity mask of the
Visual.
PowerShell Studio - Reference Guide I 411
LISTVIEW
HasAnim atedProperties Gels a va lue indicating \hether this elen1ent has any ani111ated
properties.
HasEffectiveKeyboardFocus
Gets a value that indicates v.rhether the UIEle1nent has focus.
Hasltems Gets a value U13t inrucates \hether the Iten1sControl contains items.
Height Gets or sets the suggested height of the element.
HorizontalAlignment Gets or sets the horizontal aligrunent characteristics applied to this
element \Vhen it is co1nposed within a parent elen1ent, such as a paneJ
or iten1s control.
HorizontalContentAlignment Gets or sets the ho1izontal alignment of the control's content.
InberitanceBehavior Gets or sets the scope lin1its for property value inheritance. reso1uce
key lookllp, and RelativeS01rrce Find.Ancestor lookup.
InputBindings Gets the collection of input bindings associated \Vitb this element.
InputScope Gets or sets the context for input used by tills Frame\vorkElen1ent.
IsArrangeValid Gets a value indicating 'vhether the computed size and position of
cllild elements in this ele1nenrs layout are valid.
IsEnabled Gets or sets a. value indicating whether this element is enabled in the
user iuterface (UI). This is a dependency property.
lsEnabledCore Gets a valu.e that becomes the return value of IsEnabled in derived
classes.
IsFocused Gets a value that detemlines \Vhether this elen1ent has logical focus.
This is a dependency property.
lsGrou1Jing Gets a value that indicates whether the control is using grouping.
IsHitTestVisible Gets or sets a vaJue that declares \Vhether this elen1ent can possibly be
returned as a hit test result from so rne portion of its rendered content.
This is a dependency property.
Isloitialized Gets a value that indicates \vhether this elen1ent has been initialized,
either during processing by a XAML processor, or by explicitly 113ving
its End.In.it method called.
Isl o pu tMethodEnabled Gets a value indicating whether an input n1ethod syste111, such as an
Input Method Editor (IME), is enabled for processing the input to this
elen1ent.
l sKeyboa rdFocu sed Gets a value indicating \Vhether this elen1ent 113s keyboard focus. This
is a dependency property.
lsKe:yboardFocu
sWithin Gets a value i11dicating whether keyboard focus is auywhere within the
element or its visual tree child elen1ents. This is a depe11dency
property.
I sLoaded Gets a value that indicates whether this element has been loaded for
presentation.
IsManipulationEnabled Gets or sets a value that indicates whether manipulation events are
enabled on this UIElement.
IsMeasureValid Gets a value indicating whether the curre11t size retun1ed by layout
measure is valid.
IsMouscCa11tured Gets a value indicating whether the mouse is capttued to this element.
This is a dependency property.
IsMouseCaptureWithin Gets a value that detennines whetl1er mouse capttue is held by this
element or by child elements in its visual tree. This is a dependency
pioperty.
414 I PowerShell Studio - A Comprehensive Guide
IsMouseDirectlyOver Gets a value that indicates whether the position of the mouse pointer
corresponds to hit test results, whicl1 take element compositing into
account. This i s a dependency property.
IsMouseOver Gets a value indicating whether the mouse poit1ter is located over tllis
element (including child elements in the visual tree). This is a
dependency property.
IsScaled Gets a value that indicates whether this instance is currently sealed
(read-only).(Inherited fron1 DependencyObject.)
IsStylusCaptured Gets a value indicating whether the stylus is cap1:u red by this eleme11t.
This is a dependency property.
IsStyJusCaptureWithin Gets a value that detennines whether stylus capture is held by this
ele1nent, or an element vvithin the element botu1ds and its visual tree.
This is a dependency property.
IsStylusDirectlyOver Gets a value that indicates whether tl1e stylus position corresponds to
llit test results, which take element compositing il1to account. This is a
dependency property.
IsStylusOver Gets a value indicating whether the stylus cursor is located over tllis
ele111ent (including visual child ele1nents). TJlis is a dependency
property.
IsSynchronizedWithCurrentltem Gets or sets a value that indicates whether a Selector should keep tl1e
Selectedltem synchronized with the current item in the Items property.
(Inherited fron1 Selector.)
IsTabStop Gets or sets a value that indicates vvhether a control is included in tab
navigation.
lsTextSearchCaseSensitive Gets or sets a value that indicates vvhether case is a co11dition "\tvben
searclling for items.(Inberited from ItemsControl.)
IsTextSearchEnabled Gets or sets a value that il1dicates vvhether TextSearcl1 is enabled on
the ItemsControl instance.
IsVisible Gets a value indicati11g whether this element is visible in the user
interface (UT). This is a dependency property.
ltemBindingGroup Gets or sets the BindingGroup that is copied to each item in the
ItemsControl. (Inherited from Iten1sControl.)
ItemContainerGenerator Gets the ItemContainerGenerator that is associated with the control.
ItemContainerStyle Gets or sets the Style that is applied to the container element generated
for each ite1n.
ItemContainerStyleSelecto1 Gets or sets ClIStom style-selection logic for a sty le that can be applied
to each generated co11tainer elen1ent.
Items Gets the collection used to generate the content of the
Iten1sControl.(lnherited fro1n Ite1nsControl.)
ItemsPanel Gets or sets the template that defines the panel that controls the layout
of iten1s.
ItemsSource Gets or sets a collection used to generate the content of the
ItemsControl.
ltemStringFonnat Gets or sets a composite string that specifies ho'v to format the items in
the lte1nsControl if they are displayed as stJ.ings.(111.herited from
ItemsControl.)
Item Template Gets or sets the DataTemplate used to display each item .
PowerShell Studio- Reference Guide. I 415
ItemTemplateSelecto r
Gets or sets the custom logic for choosing a template used to display
each item.
Language Gets or sets localization/globalization lai1guage infon11ation that
applies to all eleme11t.
LayoutTransform Gets or sets a graphics trailSfonnation that should apply to this element
when layot1t is performed.
LogicalChildren Gets an enumerator fo r tl1e logical child objects of tJ1e lten1sControl
object.(Inherited fro111 ltemsControl.)
Margin Gets or sets the outer margin of all element.
MaxHeight Gets or sets tl1e maximmn height constraint of the ele1nent.
MaxWidth Gets or sets t11e maximum width constraint of the element.
MinHeight Gets or sets the 111ini1numheight constraint of the ele1nent.
MinWidth Gets or sets the minimiun width constraint of the ele1nent.
Name Gets or sets t11e identifyil1g nan1e of the element. The name provides a
reference so that code-behind, such as event handler code, can refer to
a inarkup element after it is constn1cted during processing by a XAJ\.1L
processor.
Opacity Gets or sets the opacity factor applied to the entire UIElement \Vhen it
is rendered in the user interface (UI). This is a dependency property.
OpacityMasi< Gets or sets an opacity mask. as a Brush iniplen1entation that is applied
to any alpha-cham1el n1asking for the rendered content of this ele1nent.
Tltis is a dependency property.
OverridesDefaultStyle Gets or sets a value that il1dicates whether this element incorporates
style properties fro1n theme sty les.
Padding Gets or sets the padding inside a control.
Parent Gets the logical parent ele1nent of this element.
Persistld Obsolete. Gets a value that uniquely ide11tifies this element.
RenderSize Gets (or sets, but see Re1narks) the final render size of this element.
RenderTransform Gets or sets transform information that affects the rendering position of
this eleme11t. This is a dependency property.
RenderTransformOrigin Gets or sets the center point of any possible render transform declared
by RenderTransfonn, relative to the bounds of the element. This is a
dependency property.
Resources Gets or sets t11e locally-defined resource dictionary.
Selectedlndex Gets or sets the index of the first item in the current selection or returns
negative one (-1) if the selection is empty. (Inherited from Selector.)
Selectedltem Gets or sets the first ite1n in the current selection or returns ntill if the
selection is empty (Inherited from Selector.)
Selectedltems Gets the currently selected items.
SelectedValue Gets or sets the value of the Selectedltem, obtained by using
SelectedValuePath. (Inherited from Selector.)
SelectedValuePath Gets or sets the path t11at is used to get the SelectedValue from the
Selectedltem. (Inherited from Selector.)
SelectionMode Gets or sets the selection behavior for a ListBox.
416 I PowerShell Studio-A Comprehensive Guide
SnapsToDevicePixels
Gets or sets a value that determines whetheI rendering for this element
sholtld use device-specific pixel settings during rendering. This is a
de_pende11cy property.
Style Gets or sets the sty le used by this ele111ent when it is rendered.
StylusPluglns Gets a collection of all stylus plug-in (customization) objects
associated with this ele1ne11t.
Tab Index Gets or sets a value that determines tl1e order in which elements
receive focus when the user navigates through controls by using the
TAB key.
Tag Gets or sets an arbitrary object value that can be used to store custom
information about this element.
Tem]llate Gets or sets a control template.
TemplatedParent Gets a reference to the template parent of this element. This property is
not relevant if the element \.vas not created through a template.
ToolTip Gets or sets the tool-tip object that is displayed for this element in the
user interface (UI).
TouchesCa1>tured Gets all touch devices that are captured to this ele1nent.
TouchesCa1>turedWithin Gets all touch devices that are captured to this element or any child
eletnents in its visual tree.
ToucbesDirectlyOver Gets all touch devices that are over this element.
TouchesOver Gets all touch devices that are over this element or any child elements
in its visual tree.
Triggers Gets the collection of triggers established directly on this element, or
in child elements.
U.id Gets or sets the unique identifier (for localization) for this eletnent.
This is a dependency property.
U seLayoutRounding Gets or sets a value that indicates "vhether layout roundi11g should be
applied to this ele1nent's size and position during layout.
VerticaW.ignment Gets or sets the vertical alignment characteristics applied to tllis
ele1nent when it is composed \.vithin a parent element sucl1 as a panel
or iten1s control.
VerticalContentAlignment Gets or sets the vertical aligrunent of the control's co11tent.
Vielv Gets or sets a11 object that defi11es ho,;v the data is styled and organized
in a ListVievv control.
Visibility Gets or sets the user interface (UI) visibility of tllis ele1nent. This is a
dependency property.
VisualBitmapEffect Obsolete.Gets or sets the BitmapEffect value for t11e Visual.
VisualBitmapEffectln put Obsolete. Gets or sets the BitmapEffectlnput value for the Vis11al.
VisualBitmapScaJingMode Gets or sets the Bit111apScalingMode for tl1e Visual.
V.isuaJCacheMode Gets or sets a cached representation of the Visual.
V.isu a1Children Count Gets the nwnber of visual child elements within this ele1uent.
V.isuaJClearTypeHint Gets or sets the ClearTypeHint that detennines how ClearType is
rendered in the Visual.
VisualClip Gets or sets the clip region of the Visual as a Geo1netry value.
VisualEdgeMode Gets or sets the edge mode of the Visual as an EdgeMode value.
Pow erShe ll Studio - Referen ce Guide I 417
Visu alEffect
Gets or sets the bitmap effect to apply to the Visual.
VisualOffsct Gets or sets the offset value of the visual object.
VisualOpacity Gets or sets the opacity of the Visual.
VisualOpacityMask Gets or sets the Bn1sh value that represents the opacity mask of the
Visual.
VisualParcnt Gets the vist1al tree parent of the visual object.
VisnaJScrollablcAreaClip Gets or sets a clipped scrollable area for the Visual.
VisualTextBintingMode Gets or sets tl1e TextHintingMode of the Visual.
VisualTcxtRenderingMode Gets or sets the TeAiRenderingMode of the Visual.
VisualTransfonn Gets or sets the Transform value for the Visual.
VisuaJXSnappingGuidelines Gets or sets the x-coordinate (vertical) guideline collection.
VisualYSnappingGuidelines Gets or sets they-coordinate (horizontal) gt1ideline collection.
Width Gets or sets the width of the element.
MASKEDTEXTBOX
Accepts Tab Gets or sets a value deten1lining ho'iV TAB keys are handled for
inultiline coufigurations. This property is not supported by
MaskedTextBox.
AccessibilityObject Gets the AccessibleObject assigned to the control.
Accessib.leDefaultActionDescription Gets or sets the default action description of tl1e control for use by
accessibility client applications.
Accessi bleDescri11tiou Gets or sets the description of the control used by accessibility
client applications.
AccessibleName Gets or sets the name of the control u sed by accessibility client
applications.
AccessibleRole Gets or sets the accessible role of the contTol
AllowDro1> Gets or sets a value indicating whether the control can accept data
that the user drags onto it.
AllowPromptAslnput Gets or sets a value indicating whether Pro1nptCbar can be entered
as valid data by the user.
Anchor Gets or sets the edges of the container to which a control is bound
and detemlines how a control is resized with its parent.
AsciiOnly Gets or sets a value indicating ,;vhether the MaskedTeA1Box
control accepts characters outside of the ASCII character set.
AutoScrollOffset Gets or sets where this control is scrolled to in
Scroll ControllntoView.
AntoSize Gets or sets a value indicating whether the height of the control
automatically aqjusts when the font assigned to tl1e control is
changed.
BackColor Gets or sets the background color of tl1e contr:ol.
418 I PowerShell Studio - A Comprehensive Guide
Backgroundlm age This API supports the product infrastructure and is not intended to
be used directly frotn your code. Tb.is property is not relevant for
this class.
BackgroundlmageLayout This API supports the product infrastructure and is not intended to
be used directly from your code. Tb.is property is not relevant for
this class.
BeepOnError Gets or sets a value indicating wl1ether the masked teA1 box
control raises tl1e system beep for eacl1 user key stroke that it
rejects.
BindingContext Gets or sets the BindingConteA1 for the control.
BorderStyle
Gets or sets tl1e border type of the text box control.
Bottom Gets tl1e distance, in pixels, between the bottom edge of the
control and the top edge of its container's client area.
Bounds Gets or sets the size and location of the control including its
nonclient elements, in pixels, relative to the parent control.
CanEnablelme Gets a value indicating \vhether the ImeMode property can be set
to an active value, to enable Ilv1E support.
CanFocus Gets a value indicating \vl1ether tlle control can receive focus.
CanRaiseEvents Determines if events can be raised on the control.
Can Select Gets a value indicating whether the control can be selected.
CanUndo Gets a value it1dicating \Vhether tl1e user can undo the previous
operation. This property is not supported by MaskedTexffiox.
Ca1>ture Gets or sets a value indicating \vhether the control has captured
tl1e IDOllSe.
CausesValidation Gets or sets a value indicating \hetber the control causes
validation to be perfo1med on any controls that require validatio11
when it receives focus.
ClientRectan gle Gets the rectangle that represents tlle client area of the control.
ClientSize Gets or sets the height and width of tbe client area of the control.
CompanyName Gets tbe name of the co1npany or creator of the application
containing the control.
Container Gets the !Container that contains the Component.
ContainsFocus Gets a value indicating whether the control, or one of its child
controls, clrrrently has the input focus.
CootextMenu Gets or sets U1e sho1tcut menu associated with the control.
ContextMeouStrip Gets or sets the ContextMenuSttip associated \Vitl1 this control.
Controls Gets the collection of controls contained within tl1e control.
Created Gets a value indicating whether tlle control has been created.
CreateParams Gets the required creation paraineters when the control hand1e is
created. (Overrides TextBoxBase. CreateParams.)
Culture Gets or sets the culture information associated \Vitb the 1nasked
teA1 box.
Cursor Gets or sets the cursor that is displayed \Vl1en tl1e inouse pointer is
over the co11trol.
PowerShell Studio - Referen ce Guide. I 419
CutCopyMask:Format Gets or sets a value that detenni11es \.Vhether literals and prompt
characters are copied to the clipboard.
DataBindings Gets the data binclings for the control
DefaultCursor Gets or sets the default ctusor for the control.
DefaultlmeMode Gets tl1e default Input Method Editor (IME) mode supported by
t11e control.
DefaultMargin Gets tl1e space, in pixels, that is specified by default between
controls.
Defau ltMa:l.imumSize Gets the length and height, in pixels, that is specified as the default
maximun1 size of a control.
DefaultMinimumSize Gets the length and height, in pixels, that is specified as the default
minimum size of a control.
DefaultPadding Gets tl1e internal spacing, in pLxels, of the contents of a control.
DefaultSize Gets the default size of the control.
DesignMode Gets a value that indicates wl1ether the Component is Cl1rrently in
design mode.
DisplayRectangle Gets tl1e rectangle that represents the display area of the control.
Disposing Gets a value indicating whether the base Control class is in the
process of disposing.
Dock Gets or sets whicl1 control borders are docked to its parent control
and detennines ho\;y a control is resized \.Vith its parent.
Dou bleBuffered This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets a value indicating
\.Vhether control drawing is done in a buffer before the contiol is
displayed. This property is not relevant for this class.
Enabled Gets or sets a value i11dicating whether the control can respond to
user interaction.
Events Gets tl1e list of event liandlers tliat are attached. to this Component.
Focused Gets a value i11dicating whether the control has input focus.
Font Gets or sets the font of the text displayed by tl1e control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
FormatProvider Gets or sets the IFonnatProvider to use when perfon11ing type
validation.
Handle Gets the windovv handle that the control is bound to.
Has Children Gets a value indicating whether tl1e control contains one or more
child controls.
Height Gets or sets the height of the control.
HidePromptOnLeave Gets or sets a value indicating whether the pro1npt characters in
the input mask are hidden when the masked te:x.'t box loses focus.
HideSelection Gets or sets a value indicating whether the selected teA1 in tl1e text
box control remains highlighted when tl1e control loses focus.
ImeMode Gets or sets the Input Method Editor (Thffi) mode of the control.
ImeModeBase Gets or sets the Input Method Editor (IME) mode of a control.
420 I PowerShell Studio - A Comprehensive Guide
Inse11KeyMode Gets or sets the text insertion inode of the masked text box
control.
InvokeRequired Gets a value indicating whether the caller must call an invoke
method when making method calls to the control because the
caller is on a different tlu:ead than the one the control was created
on.
lsAccessible Gets or sets a value indicating wl1ether the control is visible to
accessibility applications.
IsDisposed Gets a value indicating whether the control has been disposed of.
IsHanclleCreated Gets a value indicating whether the control l1as a 11andle associated
with it.
IsMirrored Gets a value indicating whether the control is mirrored.
lsOve1\vriteMode Gets a value that specifies whether new user input overwrites
existing input.
LayoutEngine Gets a cacl1ed instance of the control's layout engine.
Left Gets or sets the distance, in pixels. betwee11 the left edge of the
control and the left edge of its container's client area.
Lines Gets or sets the lines of text in multi line configurations. This
property is not supported by MaskedTeA.1Box.
Location Gets or sets tl1e coordinates of the upper-left comer of the control
relative to the upper-left con1er of its container.
Margin Gets or sets the space between controls.
Mask Gets or sets tl1e input mask to use at nm ti1ne.
MaskCompleted Gets a value indicatil1g whetl1er all required inputs have been
entered into the input mask.
Masked TextProvider Gets a clone of the inask provider associated \.Vith this instance of
tl1e masked text box control.
MaskFull Gets a value indicating whether all required and optional inputs
have been entered into the input mask.
MaximumSize Gets or sets the size that is the upper limit that GetPreferredSize
can specify.
MaxLength Gets or sets t11e 1naxin1um number of characters the user can type
or paste into tl1e teA.1 box control. This property is not supported
by .MaskedTeA.t Box. (Overrides TextBoxBase.MaxLength.)
Minimu mSize Gets or sets the size that is the lower linrit that GetPreferredSize
can specify.
Modified Gets or sets a value that indicates tliat the teA.'t box control has
been modified by the user si11ce tl1e control was created or its
co11tents were last set.
Multiline Gets or sets a value indicating wl1ether this is a mttltiline teJ\1 box
control. This property is not frilly supported by MaskedTextBox.
(Overrides TeA1BoxBase.Multi line.)
Name Gets or sets the naine of the control.
Padding Tlris APJ supports the product infrastructure and is not intended to
be used directly from your code. This prope11y is not relevant for
tllis class.
Parent Gets or sets the parent container of the control.
PowerShell Studio - Reference Guide. I 421
MENUSTRIP
,
AccessibilityObject Gets tl1e AccessibleObject assigned to the control.
AccessibleDefaultActionDescri1>tion Gets or sets the default action description of the control for use
by accessibility client applications.
AccessibleDescription Gets or sets the description of the co.ntrol used by accessibility
client applications.
AccessibleN ame Gets or sets the name of the control used by accessibility client
applications.
Accessible~oJe Gets or sets the accessible role of the control
AllowDrOJ> Gets or sets a value i.ndicatin.g whether drag-and-drop and item
reorde1ing are handled through events that you in1plen1ent.
AllowItemReorder Gets or sets a value indicating whether drag-and-drop and item
reordering are handled privately by the ToolStrip class.
AllowMerge Gets or sets a value indicating \.Vhether multiple MenuStrip,
ToolStripDropDownMenu, ToolStripMenuiten1, and other types
can be combined.
PowerShell Studio - Reference Guide. I 423
ContextMenu Gets or sets the shortcut menu associated \Vith the control.
ContextMenuStrip Gets or sets the Co11textMenuStrip associated \Vith this control.
Controls This API supports the product infrastruct1ue and is not intended
to be used directly from your code. This property is not relevant
for this class.
Created Gets a value indicating whether tl1e control has been created.
CreatcParams Gets the required creation para1neters 'vhen the control handle is
created.
Cursor Gets or sets the cursor that is displayed when the mouse pointer
is over tl1e ToolStrip.
DataBindings Gets the data bindings for the control.
DefaultCursor Gets or sets the defatdt cursor for the co11trol.
DefaultDock Gets the docking location of the ToolStrip, indicating \vllich
borders are docked to the container.
DefauJtDropDownDirection Gets or sets a value represe11ting tl1e defatdt direction in which a
Too1StripDropDo'1vn control is displayed relative to the
ToolStrip.
DefaultGripMargin Gets the default spacing, in pL"Xels, bet\veen the sizn1g g1ip and
the edges of the MenuStrip.(Overrides
ToolStrip.DefaultGripMargin.)
DefaultlmeMode Gets the default Input Method Editor (IlvfE) mode supported by
the control.
DefaultMargin Gets the spacing in pixels, bet\veen tl1e ToolStrip and the
ToolStripContainer.
DefaultMa:ximu mSize Gets tl1e lengtl1 and height, in pixels, that is specified as the
default maximtun size of a control.
DefaultMinimumSize Gets the length ai1d height, in pixels, that is specified as the
default minimu1n size of a control.
DefaultPadding Gets the spacing in pixels, benveen the left, right, top, and
bottom edges of the Menus trip from the edges of the
f otm. (Overrides ToolStrip.Defa1dtPadding.)
DefaultSholvltemToolTips Gets a value indicating \hether ToolTips are sho'1vn for the
MenuStrip by default.(Overrides
ToolStrip.DefaultShowltemToolTips.)
DefauJtSize Gets the 11orizontal and vertical din1ensions, in pixels, of the
MenuStrip when it is first created.(Overrides
ToolStrip.DefaultSize.)
DesignMode Gets a value that indicates whether the Co1nponent is cturently
in design n1ode.
Dis1llayedltcms Gets the subset of ite.ms that are currently displayed on the
ToolStrip, including ite1ns that are automatically added into the
ToolStrip.
DisplayRectangle This API supports the product infrastructtue and is not intended
to be used directly from your code. Retrieves the current display
rectangle.
Disposing Gets a value indicating \Vhether the base Control class is in the
process of disposing.
PowerShell Studio - Reference Guide. I 425
Dock Gets or sets which ToolStrip borders are docked to its parent
control and determines 11ow a ToolS trip is resized with its
parent.
DockPadding Gets the dock padding settings for all edges of tl1e control.
DoubleBuffered Gets or sets a value .indicating \V hetl1er this control should
redra\v its surface using a secondary buffer to red11ce or prevent
flicker.
Enabled Gets or sets a value indicating whether the control can respond
to user interaction.
Events Gets the list of event handlers that are attached to tllis
Component.
Focused Gets a value indicating whetl1er the control has input focus.
Font Gets or sets the font used to display text in t11e control.
FontHeight Gets or sets t11e height of the font of tl1e control.
ForeColor Gets or sets the foreground color of the ToolStrip.
GriJlDisplayStyle Gets the orientation of the ToolS trip move 11andle.
GripMargin Gets or sets the space around the ToolStiip 1nove ha11dle.
GripRectangle Gets the botu1daries of the ToolStrip move haI1dle.
Grit>Style Gets or sets the visibility of the grip used to reposition U1e
control.
Handle Gets the windo"v handle tliat the control is bound to.
Has Children This API supports the product infrastructure and is not intended
to be used directly from your code. This property is not relevant
for this class.
Height Gets or sets the height of the control.
HorizontaJScroll Tlris API supports the product infrastntctme and is not intended
to be used directly fron1 your code. This property is not relevant
for tl1is class.
HScroll Gets or sets a value indicating whether the horizontal scroll bar
is visible.
ImageList Gets or sets the image list tliat contains the image displayed on a
Too lStrip ite1n.
ImageScalingSize Gets or sets the size, in pixels, of an image used on a ToolStrip.
ImeMode Gets or sets the Input Method Editor (IME) rnode of the control.
lmeModeBase Gets or sets the IME mode of a control.
InvokeRequired Gets a value indicating \Vhether the caller must call an invoke
method when n1aking 1netl1od calls to the control because tl1e
caller is on a different thread than the 011e the control 'vas
created ou
IsAccessible Gets or sets a value i11dicating whether the control is visible to
accessibility applications.
lsCurrentlyDragging Gets a value indicating whether the user is currently moving the
ToolStrip from one ToolStripContainer to anotl1er.
IsDisposed Gets a value indicating whetl1er the control has been disposed
of.
IsDropDown Gets a value indicating whether a ToolStrip is a
ToolStripDropDown control.
IsHandleCreated Gets a value indicating whether the control bas a handle
associated \Vith it.
426 I PowerShell Studio - A Comprehensive Guide
MONTHCALENDAR
AnnuallyBoldedD ates Gets or sets the array ofDateTime objects that detennines which
annual days are displayed in bold.
AutoScrollOfl'set Gets or sets vvhere this control is scrolled to in
ScrollControllntoView.
Auto Size This AP! supports the product infrastructure and is not intended to
be used directly from your code. This property is 11ot relevant for
this class.
Bacl<Color Gets or sets the background color for the control.(Overrides
Control.BackColor.)
Backgroundlmage This API supports the product infrastn1cture and is not intended to
be used directly from your code. Gets or sets tl1e background image
for the MonthCalendar(Overrides Control.Backgroundlrnage.)
Backgroundlm ageLayout This API supports the product infrastn1cture and is not intended to
be used directly from your code. Gets or sets a value il1dicating the
layout for the Backgroundlmage.(Overrides
Co11trol.BackgroundI1nageLayout.)
BindingContext Gets or sets the BindingContex't for the control.
BoldedDates Gets or sets the array of DateTime objects that determines which
nonrecurring dates are displayed in bold.
Bottom Gets the distance, in pixels, between the bottom edge of the control
and the top edge of its container's client area.
Bounds Gets or sets the size and location of the control including its
nonclient ele111ents, in pixels, relative to the parent control.
CalendarDimensions Gets or sets tl1e number of columns and rows of 1nonths displayed.
CanEnablelme Gets a value indicating ~ hether the ImeMode property can be set to
ai1 active value, to enable IME support.
CanFocus Gets a value indicating whetl1er the control can receive focus.
Can RaiseEvents Detennines if events can be raised on the control.
Can Select Gets a value indicating whether the control can be selected.
Ca1>ture Gets or sets a value indicating wl1ether the control bas captured the
1nouse.
CausesVaJidation Gets or sets a value indicating whether tl1e control causes validation
to be perfonned on any controls that require validation wl1en it
receives focus.
ClientRectan gle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height and width of the client area of the control.
Com1>anyName Gets the name of the company or creator of the application
containing tl1e control.
Container Gets the !Container that contains the Component.
ContainsFocus Gets a value indicating whetl1er the contro~ or one of its child
controls, Currently has tl1e input focus.
ContextMenu Gets or sets the shortcut menu associated with the control
ContextMenuStrip Gets or sets the ContextMenuStrip associated witl1 this control.
Controls Gets the collection of controls contained within the control
Created Gets a value indicating whether the control has been created.
PowerShell Studio - Reference Guide I 429
InvokeRequired
Gets a value indicating whether the caller must call an invoke
method when making method calls to the control because the caller
is on a different tluead than the one the control ,vas created on.
IsAccessibJe Gets or sets a v alue indicating whether tl1e control is visible to
accessibility applicatio1is.
lsDisposed Gets a value indicating whether the control has been disposed of.
lsHandleCreated Gets a value indicating whether tl1e control has a handle associated
with it.
IsMirrored Gets a value indicating whether the control is mirrored.
LayoutEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the distance, in pixels, between tl1e left edge of the
control and the left edge of its container's client area.
Location Gets or sets tl1e coordinates of the upper-left corner of the control
relative to tl1e upper-left comer of its container.
Margin Gets or sets the space bet"\>veen controls.
MaxDate Gets or sets the 1naximurn allowable date.
Maximu mSize Gets or sets the size tllat is the upper limit that GetPreferredSize
can specify .
MaxSelection Coo nt Gets or sets the inax.imum nu1nber of days tl1at can be selected in a
montl1 calendar control.
Min Date Gets or sets the minimum allo"vable date.
MinimumSize Gets or sets the size that is the lower linlit that GetPreferredSize
can specify.
MonthlyBoJdedDates Gets or sets the array of DateTi1ne objects that detennine "vhich
montltly days to bold.
Name Gets or sets the name of ll1e control.
Padding This API supports the product infrastruchrre and is not intended to
be used directly from your code. Gets or sets the space between the
edges of a MonthCalendar control and its contents.
Parent Gets or sets tl1e parent container of the control.
PreferredSize Gets the size of a rectangular area into which tl1e coritrol can fit.
ProductN ame Gets the product name of the assembly co11taining the control.
ProductVersion Gets the version of the assembly contaiiling the control.
Recreatin gHandle Gets a value indicating \.vhether the control is CUITently re-creating
its handle.
Region Gets or sets the window region associated with the control.
RenderRightToLeft Obsolete.This property is now obsolete.
ResizeRedraw Gets or sets a value indicating "\>vhether the control redraws itself
when resized.
Right Gets the distance, i11 pixels, betieen tl1e right edge of the control
and tl1e left edge of its container's client area.
RightToLeft Gets or sets a value indicating whether control's elements are
aligned to support locales 11sing right-to-left fonts.
RigbtToLeftLayout Gets or sets a value indicating whether tl1e control is laid out fron1
right to left.
PowerShell Studio - Reference Guide. I 431
[
ScaleChildren Gets a value tbat detenni nes the scaling of child controls.
Scroll Change Gets or sets the scroll rate for a month calendar control.
SelectionEnd Gets or sets the end date of the selected range of dates.
SelectionRange Gets or sets the selected range of dates for a montl1 calendar
control.
SelectionStart Gets or sets the start date of tl1e selected range of dates.
ShowFocusCues Gets a value indicating vvhether the control should display focus
rectangles.
SholvKeyboard Cu es Gets a value i11dicatiJ.1g wl1ether the user interface is in the
appropriate state to show or hide keyboard accelerators.
Gets or sets a value indicating 'vhetl1er the date represented by the
TodayDate property is displayed at the botto1u of tl1e control.
ShowTodayCircle Gets or sets a value indicating 'vl1ether today's date is identified
witl1 a circle or a square.
ShowWeekNumbers Gets or sets a value indicating \vhether the montl1 calendar control
displays "veek numbers (1-52) to the left of each row of days.
SingleMontbSize Gets the minimum size to display one month of the calendar.
Site Gets or sets the site of the control.
Size Gets or sets the size of the MonthCalendar control.
Tab Index Gets or sets the tab order of the control within its container.
TabStop Gets or sets a value indicating whetl1er tl1e user can give tl1e focus
to this control using the TAB key.
Tag Gets or sets the object that contains data about the control.
Text This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets the text to display on
the MonthCalendar.(Overrides Control.TeA1.)
TitleBacl\:COIO r Gets or sets a value indicating the background color of the title area
of tl1e calendar.
TitleForeColor Gets or sets a value indicating the fore ground color of the title area
of the calendar.
TodavDate
Gets or sets the value tliat is used by MonthCalendar as today's
date.
TodayDateSet Gets a value indicating w hetber the Today Date property has been
explicitly set.
Top Gets or sets the distance, in pixels, between the top edge of the
control and the top edge of its container's client area.
To1>LevelControl Gets the parent control that is not parented by anotl1er Windows
Forms control. Typically, tlris is the outermost Fom1 that the
control is contained in.
TrallingForeColor Gets or sets a value indicating the color of days in montl1s that are
not fully displayed in the control.
UseW aitCursor Gets or sets a value indicatingwhetl1er to use the wait cursor for the
current control and all child controls.
Visible Gets or sets a value indicating 'vhetl1er the control and all its child
controls are displayed.
Width Gets or sets the width of the control.
432 I PowerShell Studio - A Comprehensive Guide
Window Target This API supports the product infrastructure and is not intended to
be used directly from your code. This property is not relevant for
tllis class.
NOTIFYICON
PROPERTY DESCRIPTION
BalloonTipIcon Gets or sets the icon to display on tl1e balloon tip
associated with the Notify Icon.
Balloon Tip Text Gets or sets the text to display on the balloon tip
associated with the NotifyIcon.
BalloonTip Title Gets or sets the title of the balloon tip displayed on the
Notify Icon.
Container I Gets the !Container that contains the Component.
ContextMenu Gets or sets the shortcut inenu for the icon.
ContextMenuStrip Gets or sets the shortcut inent1associated with the
I Notify Icon.
Icon Gets or sets the current icon.
Site Gets or sets the ISite of the Component.
Tag Gets or sets an object that contains data about the
Notify Icon.
Text Gets or sets the ToolTip text displayed \vhen the
inouse poi.J1ter rests on a notification area icon.
Visible Gets or sets a value indicating \.vhether the icon is
visible in the notification area of the taskbar.
NUMERICUPDOWN
Capture Gets or sets a value indicating whether the control has captured
tl1e mouse.
CausesValidation Gets or sets a value indicating 'vhether the control causes
validation to be performed on any controls that require validation
whe11 it receives focus.
ChangingTex1 Gets or sets a value indicating whether the text property is being
changed intenlally by its parent class.
ClientRectan gle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height ai1d width of the client area of tl1e control.
CompanyName Gets the name of the co111pany or creator of the application
containing the control.
Container Gets the !Container that contains the Component
ContainsFocus Gets a value indicating whether the control, or 011e of its child
controls, currently has the input focus.
ContextMenu This API supports tl1e product infrastructure and is not intended
to be used directly from your code. Gets or sets the shortct1t
n1enu associated with the spin box (also known as an up-do\vn
co11trol).
ContextMenuStrip Gets or sets 01e shortcut 111enu for the spin box (also kno,vn as an
up-do,vu control).
Controls Gets the collection of controls contained within the control.
Created Gets a value indicatiug \vhether the control has been created.
CreateParams This API suppo11s the product infrastructure and is not inteuded
to be used directly fro1n your code. Gets the required creation
paraineters when the control handle is created.
CurrentAutoScaleDimensions Gets the ct1rrent n1n-ti111e dimensions of the screen.
Cursor Gets or sets the cursor that is displayed when the mouse pointer
is over the control.
DataBindings Gets the data bindings for the control.
DecimalPlaces Gets or sets the number of decimal places to display in the spin
box (also known as an up-dowi1 co11trol).
DefaultCursor Gets or sets the default cursor for the control.
DefaultlmeMode Gets the default Input Method Editor (IME) mode supported by
the control.
DefaultMargin Gets the space, in pixels, that is specified by default bet"veen
controls.
DefanltMaximumSize Gets the length and height in pixels that is specified as the
defatilt maximum size of a coutrol.
DefaultMinimumSize Gets the length and height, iI1 pixels, that is specified as the
default nriuimwn size of a control.
DefaultPadding Gets the internal spacing, in pixels, of tl1e co11tents of a co11trol.
DefaultSize Gets the default size of the control.
DesignMode Gets a value that indicates whether the Component is currently in
design mode.
DisplayRectangle Gets the recta11gle tl1at represents the virtual display area of the
control.
PowerShell Studio - Reference Guide I 435
Disposing Gets a value indicating whether the base Control class js in the
process of disposing.
Dock Gets or sets which control borders are docked to its parent
control and determines how a co11trol is resized ,;vitl1 its parent.
DockPadding This API supports the product infrastnicture and is not intended
to be used directly from your code. Gets the dock padding
settings for all edges of the UpDownBase control.
DoubleBuffered Gets or sets a value indicating whether this control should redraw
its surface using a secondary buffer to reduce or prevent flicker.
Enabled Gets or sets a value indicating whether the control can respond to
user interaction.
Events Gets tl1e list of event handlers tliat are attached to this
Compo neut.
Focused Gets a value indicating whether the control has input focus.
Font Gets or sets the font of the te;x.'t displayed by the control.
FontHeight Gets o:r sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the spit1 box (also known as
an up-down control).
Handle Gets the windo"v handle that the control is bo1u1d to.
Has Children Gets a value indicating whether the control contains one or more
child controls.
Height Gets or sets the height of the control.
Hexadecimal Gets or sets a value indicating \vhether the spin box (also known
as an up-down control) should display the value it contains in
hexadecin1al fonnat.
Ho rizontaJScroU Gets the characteristics associated 'ith tl1e ho1izontal scroll bar.
HScroll Gets or sets a value indicating ,;vhether the horizontal scroll bar is
visible.
ImeMode Gets or sets the Input Method Editor (Thtffi) mode of the control
I:mcModeBase Gets or sets the IME niode of a control.
Increment Gets or sets the value to increment or decrement tl1e spin box
(also known as an up-do,~11 control) when the up or down bl1ttons
are clicked.
InterceptArrowKeys Gets or sets a value indicating '\-Vhether the user can use the UP
ARROW and DOWN ARROW keys to select values.
InvokcRequired Gets a value indicating whether the caller must call an invoke
method whe111naking 1nethod calls to tl1e co11tTol because the
caller is on a different thread than the one the control was created
on.
IsAccessible Gets or sets a value indicating ,;vhether the control is visible to
accessibility applicatio11s.
IsDisposed Gets a value indicating whether the control has bee11 disposed of.
IsHandleCreated Gets a value indicating wl1ether the control has a handle
associated with it.
IsMirrored Gets a value indicating whether the control is 1nirrored.
436 I PowerShell Studio - A Comprehensive Guide
Tab Index Gets or sets the tab order of the control witltin its container.
Tab Stop Gets or sets a value indicating whether the user can give the
focus to this control using the TAB key.
Tag Gets or sets the object that contains data about the control.
Text This API supports the product infrastructure and is not intended
to be used directly fron1 your code. Gets or sets the text to be
displayed in the NwnericUpDown control.(Overrides
UpDownBase.Text.)
TextAlign Gets or sets the alignment of the text in the spin box (also knovvn
as an up-down control).
TbonsandsSe11arator Gets or sets a val11e indicating vvhether a thousands separator is
displayed in the spin box (also knov.in as an up-do,vn control)
~;vhen appropriate.
TO)l Gets or sets the distance, in pixels, betvveen the top edge of the
control and the top edge of its container's client area.
TopLeveJControl Gets the parent control that is not parented by another Windo,;vs
F onns control. Typically, this is the outennost Fonn that the
co11trol is contained in.
UpDownAlign Gets or sets the aligrunent of the up and down buttons on the spin
box (also kno\vn as an up-down control).
UserEdit Gets or sets a value indicating whether a value has been ei1tered
by the user.
UseW aitCu rso r Gets or sets a value indicating whether to use the wait cursor for
the current control and all child controls.
Value Gets or sets the value assigned to the spi11 box (also knovvn as an
up-down control).
VerticalSci-oll Gets the characteristics associated \Vith the vertical scroll bar.
Visible Gets or sets a value indicating \vhether the control and all its
cllild controls are displayed.
VScroll Gets or sets a value indicating \vhether the vertical scroll bar is
visible.
Width Gets or sets the width of the control
Window Target This API supports the product infrastn1cture and is not intended
to be used directly from your code. This property is not relevant
for this class.
OPENFILEDIALOG
AutoUpgradeEnabled Gets or sets a value indicating 'vhether tllis FileDialog instance should
automatically upgrade appearance and behavior when running on Windows
Vista and above.
CbeckFileExists Gets or sets a value indicating whether the dialog box displays a warning if
the user specifies a file name that does not exist. (Overrides
FileDialog.CheckFileExists.)
438 I PowerShell Studio - A Comprehensive Guide
I
I
CheckP athExists Gets or sets a value indicating whether the dialog box displays a warning if
the user specifies a path that does not exist. (Inherited fro1n FileDialog.)
Container Gets the !Container that contains the Component. (lnhe1ited fro111
Component.)
CustomPlaces Gets the custom places collection for this FileDialog instance. (Inherited
from FileDialog.)
DefaultExt Gets or sets the defa1Llt file na1ne e>..1ension. (111.herited from FileDialog.)
DereferenccLinks Gets or sets a value indicating whet11er the dialog box retil1rns the location of
the file referenced by the shortcut or \hether it returns the location of the
shortcut (. lnk). (Inl1erited fro1nFileDialog.)
FileNaine Gets or sets a string contai1ung the file name selected in the file dialog box.
(Inherited fro111FileDialog.)
FileNames Gets the file nan1es of all selected files in the dialog box. (Inherited fro1n
FileDialog.)
Filter Gets or sets the current file i1ame filter st1i ng, wluch detemlines the choices
that appear in t11e "Save as file type" or "Files of type" box in tl1e dialog box.
(hlherited fro1n FileDialog.)
FilterIndex Gets or sets the index of the filter currently selected in the file dialog box.
(Inherited from FileDialog.)
InitialDirectorv
Gets or sets t11e initial directory displayed by the file dialog box. (Inl1erited
fro1n FileDialog.)
Mu ltiselect Gets or sets a value indicating whether the dialog box allows inultiple files
to be selected.
Read OnlyChccked Gets or sets a value indicating whether the read-only check box is selected.
RestoreDirectory Gets or sets a value indicating whether the dialog box restores the directory
to tl1e previously selected directo1y before closing. (Inherited fro1n
FileDialog.)
SafeFileN ame Gets the file name and extension for the file selected in the dialog box. The
file name does not include the path.
SafeFileN aines Gets an array of file names and eA1ensions for all the selected files in the
dialog box. The file names do not include the path.
ShowHelp Gets or sets a value indicating whether the Help button is displayed in the
file dialog box. (l1lherited fro1n FileDialog.)
SholvReadOnly
Gets or sets a value indicating whether the dialog box contains a read-only
check box.
Site Gets or sets the !Site of the Component. (In11erited fro1n Component.)
Sup portMultiDottedExtensions Gets or sets whether the dialog box supports displaying and saving files that
have inultiple file name eA1ensions. (Inherited from FileDialog.)
Tag Gets or sets an object that contains data about the control. (Inl1erited from
Co mn10 nD ialo g.)
Title Gets or sets the file dialog box title. (Inherited fromFileDialog.)
ValidateNaines Gets or sets a value indicating whetl1er the dialog box accepts 01tly valid
Win32 file names. (Inhe1ited fro1n FileDialog.)
PANEL
PowerShell Studio - Reference Guide. I 439
r '
ActualHeight Gets the rendered height of this element.
ActualWidth Gets the rendered 'vidth of this eleme11t.
AllowDrop Gets or sets a value indicating '1vhether this element can be lISed as the
target of a drag-and-drop operation. This is a dependency property.
AreAnyTouchesCaptured Gets a value that indicates whether at least one tot1cl1 is capttued to this
element.
AreAnyTouchesCapturedWitbin Gets a value that indicates whether at least one touch is captured to this
elen1ent or to any child ele1nents in its visual tree.
AreAnyTouchesDirectlyOver Gets a value that indicates whether at least one touch is pressed over
this ele1nent.
AreAnyTouchesOver Gets a value that indicates whether at least one touch is pressed over
this element or any child elements in its visual tree.
Bacl<grouncl Gets or sets a Brush that is used to fill the area between tlle borders of
a Panel.
BindingGroup Gets or sets the BindingGroup that is used for the ele1nent.
BitmapEffect Obsolete.Gets or sets a bitmap effect that applies directly to tl1e
rendered content for this elen1ent. Th.is is a dependency property .
BitmapEffectlnput Obsolete. Gets or sets an input sotrrce for the bitmap effect that applies
directly to the rendered content for this ele1nent. This is a dependency
property.
CacheMode Gets or sets a cached representation of the UIElement.
Children Gets a UIEle1nentCollection of child ele1nents of this Panel.
Clip Gets or sets the geo1netJy used to define the outline of the contents of
an element. This is a dependency property.
Cli11T0Bounds Gets or sets a value indicating whether to clip the content of this
element (or content coining from the child ele1nents of this element) to
fit into the size of the contaiiring element. This is a dependency
property.
Command Bindings Gets a collection of Conm1a11d.Binding objects associated \Vitl1 tl1is
element. A Con1111and.Binding enables connnand handling for this
ele111ent, and declares tbe linkage between a cormnand its events, and
the ha11dlers attached by tllis element.
ContextMenu Gets or sets tbe context menu element that should appear whenever the
context iuenu is requested tlrrough user interface (Ul) fro1n within tllis
element.
Cursor Gets or sets the cursor that displays when the mouse pointer is over
tllis elen1ent.
DataConte:\'t Gets or sets the data conte>..1 for an elen1ent when it participates in data
binding.
DefaultStyleKey Gets or sets t11e key to use to reference t11e style for tllis control, when
theme styles are used or defined.
DependencyObjectType Gets the DependencyObjectType that '1vraps the CLR type of tllis
instai1ce. (Inherited from DependencyObject.)
DesiredSize Gets the size that this element computed during the measure pass of
the layou~rocess.
Dis11atcher Gets the Dispatcher this DispatcberObject is associated with. (Inherited
from DispatcherObject.)
440 I PowerShell Studio - A Comprehensive Guide
Effect Gets or sets the bitmap effect to apply to the UIEJement. This is a
dependency property.
FlowDirection Gets or sets the direction that text ru1d other user interface CUD
elements flo'v "vithin any parent element that controls their layout.
Focusable Gets or sets a value that indicates whether U1e elen1ent can recei e
focus. This is a dependency prope1ty.
FocusVisuaJStyle
Gets or sets a property that enables custonuzation of appearru1ce.
effects. or other sly le characteristics that \Vill apply to this ele1nent
when it capllrres keyboard focus.
ForceCursor Gets or sets a value that indicates "'' hether this Fra1ne\vork.Elen1ent
should force the user interface (UI) to render the cursor as declared by
the Cursor properly.
HasAnim atedP ro11erties Gets a value indicating \hether this elen1ent has any anilnated
properties.
HasEffectiveKevboardFocu
s Gets a value that indicates \:vhether the UIElen1ent has focus.
HasLogicaJOrien tation Gets a value that indicates \vhether this Panel arranges its descendants
in a single di1nension.
HasLogical01ientationPublic Gets a value that indicates \Vhether this Pa11el arranges its descendants
in a single dllnension.
Height Gets or sets the suggested height of the elc1nent.
HorizontalAlignment Gets or sets the 11orizontal alignment characteristics applied to this
ele1nent ' vhen it is composed \vithin a parent element. such as a panel
or ite1ns co11trol.
lnheritanceBehavior Gets or sets the scope li1nits for property value iI1heritance. resource
key lookup, and RelativeSource FindAncestor lookup.
lnputBindings Gets the collection of input bi11dings associated '"ith this element.
In11utScope Gets or sets tl1e context for input used by this Fr3111e\vorkElement.
lntemaJChildren Gets a UIElementCollection of child ele1nents.
lsArrangeValid Gets a value indicating vYhether the computed size and position of
child ele1nents in tlris element's layout are valid.
lsEnabled Gets or sets a value indicating vvhether this element is enabled in the
user interface (Ul). This is a dependency property.
IsEnabledCore Gets a value that becomes the return value of lsEnabled in derived
classes.
IsFocused Gets a value that detemlines \Vhether this element has logical focus .
This is a dependency property.
IsHitTestVisible Gets or sets a value that declares \vheU1er this ele1nent can possibly be
returned as a hit test result from some portion of its rendered content.
This is a dependency property.
lslnitialized Gets a value that indicates \vhether this element has been initialized,
either during processing by a XAML processor, or by explicitly having
its Endinit method called.
lslnputMethodEnabled Gets a value indicating v-Ybether an input n1ethod system~ such as an
Input Method Editor (IlvfE) is enabled for processing the input to this
element.
lsItem sHost Gets or sets a value that indlcates that this Panel is a container for user
interface (Ul) ite1ns that are generated by an Ite1nsControl.
PowerShe ll Studio - Refere nce Guide. I 441
IsKeyboardFocused '
Gets a value indicating whether this element has keyboard focus. This
is a dependency property.
IsKeyboardFocusWithin
Gets a value indicating whether keyboard focus is anywhere \Vithin the
element or its visual tree child elen1ents. This is a dependency
property.
IsLoaded Gets a value that indicates wl1ether this element has been loaded for
presentation.
IsManipulationEnabled Gets or sets a value that indicates whether manipulation events are
enabled on this UIElement.
IsMeasu reValid Gets a value indicating whether the current size returned by layout
measure is valid.
lsMouseC aptured Gets a value indicating ,;vhether the inouse is captured to this elen1e11t.
This is a depende11cy property.
IsMouseC aptu reWithin Gets a value that detennines wl1ether mouse capture is held by this
element or by child elements in its visual tree. This is a dependency
property.
IsMouseDirectlyOver Gets a value that indicates \vhether the position of the inouse pointer
corresponds to hit test results, \.Vhich take ele1nent compositing into
account. This is a dependency property.
l sMouseOver Gets a value indicating whether the 1nouse pointer is located over this
element (including child elements in the visual tree). This is a
dependency property.
IsSealed Gets a value that indicates whether this instance is currently sealed
(read-only).(lnherited fro1n DependencyObject.)
IsStylusCaptured Gets a value indicating whether the stylus is captured by this ele1nent.
This is a dependency property .
IsStylusCaptureWithin Gets a value that detennines whether stylus capture is held by this
elen1ent, or an ele1nent within the ele1nent bounds and its visual tree.
This is a dependency property.
lsStylusDirectlyOver Gets a value that indicates whether the stylus position co1responds to
hit test results, which take ele1nent co1npositing into account. This is a
dependency property.
IsStylusOver Gets a value indicating whether the stylus cursor is located over tllis
element (including visual child elements). This is a depende11cy
property.
IsVisible Gets a value indicating whether this element is visible in the user
interface (Ul). This is a dependency property.
La.oguage Gets or sets localization/globalization language information that
applies to an element.
LayoutTra.osfo rm Gets or sets a graphics transformation that sl1ould apply to this element
when layout is performed.
LogicalChildren Gets an entlIDerator that cm1 iterate the logical child elements of tllis
Panel element. (Overrides Frame,;vorkEleme11t.Lo gicalChildren.)
LogicalOrientation The Orientation of the panel if tl1e pm1el supports layout in only a
si11gle dimension.
LogicaJOrientationPublic The Orie11tatio11 of the panel, if the panel supports layout in only a
single dimension.
Margi.o Gets or sets the outer niargiI1 of an element.
442 I PowerShell Studio - A Comprehensive Guide
Max Height
Gets or sets tbe maximum height constraint of the element.
MaxWidth Gets or sets the maximum width constraint of tl1e element.
MinHeight Gets or sets the mini mum height co11straint of the element.
MinWidth Gets OT sets the 1ninimum ,;vidth constraint of the element.
Name Gets or sets the identifying naine of tl1e element. The ruune provides a
reference so tl1at code-behin~ such as event handler code, ca11 refer to
a n1arkup ele1nent after it is constructed during processing by a XAML
processor.
Opacity Gets or sets the opacity factor applied to the entire UIEle111ent when it
is rendered in the user interface (UI). Tllis is a dependency property.
OpacityMask Gets or sets an opacity uiask, as a B1ush implementation that is applied
to any alpha-cllal1Ilel maskil1g for the rendered content of this element.
This is a dependency property.
OverridesDefaultStyle Gets or sets a value that indicates vvhether tllis elen1ent incorporates
style properties fro111 theme styles.
Parent Gets the logical parent ele1nent of this ele1nent.
Persistld Obsolete.Gets a value that uniquely identifies this element.
RendcrSize Gets (or sets, but see Remarks) the final render size of tllis element.
Ren.derTransform Gets or sets trai1sform information that affects tl1e rendering position of
this element. Tllis is a dependency property.
RenderTransformOrigin Gets or sets the center point of any possible render trai1sfor1n declared
by RenderTransforni, relative to the bounds of the element. This is a
dependency property.
Resources Gets or sets the locally-defined resource dictionary.
SnapsToDevicePi'tels Gets or sets a valtte that detennines whetl1er rendering for tllis element
should use device-specific pixel settings dming rendering. This is a
dependency property.
Style Gets OT sets the style used by tllis ele1nent when it is rendered.
StylusPlu gins Gets a collection of all stylus plug-in (customizatio11) objects
associated with this element.
Tag Gets or sets au arbitrary object value that cai1 be used to store custo1n
infomiation about this element.
Tero platedParent Gets a reference to the template parent of this ele1neut. Tllis property is
not releva11t if the elen1ent ,;vas not created through a te1nplate.
ToolTiJ.> Gets or sets the tool-tip object that is displayed for tllis element in the
user interface (UI).
TouchesCaptured Gets all toucl1 devices tliat are captured to this ele1nent.
TouchesCa1>turedWitbin Gets all touch devices that are captured to this element or any child
elements in its visual tree.
Tou chesD irectlyOver
Gets all touch devices tliat are over this element.
ToucbesOver Gets all to11ch devices that are over this element or any child elements
in its visual tree.
Triggers Gets the collection of triggers established directly on this element, or
in child elen1ents.
PowerShell Studio - Reference Guide I 443
Uid Gets or sets the unique identifier (for localization) for this element.
This is a dependency property.
UseLayoutRou.ncling Gets or sets a value that indicates 'vhether layout rounding should be
applied to this element's size and position during layout.
VerticalAlignment Gets or sets the vertical alignment characteristics applied to this
element when it is composed within a parent element such as a panel
or items control.
Visibility Gets or sets the user interface (Ul) visibility of this element. This is a
dependency property.
Visu alBitmapEffect Obsolete.Gets or sets the BitmapEffect value for the Visual.
Visu alBitm apEffectln put Obsolete.Gets or sets the BitmapEffectlnput value for the Visual.
VisuaIBitmapScalingMode Gets or sets tl1e BittnapScalingMode for the Visual.
VisualCacheMode Gets or sets a cached representation of the Visual.
VisualChildrenCount Gets the number of child Visual objects in this instance of
Panel. (Overrides Framework.Element. VisualChildrenCount.)
Visu alClearTypeHint Gets or sets the ClearTypeHint that determines bo'v ClearType is
rendered in the Visual.
VisuaJCliJ> Gets or sets the clip region of the Visual as a Geometry value.
VisualEdgeMode Gets or sets the edge inode of the Visual as a11 EdgeMode value.
VisualEffect Gets or sets the bitmap effect to apply to the Visual.
VisualOffset Gets or sets the offset value of the visual object.
VisualOpacity Gets or sets the opacity of the Visual.
VisualOpacityMask Gets or sets the Bn1sh value that represents the opacity mask of the
Visual.
VisualParent Gets the visual tree parent of the visual object.
VisuaJScrollableAreaClip Gets or sets a clipped scrollable area for the Visual.
Viso alTextHintingMode Gets or sets the TextHintingMode of the Visual
VisualTextRenderingMode Gets or sets the TextRenderingMode of the Visual.
Visu alTransfo rm Gets or sets the Transfor1n value for tl1e Visual.
VisualXSnappingGuidelines Gets or sets the x-coordinate (vertical) guideline collection.
VisuaJYSnappingGuidelines Gets or sets the y-coordiJIBte (horizontal) guideline collectio11.
Width Gets or sets the width of the elen1ent.
PICTUREBOX
PROPERTY DESCRIPTION
AccessibilityO b ject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescri 11tion Gets or sets tl1e default action descriptio11 of the
control for use by accessibility client applications.
444 I PowerShell Studio - A Comprehensive Guide
Events Gets the list of event handlers that are attached to this
Component.
Focused Gets a value il1dicating 'vhetl1er the control has input
focus.
Font This API supports the product infrastn1ct11re and is not
intended to be used directly from your code. Gets or
sets the font of the te>..'t displayed by the
control.(Overrides Control.Font.)
FontHeight Gets or sets the height of the font of the control
ForeColor This API supports the product infrastn1chrre and is not
intended to be used directly from your code.
Overrides tl1e Control.ForeColor property.(Ove1rides
Control.ForeColor.)
Handle Gets the window handle that the co11trol is bound to.
Has Children Gets a value indicating 'vhether the control contains
one or 1nore child controls.
Height Gets or sets the height of the control.
Image Gets or sets the image that is displayed by PictureBox.
lmageLocation Gets or sets tl1e path or URL for the image to display
in the PictureBox.
lmeMode Gets or sets the Input Metl1od Editor(IME) 1node
supported by this control.
ImeModeBase Gets or sets the Ilv1E nlode of a control.
lnitiallm.age Gets or sets tl1e image displayed in the PictureBox
control when the main image is loading.
Invo.k eRequired Gets a value indicating whether the caller inust call an
invoke n1ethod when making 1netl1od calls to the
control because the caller is on a different thread tba11
the one tl1e control ,;vas created on.
IsAccessible Gets or sets a value il1dicating whether the control is
visible to accessibility applications.
IsDisposed Gets a value indicating vvhether the control has been
disposed of.
lsHandleCreated Gets a value indicating whether the control has a
handle associated vvitl1 it.
IsMirrored Gets a value indicating whether the control is
nrirrored.
LayoutEngine Gets a cached instance of the control's layollt engine.
Left Gets or sets the distance, in pixels, between tl1e left
edge of the control and the left edge of its container's
client area.
Location Gets or sets the coordinates of the tipper-left comer of
the control relative to the upper-left comer of its
contai11er.
Margin Gets or sets the space ben.veen controls.
Ma'timumSize Gets or sets the size that is the upper limit that
GetPreferredSize can specify.
PowerShell Studio - Reference Guide I 447
MinimumSize Gets or sets the size that is the lo,ver limit that
GetPreferredSize can specify.
Name Gets or sets the name of the control.
Padding Gets or sets padding within the control.
Parent Gets or sets the parent contaiJ.1er of the control.
PreferredSize Gets the size of a rectangular area into vvhich the
control can fit.
ProductName Gets the product name of the assembly containing the
control.
ProductVersion Gets the version of the assembly containing the
control.
RecreatingHandle Gets a value indicating \;vhether the co11trol is
currently re-creating its handle.
Region Gets or sets tl1e window region associated wit11 the
control.
RenclerRigbtToLeft Obsolete.This property is now obsolete.
ResizeRed ra'v Gets or sets a value indicating "vhether the control
redraws itself \he11 resized.
Right Gets the distance, in pixels, beti;veen the right edge of
the control and the left edge of its container's client
area.
RightToLeft This API supports the product infrastruct1ue and is not
intended to be used directly fron1 your code. Gets or
sets a value indicating whether control's elements are
aligned to support locales usiJ.1g right-to-left
languages.(Ovenides Control.RightToLeft.)
ScaleChildren Gets a value that detenuines tl1e scaling of child
controls.
ShowFocusCues Gets a value indicating \;vhether the control shottld
display focus rectangles.
SholvKeyboardCues Gets a value indicating \ hethe.r the user iJ.1terface is in
the appropriate state to show or hide keyboard
accelerators.
Site Gets or sets the site of the control.
Size Gets or sets tl1e height a11d width of the control.
SizeMocle Indicates how the iniage is displayed.
TabIndex This API supports the product infrastructure and is not
it1tended to be used directly from your code. Gets or
sets the tab index value.
TabStop This API supports the product infrastructtue and is not
i11tended to be used directly from your code. Gets or
sets a value that indicates "vhether the user can give
the focus to this control by using the TAB key.
Tag Gets or sets the object that contaillS data about the
control.
Text This API supports the product infrastructt1re and is not
intended to be used direc~y from your code. Gets or
448 I PowerShell Studio - A Comprehensive Guide
AccessibilityObject
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescriptiou Gets or sets the default action description of the control for use by
accessibility client applications.
AccessibleDescri11tion Gets or sets the description of the control used by accessibility
client applications.
AccessibleName Gets or sets the nan1e of the control used by accessibility client
~plications.
AccessibleRole Gets or sets the accessible role of the control
AllowDrop This API supports the product infrastructure and is not intended to
be tlSed directly from your code. Gets or sets a value indicating
whether the conuol can accept data that the user drags onto
it.(Overrides Control.AllowDrop.)
Anchor Gets or sets the edges of the container to wllicl1 a control is bound
and detennines how a control is resized \Vith its parent.
AutoScrollOfl'set Gets or sets \.V here tills co11trol is scrolled to in
ScrollControllntoView.
Auto Size This API supports the product illfrastructure and is not intended to
be used directly fro1n your code. Tllis property is not relevai1t for
this class.
Bacl<.Color Gets or sets the background color for the control.
Backgroundlmage This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets the background
ilnage for the ProgressBar control.(Overrides
Co11trol.Backgrou11dlmage.)
PowerShell Studio - Reference Guide I 449
BackgroundlmageLayou t This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets the layout of the
background image of the progress bar.(Overri,des
Control.Backgroundl.lnageLayout.)
Bin din.g Contcxt Gets or sets the BindingContext for the control.
Bottom Gets the distance, in pixels. benveen U1e bottom edge of the
control and the top edge of its container's client area.
Bounds Gets or sets the size and location of the control including its
nonclient ele1nents, in pi.xels, relative to tl1e p arent control.
CanEnabJelme Gets a value indicating \vhether the ImeMode property can be set
to an active value. to enable 1ME support.
CanFocus Gets a value indicating whether the control can receive focus.
CanRaiscEvents Detem1ines if events can be raised on the control.
CanSelect Gets a value indicati11g whether the control can be selected.
Capture Gets or sets a value indicating ,,hether the control has captured
the tnouse.
CausesVaJidation This API supports the product infrastructure and is not intended to
be used directly from yotir code. Gets or sets a value indicating
\vhether U1e control. \iv hen it receives focus, causes validation to be
perfonned on ai1y co11trols that require validation.
ClientRectan gle Gets tlle rectangle that represents the client area of t11e control.
ClientSize Gets or sets the height and \.vidtl1 of the client area of U1e control.
CompanyN ame Gets the na1ne of the company or creator of the application
contai11ing U1e control.
Container Gets the IContainer that contains the Coniponent.
ContainsFocus Gets a value indicating whether the control or one of its child
controls. currently has the i11put focus.
ContextMenu Gets or sets the shortet1t menu associated v.Ti.th the control.
ContextMenuStrip Gets or sets the ContextMenuStrip associated \Vith lltls control.
Controls Gets the collection of controls contained \vithin the control.
Created Gets a value iL1dicating whether the control has been created.
CreateParams This APT supports the product infrastructure and is not intended to
be used directly from your code. Overrides
Control.CreateParan1s.(Overrides Co11trol.CreateParat11S.)
Cursor Gets or sets the cursor that is disp layed when t he 111ouse pointer is
over the control.
DataBindings Gets the data bindings for the control.
Defau ltCu r so r Gets or sets the default cursor for the control.
DefaultlmeMode Gets the default Input Method Editor (IME) mode supported by
the control.(Overrides Control.DefaultlmeMode.)
DefaultMargin Gets the space. in pi"\'.els, that is specified by default bet\veen
controls.
Defau ltMaximumSize Gets the length and height in pixels, that is specified as U1e default
maximum size of a control.
Defau It Mini 1nu m Size Gets the length and height, in pixels, U1at is specified as the default
1ninimum size of a control.
Defau ltPadding Gets the internal spacing, in pixels, of the contents of a control.
DefaultSize Gets tlle default size of the control.(Overrides
Co ntro l.DefaultSize.)
450 I PowerShe ll St ud io - A Com prehensive Guide
Design Mode Gets a value that indicates ,,hether the Co1nponent is currently in
design mode.
DisplayRectangle Gets the rectangle that represents the display area of the contTol.
Disposing Gets a value indicating \vhether the base Control class is in the
process of disposing.
Dock Gets or sets ' vhich control borders are docked to its parent control
and determines hovv a control is resized 'ith its parent.
DoubleBuffered Gets or sets a value indicating 'vhether the control should redra\v
its surface using a secondary buffer.(Overrides
Control.DoubleBuffered.)
Enabled Gets or sets a value indicating ';vhether the control can respond to
user interaction.
Events Gets tl1e list of event handlers that are attached to this Component.
Focused Gets a value indicating 'vbether the control bas input focus.
Font This API supports the product infrastructure and is not intended to
be used directly from your code. Gets or sets the font of text in the
ProgressBar.(Overrides Control.Font.)
FontBeigbt Gets or sets the height of the font of the control .
ForeColor Gets or sets the foreground color of the control.
Handle Gets the wil1do'v handle that t11e control is b0Lu1d lo.
HasChildreo Gets a value indicating \Vbetl1er the co11trol contains one or more
cllild controls.
Height Gets or sets the height of the control.
ImcMode This API supports the product infrastructure and is not intended to
be used directly fro1n your code. Gets or sets the i11put method
editor (IME) for the ProgressBar
ImeModeBase Gets or sets the IME mode of a control.
InvokeRequircd Gets a value indicating whether the caller must call an invoke
method \Yhen 1naking method calls to the control because the
caller is on a different thread than the one the control 'vas created
011.
IsAccessible Gets or sets a value indicating whether the control is visible to
accessibility applications.
IsDisposcd Gets a value indicating whether the control has been disposed of.
IsHandleCreated Gets a value indicating \vhether the control has a handle associated
\Vith it.
lsMirrored Gets a value indicating 'vhether tl1e control is nlirrored.
LayoutEngine Gets a cached instance of tl1e control's layout engine.
Left Gets or sets the distance, in pixels, between the left edge of the
control and the left edge of its container's client area.
Location Gets or sets the coordinates of the upper-left corner of the control
relative to the upper-left comer of its container.
Margin Gets or sets the space bet\>veen controls.
MarqueeAnimationSpeed Gets or sets the tin1e period, in milliseconds. that it takes tl1e
progress block to scroll across the progress bar.
Maximum Gets or sets the maximtlill value of the range of the control.
MaximumSi7..e Gets or sets the size tl1at is the upper linlit that GeltPreferredSize
can specify .
Minimum Gets or sets tl1e 1nillimum value of U1e range of the control.
PowerShell Studio- Reference Guide I 451
MinimumSize Gets or sets the size tl1at is the lower linlit that GetPreferredSize
can specify .
Name Gets or sets the name of the control.
Padding This API supports the product infrastructure and is not iluended to
be used directly fron1 your code. Gets or sets the space bet,veen
the edges of a ProgressBar control and its contents.
Parent Gets or sets the parent container of the control.
PreferredSize Gets the size of a rectangular area into which tbe control can fit.
ProductN aine Gets the product name of the assen1bly containing the control.
ProductVersion Gets the version of U1e assembly containing U1e control.
RecreatingHandJe Gets a value indicating \Vhether the control is currently re-creating
its handle.
Region Gets or sets U1e \vindolv region associated with the control.
RenderRightToLeft Obsolete.This property is now obsolete.
ResizeRed ra'v Gets or sets a value indicating whell1er the control redra'\\s itself
\vhen resized.
Right Gets the distance. in pi-xels, bet\veen the right edge of the control
and the left edge of its container's client area.
RigbtToLeft Gets or sets a value indicating \heU1er control's elen1ents are
aligned to Sltpport locales using right-to-left fonts.
RightToLeftLayout Gets or sets a value indicating \Yhether the ProgressBar and auy
text it contains is displayed from right to left.
ScaJeChildren Gets a value that detemunes t11e scaling of cl1ild controls.
Sho''' FocusCues Gets a value indicating \vhether the control should display focus
rectangles.
SholvKeyboard
Cues Gets a value indicating \Vhether the user interface is in the
appropriate state to show or hide keyboard accelerators.
Site Gets or sets the site of the control.
Size Gets or sets the height and \Vidth of the control.
Stc1> Gets or sets the an1ount by \vhich a call to the PerformStep method
increases the current position of the progress lbar.
Stvle
~
Gets or sets the 1Tu1nner in which progress shottld be indicated on
the progress bar.
Tablndex Gets or sets the tab order of the control \vitllin its container.
TabStop This API supports the product infrastructure and is not intended to
be used directly fro1u yotu code. Overrides TabStop.
Tag Gets or sets the object that contains data about the control.
Text Tllis API supports ll1e product infrastructure and is not intended to
be used directly from your code. Gets or sets the text associated
~vith this control.(Overrides Control. TeA1.)
Gets or sets the distance, in pi-xels, between the top edge of the
control and the top edge of its contaiuer's client area.
TopLevelControl Gets the parent control that is not parented by anotl1er Windo,vs
Fonns control. Typically. this is the outermost Form that the
control is contaii1ed in.
UseW aitCursor Gets or sets a value indicating whether to use th.e wait cursor for
the current control a11d all child controls.
Value Gets or sets the current position of the progress bar.
452 I PowerShell Studio - A Comprehensive Guide
Visible Gets or sets a value indicating whether the control and all its child
controls are displayed.
Width Gets or sets the width of the control.
WinctowTarget This API supports the product infrastn1cture and is not intended to
be used directly from your code. This property is not relevant for
this class.
PROPERTY GRID
Backgroundlmage Thjs API supports the product infrastructure and is not inte11ded
to be used directly fro111 your code. This property is not relevant
for this class. (Overrides Control.Backgroundlrnage.)
BackgroundlmageLayou t Tlus AP! supports the product infrastructure and is not i.J1tended
to be used directly from your code. This property is not relevant
for this class.(Overrides Control.BackgroundimageLayout.)
BindingContext Gets or sets tl1e BindingConte:\.1 for the control.
Bottom Gets the distance, in pixels, bet\veen the bottom edge of the
control and the top edge of its container's client area.
Bounds Gets or sets the size and location of the control including its
nonclient elements, in pixels, relative to the parent control.
Browsab lcAttributes Gets or sets the bro,vsable attributes associated with the object
that the property grid is attached to.
CanEnablelme Gets a value indicating \vhether the ln1eModie property can be set
lo an active value. to enable IME support.
CanFocus Gets a value indicating ~vbether the control can receive focus .
CanRaiscEvents Determines if events can be raised on the control.
CanSelect Gets a value indicating whether the control can be selected.
CanSholvCommands Gets a value indicating \\rhether tl1e conunands pane can be made
visible for the currently selected objects.
CanShowVisu alStyleGlyJlhs Gets or sets a "Value that indicates whether OS-specific visual
style glyphs are used for the e:\.-pansion nodes in the grid area.
Capture Gets or sets a value indicating \Vhether the control has captured
the rnouse.
CategoryForeColor Gets or sets the te>..'t color used for category headings.
CategoryS1>litterColor Gets or sets the color of the line that separates categories in the
grid area.
CausesVaJidation Gets or sets a value indicating \Vbether the control causes
validation to be perfonned on any controls U1al require validation
when it receives focus.
ClientRectangle Gets the rectangle that represents the client area of the control.
ClientSize Gets or sets the height and ' vidth of the client area of the control.
CommandsActiveLinkColor Gets or sets the color of active Links in the executable conu11a.uds
region.
CommandsBackColor Gets or sets the background color of the hot collllnands region.
CommandsBorderColor Gets or sets the color of the border swTotmding the bol
co1runands region.
CommandsDisabledLinkColor Gets or sets the unavailable link color for tbe executable
con11nands region.
CommandsForeColor Gets or sets the foregrotu1d color for the hot comnuu1ds region.
CommandsLinkColor Gets or sets the link color for the executable comn1ands region.
CommandsVisible Gets a value indicating ' vhether the co1nn1ands pane is visible.
Comm andsVisiblelfAvailable Gets or sets a value indicating '\1 hether the con1rna11ds pane is
visible for objects U1at ex-pose verbs.
454 I PowerShell Studio - A Comprehensive Guide
CompanyN ame Gets the name of the cotnpany or creator of the application
containing the control.
Container Gets the !Container that contains the Co111pone11t.
ContainsFocus Gets a value il1dicatingwhether the control, or one of its child
controls, cmrently bas the input focus.
ContextMenu Gets or sets the shortcut menu associated with the control.
ContextMenuDefaultLocation Gets tl1e default location for the shortcut menu.
ContextMenuStrip Gets or sets the Conte~"Ment1S trip associated with this control.
Controls This API supports the product infrastructure and is not intended
to be used directly from your code. This property is not relevant
for tllis class.
Created Gets a value indicatil1g vvhether the control has been created.
CreateParams Gets the required creation para1neters wl1en the control handle is
created.
CurrentAutoScaleDimensions Gets the current run-time di1nensions of the screen.
Cursor Gets or sets the cursor that is displayed \;vhen the mouse pointer
is over the control.
DataBindings Gets the data bindings for the control.
DefaultCursor Gets or sets the default cursor for the control.
DefaultlmcMode Gets the default Input Method Editor (Thill) mode supported by
the control.
DefaultMargin Gets the space, in pixels, that is specified by default between
controls.
DefaultMaximumSize Gets the length and height. in pixels, that is specified as the
defa1llt maxi1nrun size of a control.
DefaultMinimumSize Gets the length and height, in pixels. that is specified as the
defa1llt minin1mn size of a control.
DefaultPadding Gets the internal spacing, in pixels, of tl1e contents of a control.
DefaultSize Gets the default size of the control.(Overrides
Control.DefaultSize.)
DefaultTa.bType Gets the type of the defa1tlt tab.
DesignMode Gets a value tl1at indicates whether tl1e Co1nponent is currently in
design mode.
DisabledltemForeColo r Gets or sets the foregroru1d color of disabled text in the grid area.
DisplayRectangle Gets the rectangle that represents the virtual display area of the
control.
Disposing Gets a value indicating wl1ether the base Control class is in the
process of disposing.
Dock Gets or sets vvbich control borders are docked to its parent
control and detennil1es how a control is resized with its parent.
DockPadding Gets the dock padding settings for all edges of the control.
DoubleBuffered Gets or sets a value indicating vvhether this control should redraw
its surface using a secondary buffer to reduce or prevent flicker.
Dra,vFJatToolbar Gets or sets a value indicating \hether the PropertyGrid control
paints its toolbarwith flat buttons.
PowerShell Studio - Reference Guide I 455
Enabled Gets or sets a value indicating whether the control can respond to
user interaction.
Events Gets the list of event handlers that are attached to this
Component.
Focused Gets a value indicating whether the control has input focus.
Font Gets or sets the font of the text displayed by the control.
FontHeight Gets or sets the height of the font of the control.
ForeColor This API supports the product infrastn1cture and is not intended
to be used directly from your code. This property is not relevant
for this class.(Overrides Control.ForeColor.)
Handle Gets the window handle that the control is bom1d to.
Has Children Gets a value indicating vvhetber the control contains one or inore
child controls.
Height Gets or sets the height of the control.
Hel1>BackColor Gets or sets the backgrotmd color for the Help region.
HelpBorderColor Gets or sets the color of the border surrounding the description
pane.
Hel1>ForeColor Gets or sets the foreground color for the Help region.
HelpVisible Gets or sets a value indicating \;vhether the Help text is visible.
HorizontalScroll Gets tl1e characteristics associated with tl1e horizontal scroll bar.
HScroll Gets or sets a value indicating \;vhether the horizontal scroll bar is
visible.
lmeMode Gets or sets the Input Method Editor (I.ME) inode of the control.
lmeModeBase Gets or sets the Th1E mode of a control.
lnvokeRequired Gets a value indicating whether the caller n1ust call an ii1voke
met11od vvhen maki.I1g 1nethod calls to tlle control because the
caller is on a different thread than the one the control was created
on.
lsAccessible Gets or sets a value indicating whether tl1e control is visible to
accessibility applications.
IsDisposed Gets a value indicating \Vhether the control has been disposed of.
IsHandleCreatecl Gets a value indicating whether the control has a handle
associated "vith it.
IsMirro reel Gets a value iI1dicating whether the control is ininored.
LargeButtons Gets or sets a value indicating whether b11ttons appear in standard
size or in large size.
LayoutEngi.ne Gets a cached instance of the control's layout e11gine.
Left Gets or sets the distance, in pL'<els between the left edge of the
control and the left edge of its container's client area.
LineColor Gets or sets the color of the gridlines and borders.
Location Gets or sets the coordinates of the upper-left comer of the control
relative to the upper-left corner of its container.
Margin Gets or sets the space between controls.
456 I PowerShell Studio - A Comprehensive Guide
-:.::i::,"IO;
MaximumSize Gets or sets the size that is the upper limit that GetPreferredSize
can specify.
MinimumSize Gets or sets the size that is the lower linut that GetPreferredSize
can specify.
Name Gets or sets the na1ne of the control.
Padding This API supports the product infrastructure and is not intended
to be used directly from your code. This property is not relevant
for this class.
Parent Gets or sets the parent container of the control.
ParentForm Gets the fonn that the container control is assigned to.
PreferredSize Gets the size of a rectangular area into \Nhich the control can fit.
ProductN ame Gets the product name of the assembly containing tl1e control.
ProductVersion Gets the version of the assembly contaitung the control.
Pro11ertySort Gets or sets the type of sorting the Property Grid uses to display
properties.
Prope.r tyTabs Gets the collection of property tabs that are displayed in the grid.
Recreatin gHandle Gets a val11e iJ.1dicating \;vhether the co11trol is currently re-
creating its handle.
Region Gets or sets the windo"v region associated with the control.
RenderRigbtToLeft Obsolete.This property is now obsolete.
ResizeRecl raw Gets or sets a value indicating whether the control redraws itself
vv hen resized.
Right Gets the distance, i11 pixels, between the right edge of the control
and the left edge of its co11taiJ.1er's client area.
RightToLeft Gets or sets a value indicating whether control's elen1ents are
aligned to support locales using right-to-left fonts.
ScaleChildren Gets a value that determines the scaling of child controls.
SelectedGridltem Gets or sets the selected grid item.
SelectedltemWithFocusBackColor Gets or sets the backgrotmd color of selected ite1ns that have tl1e
input focus.
SelectedltemWithFocusForeColor Gets or sets the foreground color of selected items that have tl1e
input f OCUS .
Selected Object Gets or sets the object for which the grid displays properties.
Selected Objects Gets or sets the currently selected objects.
SelectedTab Gets the currently selected propert)' tab.
Show FocusCues Gets a value indicating whether the control sho1tld display focus
rectangles. (Overrides Contra l. ShowFocusCues.)
Show Keyboard Cues Gets a value indicating whether the user interface is in the
appropriate state to sho\ or hide keyboard accelerators.
ShowPro11e11yPagelmage Gets the image tltat represents the property page.
Site Gets or sets the site of the control.(Overrides Control.Site.)
Size Gets or sets the height and vvidth of the control.
SortByCategorylmage Gets the image that represents sorting grid items by category.
PowerShell Studio - Reference Guide I 457
SortByPrope1iylmage Gets the itnage tl1at represents sorting grid items by property
name.
Tablndex Gets or sets the tab order of the control '\>vithin its container.
TahSto11 Gets or sets a value indicating whether the user can give the
focus to this control using the TAB key.
Tag Gets or sets the object tllat contains data about the control.
Text Gets or sets the te:\.1 associated with this control.(Overrides
Control.Text.)
ToolbarVisibl.e Gets or sets a va111e indicating wl1etber the toolbar is visible.
ToolStripRenderer Gets or sets the painting functionality for ToolStrip objects.
Top Gets or sets the distance, in pixels, between the top edge of the
control and the top edge of its container's client area.
To11LevelControl Gets the parent control that is not parented by another Windows
Fonns control. Typically, this is the outermost Form that the
control is contained in.
UseCompatibleTextRendering Gets or sets a value that determines whether to use the Graphics
class (GDI+) or the TeA.1Renderer class (GDI) to rendeT text.
UseWaitCursor Gets or sets a value indicating whether to use the wait cursor for
the current control and all child controls.
VerticalScroll Gets the characteristics associated with the vertical scroll bar.
Vie,vBackColor Gets or sets a value indicating the background color in the grid.
ViewBorderColor Gets or sets the color of the border surrounding the grid area.
Vie\vForeColor Gets or sets a value indicating the color of the text in the grid.
Visible Gets or sets a value indicating whether the control and all its
child controls are displayed.
VScroll Gets or sets a value indicating -vvhether tl1e vertical scroll bar is
visible.
Width Gets or sets the widtl1 of the control.
Window Target This API supports the product infrastructure and is not it1tended
to be used directly fro111 your code. This property is not relevant
for this class.
RADIO BUTTON
PROPERTY DESCRIPTION
AccessibilityO bject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescri11tion Gets or sets the default actio11 description of tl1e
control for use by accessibility client applications.
AccessibleDescription Gets or sets the description of the control used by
accessibility client applications.
.A.ccessible:N"aine Gets or sets the name of the control used by
accessibility client applications.
Accessiblellole Gets or sets the accessible role of t11e control
458 I PowerShell Studio - A Comprehensive Guide
Allow Drop Gets or sets a value indicating vvhether the control can
acce_p t data that the user drags onto it
Anchor Gets or sets the edges of tl1e co11tainer to which a
control is botmd and detennines ho'i\7 a control is
resized ,;vith its parent.
A]Jpearance Gets or sets a value determining tl1e appearance of the
RadioButton.
Auto Check Gets or sets a value indicating whether the Checked
value and the appearance of tl1e co11trol automatically
change when the co11trol is clicked.
AutoEllipsis Gets or sets a value indicating whether the ellipsis
character (...) appears at the right edge of tl1e co11trol,
denoting that the control text eA'tends beyond the
specified length of the control.
AutoScrollOfl'set Gets or sets '\>vhere tlris control is scrolled to in
ScrollControllntoView.
Auto Size Gets or sets a value tl1at indicates '\>Vheti1er the control
resizes based on its co11tents.
Bacl<Color Gets or sets the backgrotmd color of the control.
Backgroundlmage Gets or sets the backgrotmd i111age displayed in the
control.
BackgroundlmageLayout Gets or sets the background in1age layout as defined
in the In1ageLayout enumeration.
BindingContext Gets or sets the BindingContext for the control.
Bottom Gets the distance, in pixels, benveen the botton1 edge
of the control and the top edge of its contaiI1er's client
area.
Bounds Gets or sets the size and location of the control
including its nonclient ele1nents, in pi,xels, relative to
the parent control.
CanEnablelme Gets a value indicating whether the I1neMode
property can be set to an active value, to enable IME
support.
CanFocus Gets a value indicating 'vhether the contTol can
receive focus.
CanRaiseEvents Determines if events can be raised on the co11trol
CanSelect Gets a value indicating ,;ybether the control can be
selected.
Ca1.>ture Gets or sets a value indicating whether the control has
captured tl1e moltse.
CausesValidation Gets or sets a value indicating ' vbether the control
ca11ses validation to be performed on any controls that
require validation when it receives focus.
CheckAlign Gets or sets the location of the check box portion of
the RadioButton.
Checl<ed Gets or sets a value indicating whether the control is
checked.
ClientRectan gle Gets the rectangle that representsthe client area of the
control.
PowerShell Studio - Reference Guide I 459
ClientSize Gets or sets the height and \vidth of the client area of
the control.
Com1lanyName Gets the na1ne of the company or creator of tbe
application containing the control.
Container Gets the I Container that contains the Co1nponent.
ContainsFocus Gets a value indicating 'Vhether the control, or one of
its child controls, currently has the input focus.
ContextMenu Gets or sets the shortcut 111enu associated \ith the
control.
ContextMenuStrip Gets or sets the ConteA1MenuStrip associated 'ith
this control.
Controls Gets the collection of controls contained within tl1e
control.
Created Gets a value indicating 'vhether the control has been
created.
CreateP arams This API supports the product infrastructtue and is not
intended to be used directly fro1n your code. Gets tl1e
required creation parameters when the control handle
is created.(Overrides ButtonBase.CreateParams.)
Cursor Gets or sets the cursor that is displayed '1vhen the
mouse pointer is over the contr:ol.
DataBindings Gets the data bindings for tl1e control.
DefaultCursor Gets or sets the default cursor for tl1e control.
Defau ltlmeMode Gets the default Input Method Editor (IlvIE) mode
supported by this control.
DefaultMargin Gets the space, in pixels, that is specified by default
between controls.
DefaultMaximumSize Gets tl1e lengtl1 and height, in pixels, that is specified
as the default maximmn size of a control.
DefaultMinimumSize Gets the lengtl1 and height, in pL-xels, that is specified
as the default minimum size of a control.
DefaultPadding Gets the internal spacing. in pixels. of the contents of
a control.
DefaultSize Gets the defa1tlt size of the control. (Overrides
ButtonBase.DefattltSize.)
DesignMode Gets a value tliat indicates 1'Vhether the Component is
currently in design i11ode.
Dis1>layRectangle Gets the rectangle that represents tbe display area of
the control.
Disposing Gets a value indicati11g \vhether the base Control class
is in the process of disposing.
Dock Gets or sets which control borders are docked to its
parent control and detennines how a control is resized
with its parent.
Dou bleBu ffered Gets or sets a value indicating whether this control
sho1tld redraw its Slrrface using a secondary buffer to
reduce or prevent flicker.
Enabled Gets or sets a value indicating whether the control can
respond to user interaction.
460 I PowerShell Studio - A Comprehensive Guide
Events Gets t11e list of event handlers that are attached to this
Component.
FJatAp1>earan.ce Gets the appearai1ce of the border and the colors used
to indicate check state and mouse state.
FJatStyle Gets or sets the flat style appearance of the butto11
control.
Focused Gets a value b.1dicating "vl1ether the control has input
focus.
Font Gets or sets the font of the te>..'t displayed by the
control.
FontHeight Gets or sets the height of the font of the control.
ForeColor Gets or sets the foreground color of the control.
Handle Gets the window handle that the control is bound to.
Has Children Gets a value indicating "vhether the co11trol contains
011e or more child controls.
Height Gets or sets the height of the control.
Image Gets or sets the image that is displayed on a button
control.
lmageAJign Gets or sets the alignment of the image on the button
control.
lmagelndex Gets or sets the i1nage list index value of the image
displayed on the button control.
lmageKey Gets or sets the key accessor for the image in the
ImageList.
ImageList Gets or sets the lmageList tliat contains the Image
displayed on a button control.
lmeMode This API supports the product infrastructure and is not
intended to be used directly from your code. Gets or
sets the Input Method Editor (IME) n1ode supported
by this control. This property is i1ot relevant for this
class.
ImeModeBase Gets or sets the IME mode of a control.
InvokeRequired Gets a value indicating whetl1er the caller must call a11
invoke method when making method calls to the
control because the caller is on a different thread than
the one the control was created on.
lsAccessible Gets or sets a value i11dicating whether the control is
visible to accessibility applications.
IsDefault Gets or sets a value indicating "\>vhether the button
control is the default button.
IsDisposed Gets a value indicating \vhether the control has been
disposed of.
lsHandJeCreated Gets a value indicating 'vhether the control has a
l1311dle associated \ith it.
IsMirrored Gets a value indicating \Vhetber the control is
mirrored.
LayoutEngine Gets a cacl1ed instance of the control's layout engine.
PowerShell Studio - Reference Guide I 461
Tag Gets or sets the object that contains data about the
control.
Text Gets or sets the teA't associated vvith this control.
TextAlign This API supports the product infrastn1cture and is not
intended to be used directly fron1 your code. Gets or
sets the aligrunent of the text 011 the Radi0Butto11
control. (Overrides ButtonBase. Tea1Align.)
TextlmageRelation Gets or sets the position of text and image relative to
each other.
Top Gets or sets the distance, in pixels, betvveen the top
edge of the control and the top edge of its containe1Js
client area.
TopLevelControJ Gets the parent control that is not parented by another
Windows Forms control. Typically, tl1is is the
outermost Form that the control is contained in.
UseCompatibleTextRendering Gets or sets a value tl1at detennin.es whet11er to use the
Graphics class (GDI+) or the TextRenderer class
(GDD to render teA't.
UseMnemonic Gets or sets a value indicating ,;vhetl1er the first
character that is preceded by ai1 ampersand (& ) is
used as the mnemo1ric key of the control.
UseVisualStyleBackColor Gets or sets a value that determines if the backgrotmd
is drawn using visual styles, iI supported.
UseWaitCursor Gets or sets a value indicating vvhether to use the 'vait
cursor for the current control and all child controls.
Visible Gets or sets a value indicating vvhetller tl1e control and
all its clrild controls are displayed.
Width Gets or sets the widtl1 of t11e co11trol.
Window Target This API supports the product infrastructure ai1d is not
intended to be used directly fron1 your code. TJris
property is not relevant for this class.
RICHTEXTBOX
PROPERTY DESCRIPTION
Acce1>tsRetu rn Gets or sets a value that indicates hovv the teA1 editing
control responds ,;v-hen the user presses the ENTER
key.
Accepts Tab Gets or sets a value t11at indicates how the text editing
control responds ,;vhen the user presses tl1e TAB key.
Actuameight Gets the rendered height of this element.
ActuaIWidtb Gets the rendered ,;vidth of tllis elen1ent.
Allo\vDro1> Gets or sets a value indicating vvhether tlris element
can be used as the target of a drag-and-drop operation.
Tlris is a dependency property.
AreAnyTouchesCaptured Gets a value that indicates whether at least one touch
is captured to this element.
PowerShell Studio - Reference Guide I 463
Cursor Gets or sets the cursor tliat displays when the 1nouse
pointer is over this element.
Data Context Gets or sets the data couteA1 for fill ele1nent when it
participates in data binding.
DefaultStyleKey Gets or sets the key to use to reference tl1e style for
this control, when theme styles are used or defined.
De11endencyObjectType Gets the DependencyObjectType that wraps the CLR
type of this instance. (Inl1erited from
DependencyObject.)
DesiredSize Gets the size that this elernent computed during the
measure pass of the layout process.
Dis11atcher Gets the Dispatcher this DispatcherObject is
associated \ith. (Inherited frorn DispatcherObject.)
Document Gets or sets the Flo\vDocument that represents the
contents of the RichTeA1Box.
Effect Gets or sets the bitmap effect to apply to the
UIElement. This is a dependency property.
ExtentHeight Gets the vertical size of the visible content area.
ExtentWidth Gets the horizontal size of the visible content area.
Flo,vDirection Gets or sets the direction tltat text and other user
interface (UI) elements flovv \ithin filly parent
ele1nent that controls their layout.
Focusable Gets or sets a value tiiat indicates whether the ele1nent
can receive focus. This is a dependency property.
FocusVisualStyle Gets or sets a property that enables customization of
appearance, effects or other sty le cbaracteristics tliat
\.Vill apply to this eleme11t when it captures keyboard
focus.
FontFamily Gets or sets the font family of the control.
FontSize Gets or sets the font size.
FontStretcb Gets or sets the degree to which a font is condensed or
expanded on tl1e screen.
FontStyle Gets or sets the font sty le.
FontWeight Gets or sets the weight or thickness of the specified
font.
ForceCursor Gets or sets a value that indicates whetl1er this
Frame,vorkElement should force tl1e user interface
(UI) to render the cttrsor as declared by the Ctrrsor
property.
Foreground Gets or sets a bntsh that describes the foreground
color.
HandlesScrolling Gets a value that indicates whether a control supports
scrolling.
HasAnimatedPro11erties Gets a value indicating whether this eleme11t has any
animated properties.
HasEffectiveKevboardFocus
~
Gets a value that indicates whether tl1e UIElement has
focus.
Height Gets or sets the suggested height of the ele1nent.
PowerShe ll Stu dio - Refere nce Guide I 465
SAVEDDIALOG
PROPERTY DESCRIPTION
AddExtension Gets or sets a value indicating \Vhether the dialog box
automatically adds an extension to a file name if the
user omits the extension.
Auto U1>gradeEnabled Gets or sets a value indicating ,;vhether this FileDialog
instance sl1ould automatically t1pgrade appearance and
behavior when nu1ning on Windo\VS Vista.
CbeekFileExists Gets or sets a value indicating whether the dialog box
displays a wan1ing if the user specifies a file name
that does not exist.
CheckP atbExists Gets or sets a value indicating whetl1er the dialog box
displays a "varni11g if the user specifies a path that
does not exist.
470 I PowerShell St udio - A Comprehensive Guide
SPLITCONTAINER
PROPERTY DESCRIPTION
AccessibilityObject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets the default action description of the
control for use by accessibility clie11t applications.
PowerShell Studio - Reference Guide I 471
SPLITTER
PROPERTY DESCRIPTION
AccessibilityObject Gets the AccessibleObject assigned to tl1e control.
AccessibleDefaultActionDescription Gets or sets the default action description of t11e
control for use by accessibility client applications.
AccessibleDescri1ltion Gets or sets file description of tlle control used by
accessibility client applications.
AccessibleName Gets or sets the na1ne of the control used by
accessibility client applications.
.t\ccessible~o1e Gets or sets the accessible role of the control
AllowDrop This API supports the product infrastructme and is not I
intended to be used directly fro1n your code. This
property is not relevant to this class .(Overrides
Control.AllowDrop.)
Anchor This API supports the product infrastn1ct1ue and is not
intended to be used directly from your code. This
property is not relevant to this class.(Overrides
Control. Anchor.)
AutoScrollOffset Gets or sets where this control is scrolled to in
ScrollControllntoView.
Auto Size This API supports the product infrastn1cture and is not
intended to be used directly frotn your code. This
property is not relevant for this class.
PowerShell Studio - Reference Guide I 477
Handle Gets the 'vindow handle that the control is bot1nd to.
Has Children Gets a value indicating whether the control contains
one or n1ore child controls.
Height Gets or sets the height of the control.
ImeMode This A.PI supports the prodt1ct infrastructure and is not
intended to be used directly fron1 your code. This
property is not relevant to this class.
ImeModeBase Gets or sets the IME mode of a control.
lnvolteRequ ired Gets a value indicating whether the caller must call an
invoke inethod when inaki11g 1nethod calls to the
control because the caller is on a different thread than
the one the control was created on.
IsAccessible Gets or sets a value indicating whether the control is
visible to accessibility applications.
lsDis11osed Gets a value indicati11g \vhether the co11trol has been
disposed of.
IsHandleCreated Gets a value indicating \Vhether tl1e control has a
hru1dle associated with it.
lsMirrored Gets a value indicating \vhether the co11trol is
mirrored.
Layou tEngine Gets a cached instance of the control's layout engine.
Left Gets or sets the distance. in pixels. benveen the left
edge of the control and the left edge of its container's
client area.
Location Gets or sets the coordinates of the upper-left comer of
the control relative to the upper-left comer of its
container.
Margin Gets or sets the space between controls.
MaximumSize Gets or sets the size that is the upper limit that
GetPreferredSize can specify.
MinExtra Gets or sets the minimum distance that must remail1
between the splitter control and the edge of the
opposite side of tl1e container (or the closest control
docked to that side). Splitter.MinExtra has been
replaced by similar properties in
Sy stein.Windovvs.Forms. SplitContainer and is
provided only for co1npatibility with previous
versions.
MinimumSize Gets or sets the size that is the lower Jimit that
GetPrefe1TedSize can specify.
MinSize Gets or sets the minimum distance that must remain
between the splitter control and tl1e container edge
that the control is docked to. Splitter.MinSize lias
been replaced by SplitContaiI1er.PanellMinSize and
SplitContainer.Panel2MinSize ru1d is provided only
for compatibility with previous versions.
Name Gets or sets the name of the control.
Padding Gets or sets padding withil1 the control.
480 I PowerShell Studio - A Comprehensive Guide
STATUSBAR
PROPERTY DESCRIPTION
ActualHeight Gets the rendered height of this element.
ActualWidth Gets the rendered width of this ele1nent.
AllowDro1> Gets or sets a value indicating whether this eleme11t
can be used as the target of a drag-and-drop operation.
This is a dependency property.
Alternation Count Gets or sets the nmnber of alten1ating item containers
in the Ite1nsControl, ivhich enables alten1ating
containers to have a unique appeara11ce. (hlherited
from ItemsControl.)
AreAoyTouchesCa1>tu red Gets a value that indicates whether at least one touch
is captured to this element.
AreAnyTouchesCapturedWithin Gets a value that indicates 'hether at least one touch
is capttued to this elen1ent or to any child ele1nents in
its visual tree.
AreAnyTouchesDirectlyOver Gets a value that indicates whether at least one touch
is pressed over this element.
AreAnyTouchesOver Gets a value tliat indicates whether at least one touch
is pressed over this element or any clrild elements i11
its visl1al tree.
Background Gets or sets a brusl1 that describes tl1e background of a
control
BindingGrou Jl Gets or sets the BindingGroup tliat is used for the
element.
BitmapEffect Obsolete.Gets or sets a bitmap effect that applies
directly to the rendered content for this element. This
is a dependency property.
Bitm apEJ'fectln1>ut Obsolete. Gets or sets an input source for the bitmap
effect that applies directly to tl1e rendered co11te11t .for
this element. This is a dependency property.
BorderBrush Gets or sets a brush that describes t11e border
background of a control.
BorderThickness Gets or sets the border thickness of a control.
482 I PowerShell Studio - A Comprehensive Guide
STATUSSTRIP
PROPERTY DESCRIPTION
--
AccessibilityObject
--
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDesc1;ption Gets or sets the default action description of tJ1e
control for use by accessibility client applications.
Accessib leDesc ri 1>tion Gets or sets the description of the control used by
accessibility client applications.
AccessibleName Gets or sets the name of the control used by
accessibility client applications.
J\ccessibleRole Gets or sets the accessible role of the control
Allo,vDrop Gets or sets a value indicating whether diag-and-drop
and item reorderiI1g are handled through events that
you i1nple1nent.
AllowItemReorder Gets or sets a value indicating whether drag-and-drop
and item reordering are handled privately by the
ToolStrip class.
Allow Merge Gets or sets a value indicating \Vhether 1n1tltiple
MenuStrip, ToolStripDropDownMenu,
ToolStripMenultem, and other types can be
combined.
Anchor Gets or sets the edges of tlie container to which a
ToolStrip is bound and detenniI1es how a ToolStrip is
resized ,;vith its parent.
AutoScroll Tllis API supports the product i11frastn1cture and is not
intended to be used directly fro in your code. This
property is not relevant for this class.
AutoScrollMargin Thls API supports tlle product illfrastructure aud is not
intended to be used directly from your code. This
property is not relevant for this class.
AutoScrollMinSize This API supports the product infTastructure a11d is not
intended to be used directly from your code. Tllis
property is not relevaut for this class.
AutoScrollOffset Gets or sets \Vhere this control is scrolled to in
ScrollControllntoView.
AutoScroUPosition Tllis API supports the product infrastructure aud is not
intended to be used directly fron1 your code. Tllis
property is not relevant for this class.
PowerShell Studio - Reference Guide I 489
Events Gets the list of event handlers that are attached to this
Component.
Focused Gets a val11e indicati11g whether the co11trol has input
focus.
Font Gets or sets the font used to display text il1 tl1e co11trol.
FontHeight Gets or sets the heigl1t of the font of the control.
ForeColor Gets or sets t11e foreground color of tl1e ToolStrip.
Gri1>Dis11JayStyle Gets the orientation of the ToolStrip move handle.
GripMargin Gets or sets the space around the ToolStrip 111ove
J1andle.
GripRectangle Gets the boundaries of the ToolStrip move hru1dle.
GripStyle Gets or sets the visibility of tl1e grip used to reposition
the control.
Handle Gets the \;vindow handle that the control is bound to.
Has Children This API supports the product infrastructure ru1d is not
intended to be used directly fro1n your code. This
property is not relevant for this class.
Height Gets or sets the heigl1t of the co11tro1.
HorizontaJScroll Tllis API suppo1ts tl1e product infrastructure and is not
intended to be used directly fron1 your code. This
property is not relevant for tllis class.
HScroll Gets or sets a value indicating whether the horizontal
scroll bar is visible.
ImageList Gets or sets the in1age list that contains the ilnage
displayed on a ToolStrip item.
lmageScalingSize Gets or sets tl1e size, in pixels, of ai1 image used on a
ToolStrip.
ImeMode Gets or sets the Input Method Editor (IME) n1ode of
the control.
ImeModeBase Gets or sets the IME mode of a control.
InvokeRequired Gets a value indicati11g ,;v hethe-r the caller n1ust call an
invoke inethod when 1naking method calls to the
control because the caller is on a different thread than
tl1e one the control vvas created on.
IsAccessible Gets or sets a value indicating whether the control is
visible to accessibility applications.
Is CurrentlyDragging Gets a value indicating \\i hether the user is currently
1noving tl1e ToolStiip from. one ToolStripContainer to
another.
IsDisposed Gets a value indicating ,;vhether the control has been
disposed of.
Gets a value indicating 'vhetlter a ToolStrip is a
ToolStripDropDown control.
IsHandleC reated Gets a value indicati11g \hether the co11trol has a
haildle associated with it.
lsMirrored Gets a value indicating whether the control is
mirrored.
492 I PowerShell Studio - A Comprehensive Guide
Window Target This API supports the product infrastn1cture and is not
intended to be llSed directly from your code. This
property is not relevant for this class.
TABCONTROL
PROPERTY DESCRIPTION
Accessib.ilityObject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets the default action description of the
control for use by accessibility client applications.
AccessibleDescri1>tion Gets or sets the description of the control used by
accessibility client applications.
AccessibleN a.me Gets or sets the name of the control used by
accessibility client applications.
AccessibleRole Gets or sets the accessible role of the control
Alignment Gets or sets the area of the control (for example, along
the top) where the tabs are aligned.
Gets or sets a value indicating vvhether the control can
accept data that tbe user drags onto it.
Anchor Gets or sets the edges of tl1e container to vvbich a
control is bou11d and detennines how a control is
resized '.vith its parent.
AJ>pearance Gets or sets the visual appearance of tl1e co11trol's tabs.
AutoScrollOffset Gets or sets where this control is scrolled to il1
ScrollControllntoView.
Auto Size This API supports the product hlfrastn1ctlrre and is not
intended to be used directly fro1n your code. This
property is not relevai1t for this class.
BackCo.l or This API supports tl1e product infrastructure and is not
intended to be used directly from your code. This
n1ember is not n1eaitingful for this control.(Overrides
Control.BackColo r. )
Backgroundlmage This API supports the product infrastructure and is not
intended to be used directly from your code. This
n1ember is not n1eailli1gful for this control.(Overrides
Co11trol.Backgroundl1nage.)
BackgroundlmageLayout This API supports the product infrastn1cture and is not
intended to be used directly fro1n your code. Tlris
n1e1nber is not meairingful for this control.(Overrides
Contro l.BackgroundimageLayout.)
Bin dingContext Gets or sets the BindingContext for the control.
Bottom Gets the distance, in pixels, between tl1e botto1n edge
of the control ai1d the top edge of its container's client
area.
Bounds Gets or sets the size and location of the control
including its nonclient elements, in pixels relative to
the parent control.
PowerShell Studio - Reference Guide I 495
TABLELAYOUTPANEL
PROPERTY DESCRIPTION
AccessibilityOb ject Gets the AccessibleObject assigned to tl1e control.
PowerShell Studio - Reference Guide I 499
TEXTBOX
PROPERTY DESCRIPTION
AcceptsRetum Gets or sets a value that indicates how the text editing
control responds wl1en the user presses the ENTER
key.
Accepts Tab Gets or sets a value that indicates how tl1e text editing
control responds when tl1e user presses the TAB key.
Actuaffieight Gets the rendered height of tllis element.
ActualWiclth Gets the rendered width of this elernent.
AllowDrop Gets or sets a value indicating whether this element
can be used as the target of a drag-and-drop operation.
This is a dependency property.
AreAnyTouchesCaptured Gets a value that indicates vvhether at least one touch
is captured to this ele1nent.
A:reAnyTouchesCapturedWithin Gets a value that indicates \Vhether at least one touch
is captured to this element or to any child elements in
its visual tree.
AreAnyTouchesDirectlyOver Gets a value that indicates whether at least one touch
is pressed over this elen1ent.
504 I PowerShell Studio - A Comprehensive Guide
DefaultStyleKey Gets or sets the key to use to reference the style for
this control, when theme styles are used or defined.
Depen dencyOb,icctType Gets the DependencyObjectType that \ivraps tbe CLR
type of this instance. (Inhe1ited fro1n
Dependency Object.)
DesiredSize Gets the size that this element computed during the
measure pass of the layout process.
Gets the Dispatcher tl1is DispatcherObject is
associated with. (Inherited from DispatcherObject.)
Effect Gets or sets the bitmap effect to apply to the
UIEle1nent. This is a dependency property.
ExtentHeigbt Gets the vertical size of the visible content area.
ExtentWidth Gets the horizontal size of the visible content area.
FlowDirection Gets or sets the direction that text and other user
i11terface (UI) elements flo"v within any parent
element that controls their layout.
Focusable Gets or sets a value that indicates whether the eleme11t
can receive focus. This is a depe11dency property.
FocusVisuaJStvJe
Gets or sets a property that enables customization of
appearance, effects, or other style characteristics that
will apply to this element when it captures keyboard
focus.
FontFamily Gets or sets the font family of the control.
FontSize Gets or sets the font size.
FontStretcb Gets or sets the degree to which a font is condensed or
expai1ded on the screen.
FontStyle Gets or sets the font style.
FontWeight Gets or sets t11e weigl1t or thickness of the specified
font.
ForceCursor Gets or sets a value that indicates \vhether this
Frame~1orkEle1ne11t should force the user interface
(UI) to render the cursor as declared by the Cmsor
property.
Foreground Gets or sets a b111sl1 that describes the foreground
color.
Han cllesScrolling Gets a value that indicates whether a co11trol suppo11s
scrolling.
HasAnimatedPro11erties Gets a value indicating \Vhether this element has any
animated properties.
HasEffectiveKeyboardFocus Gets a value that indicates 'vhetl1er the UIElement has
focus.
Height Gets or sets the s11ggested height of the element.
HorizontalAlign:ment Gets or sets the horizontal aligmnent characteristics
applied to this element when it is composed '1vithin a
parent element. such as a panel or items control.
HorizontalContentAlignment Gets or sets the horizontal aligmnent of the control's
conte11t.
HorizontalOffset Gets or sets the horizontal scroill position.
506 I PowerShell Studio - A Comprehensive Guide
lsMouseDi rectlyOver Gets a value tliat indicates \Vhether the position of the
mouse pointer corresponds to hit test results, which
take element compositing into account. This is a
dependency prope1ty.
lsMouseOver Gets a value indicatil1g ' vhether the mouse pointer is
located over this eleme11t (including child elements in
the visual tree). This is a dependency property.
lsReadOnly Gets or sets a value that indicates whether the text
editing control is read-only to a user interacting with
the control.
IsReadOnlyCaretVisible Gets or sets a value that indicates whether a read-only
text box displays a caret.
IsSeaJed Gets a value tl1at indicates '"hether this instance is
currently sealed (read-only).(Inherited fro1n
Depende11cyObject.)
lsSelectionActive Gets a value that indicates whether the text box has
focus and selected text.
lsStylusCaptured Gets a value indicating wl1ether the stylus is captured
by this element. This is a dependency property .
lsStylusCaptureWitbin Gets a value that detennines whether stylus capture is
held by this element, or an element within the element
bounds and its visual tree. Tlris is a dependency
property .
IsStylusDirectlyOver Gets a value tl1at indicates \.Vhether the stylus position
corresponds to hit test results, wlrich take element
con1positing into account. Tlris is a dependency
property .
IsStylusOver Gets a value :indicating \vhether tl1e sty lus cursor is
located over this element (including visual child
elements). This is a dependency property.
IsTabStop Gets or sets a value that indicates vvhether a control is
i11cluded in tab navigation.
IsUndoEnabled Gets or sets a value that indicates whether undo
support is enabled for tl1e text-editing control.
IsVisible Gets a value indicating whether tlris ele1nent is visible
in the user inte1face (Ul). Tltls is a dependency
property.
Language Gets or sets localization/globalization language
infonnation tllat applies to an ele1nent.
LayoutTransfo rm Gets or sets a graphics transforniation that shottld
apply to this element when layout is perfonned.
LineCount Gets the total 11umber of lines in the text box.
LogicaJChilclren Gets an enu1nerator for the logical child elements of
the TextBox.(Overrides
FraineworkElen1ent.LogicalChildren.)
Margin Gets or sets the outer margin of an element.
MaxHeight Gets or sets the maximum height constraint of the
element.
Gets or sets the maximu1n number of characters that
can be manually entered into the text box.
508 I PowerShell Studio - A Comprehensive Guide
TIMER
PROPERTY DESCRIPTION
Auto Reset Gets or sets a Boolean i11dicating whetl1er tl1e Timer
should raise the Elapsed event only once (false) or
repeatedly (tn1e).
PowerShell Studio - Reference Guide I 511
TOOLBAR
PROPERTY DESCRIPTION
Actuaffieight Gets the rendered height of tlris element.
ActualWidth Gets the rendered width of this element.
AllowDrop Gets or sets a value indicating whether this element
can be used as the target of a drag-and-drop operation.
This is a dependency property.
AlternationCount Gets or sets the number of alternating iten1 containers
in the Ite1nsControl, which enables alternating
co.ntainers to have a u1rique appearance. (Inherited
fro1n ItemsControl.)
AreAnyTouchesCa1Jtu red Gets a value tliat i11dicates \svhether at least one touch
is captured to this element.
AreAnyTouchesCaJJturedWithin Gets a value that indicates \Vhether at least one toucl1
is capt1rred to this ele1nent or to any child elements in
its visual tree.
AreAnyTouchesDirectlyOver Gets a value tllat indicates whether at least one touch
is pressed over this element.
AreAnyTouchesOver Gets a value tl1at iI1dicates whether at least one touch
is pressed over this elernent or any child elements in
its visual tree.
Background Gets or sets a bn1sh that describes the background of a
control.
Band Gets or sets a value that indicates where the toolbar
should be located in the ToolBarTray .
Bandlndex Gets or sets the band index r11unber that indicates the
position of the toolbar on the band.
BindingGrou11 Gets or sets the BindingGroup tliat is used for the
ele1nent.
512 I PowerShell Studio - A Comprehensive Guide
FlowDirection Gets or sets tl1e direction tl1at tex.1: and other user
interface (UI) elements flow within any parent
eleme11t that controls their layout.
Focusable Gets or sets a value that indicates "'' hether the element
can receive focus. This is a dependency property .
FocusVisualStyJe Gets or sets a property that enables customization of
appearance, effects. or other sty le characteristics that
will apply to this element when it captures keyboard
focus.
FontFamily Gets or sets the font fanrily of the control.
FontSize Gets or sets the font size.
FontStretcb Gets or sets the degree to which a font is condensed or
expanded on the screen.
FontStyle Gets or sets the font style.
FontWeight Gets or sets the weight or tlrickness of tl1e specified
font.
ForceCursor Gets or sets a value tl1at indicates \Vl1ether this
FrameworkElement should force tl1e user interface
(Ul) to render the cursor as declared by tl1e Cursor
property .
Foreground Gets or sets a brush tl1at describes tl1e foreground
color.
Grou11Style Gets a collection of GroupStyle objects that define the
appearance of each level of groups.(Inherited fro1n
Iten1SControl.)
Grou pStyleSelector Gets or sets a inethod that enables you to provide
custon1 selection logic for a GroupStyle to apply to
each group in a collection (Inherited from
Ite1nsControl.)
HandlesScrolling Gets a value tliat indicates 'vhether a control supports
scrolling.
HasAnimatedProperties Gets a value indicating whether this element has ai1y
animated properties.
HasEffectiveKeyboardFocus Gets a value that indicates whether the UIElen1ent has
focus.
HasHeader Gets a value tl1at indicates "vhetl1er this
Headeredlte1nsControl has a header. (Inherited fro1n
HeaderedltemsControl.)
HasItems Gets a value tliat indicates 'vhether the Iten1sControl
contains ite1ns. (Inherited from ItemsCoutrol.)
HasOverflowItems Gets a value that indicates whether the toolbar has
iten1s that are not visible.
Header Gets or sets the item that labels the control. (lnl1erited
from HeaderedltemsCo ntrol.)
HeaderStringFormat Gets or sets a composite string that specifies ho\v to
fonnat the Header property if it is displayed as a
string.(lnherited fron1 HeadereditemsControl.)
514 I PowerShell Studio - A Comprehensive Guide
TouchesOver Gets all touch devices t11at are over this element or
any child elements in its visual tree.
Triggers Gets the collection of niggers established directly on
this ele1nent, or in child elements.
Uid Gets or sets the unique identifier (for localization) for
this ele1nent. This is a dependency property.
U seLayoutRounding Gets or sets a value that indicates whether layout
rounding should be applied to this elen1ent's size and
position dtrring layout.
Ve11ica1Alignoient Gets or sets the vertical alignment characteristics
applied to this element when it is composed within a
parent element such as a panel or items control.
VerticalContentAlignment Gets or sets the vertical align1nent of the control's
content.
Visibility
Gets or sets the user interface (UI) visibility of tllis
element. This is a dependency property.
VisualBitmapEffect Obsolete. Gets or sets the BitmapEffect value for the
Visual.
Visu alBitmapEffectln put Obsolete. Gets or sets the BitmapEffectlnput value for
the Visual.
VisuaIBitmapScalingMode Gets or sets the BitmapSca1ingMode for the Visual.
VisualCacheMode Gets or sets a cached representation of tbe Visual.
VisualChildrenCount Gets the number of visual child elements within tllis
element.
VisualClearTypeHint Gets or sets the ClearTypeHint that detennines how
ClearType is rendered in the Visual.
VisualCli1> Gets or sets the clip region of the Visual as a
GeometTy value.
VisualEdgeMode Gets or sets the edge inode of the Visual as a11
EdgeMode value.
VisualEffect Gets or sets the bitmap effect to apply to the Visual.
VisualOffset Gets or sets the offset value of the visual object.
VisualOpacity Gets or sets the opacity of the Visual.
Visu alOpacityMask Gets or sets the B1ush value that represents the
opacity mask of the Visual
VisualParent Gets the visual tree parent of the visual object
VisualScrollableAreaClip Gets or sets a clipped scrollable area for the Visual
Visu aJTe:\."tHintin gMode Gets or sets the TextHintingMode of tl1e Visual.
VisualTextRenderingMode Gets or sets the TextRenderingMode of the Visual.
Visual Transform Gets or sets the Transform value for the Visual.
VisualXSnappingGuidelines Gets or sets the x-coordinate (vertical) guideline
collection.
VisualYSnaJlJlin gGuidelines Gets or sets they-coordinate (horizol}tal) guideline
collection.
Width Gets or sets the \vidth of the ele1nent.
PowerShell Studio - Reference Guide I 519
TOOLSTRIP
PROPERTY DESCRIPTION
AccessibilityObject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets the default action description of tl1e
control for use by accessibility client applicatio11s.
AccessibleDesc1iption Gets or sets the description of the control used by
accessibility client applications.
AccessibleNaine Gets or sets the name of the co11trol used by
accessibility client applications.
Accessible:R..ole Gets or sets the accessible role of the control
AllowDrop Gets or sets a value indicating l-vhether drag-and-drop
and item reordering are hai1dled through events that
you implement. (Overrides Control.Allo,Drop.)
AllowItemReorder Gets or sets a value indicating l-Vhether drag-and-drop
and item reordering are handled privately by the
ToolStrip class.
AllowMerge Gets or sets a value indicating \<vl1ether multiple
MenuStrip, ToolStripDropDownMenu,
ToolStripMenultem, and other types can be
co1nbined.
Anchor Gets or sets the edges of the container to \fV bicl1 a
ToolStrip is bound a11d detennines how a ToolStrip is
resized with its parent. (Overrides Control.Anchor.)
AutoScroll Tius API supports the product infrastructure and is not
intended to be used directly from your code. This
property is not relevant for this class. (Overrides
ScrollableControl.AutoScroU.)
AutoScrollMargin This API supports the product infrastructure and is not
intended to be used directly from your code. This
property is not relevant for tllis class.
AutoScrollMillSize This API supports the product infrastruct1ue and is not
intended to be used directly fro1n yotu code. Tlris
property is not relevant for tllis class.
AutoScroUOffset Gets or sets where this control is scrolled to in
ScrollCo ntrollnto View.
AutoScrollPosition This API supports the product infrastruct1ue and is not
intended to be used directly from your code. This
property is not relevant for this class.
Auto Size Gets or sets a value indicating whether the control is
automatically resized to display its entire
contents.(Ovenides Control.AutoSize.)
BackColor This API supports the product infrastn1cture ai1d is not
intended to be used directly fro111 yo1u code. Gets or
sets the backgro1u1d color for the ToolStriy.
Backgroundlmage Gets or sets the backgrou.nd image displayed in the
control.
BackgroundlmageLayout Gets or sets the background image layout as defined
in tlle I1nageLayout enun1eration.
520 I PowerShell Studio - A Comprehensive Guide
Show Keyboard Cues Gets a value indicating whether the user interface is in
the approp1iate state to show or hide keyboard
accelerators.
Site Gets or sets the site of the control.
Size Gets or sets the height and width of the control.
Stretch Gets or sets a value indicating vvhether the ToolStrip
stretches from end to end in the ToolStripContainer.
TabIndex Gets or sets the tab order of the control witlrin its
container.
TabStop Gets or sets a value indicating ,;vhether the user can
give the focus to an item in t11e ToolStrip using tl1e
TAB key.
Tag Gets or sets the object t11at contains data about the
control.
Text Gets or sets the text associated ,;vith tllis control.
TextDirection Gets or sets the direction in which to draw text on a
ToolStrip.
TO)l Gets or sets the distance, in pixels, betvveen tl1e top
edge of the control and the top edge of its contaiI1e1Js
client area.
TopLevelControl Gets the parent control that is not parented by a11other
Windows Fo1n1s control. Typically>tllis is the
outennost Fonn that tl1e control is contai11ed in.
UseW aitCursor Gets or sets a value indicating whetl1er to use the wait
cursor for the current control and all child controls.
VerticalScroll Tllis API supports the product infrastn1cture and is not
intended to be used directly fro1n your code. This
property is not relevant for tllis class.
Visible Gets or sets a value indicating whether the control and
all its cllild controls are displayed.
VScroll Gets or sets a value indicating ,;vhether the vertical
scroll bar is visible.
Width Gets or sets the width of the control.
WindolvTarget Tllis API supports the product infrastn1cture ai1d is not
intended to be used directly fro1n your code. This
property is not releva11t for this class.
TOOLTIP
PROPERTY DESCRIPTION
Active Gets or sets a value indicating whether the ToolTip is
currert~y active.
AutomaticDelay Gets or sets the automatic delay for the ToolTip.
AutoPopDelay Gets or sets the period of time the ToolTip re1nains
visible if the pointer is stationary on a control with
specified ToolTip text.
PowerShell Studio - Reference Guide I 525
TRACKBAR
PROPERTY DESCRIPTION
AccessibilityO bject Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDescription Gets or sets tl1e default action description of t11e
control for use by accessibility client applications.
AccessibleDescription Gets or sets the description of the co11trol used by
accessibility client applications.
526 I PowerShell Studio - A Comprehensive Guide
MaximumSize Gets or sets the size tl1at is the upper limit that
GetPreferredSize can specify.
Minimum Gets or sets the lower limit of the range this TrackBar
is working with.
MinimumSize Gets or sets the size that is the lower linrit that
GetPreferredSize can specify .
Name Gets or sets the name of the control.
Orientation Gets or sets a value indicating the horizontal or
vertical orientation of the track bar.
Padding This API supports the product infrastructure and is not
intended to be used directly from yotrr code. Gets or
sets the space between the edges of a TrackBar
control and its contents.
Parent Gets or sets the parent container of the control.
PrefenedSize Gets the size of a rectangular area into "vlrich tl1e
control can fit.
ProductName Gets the product name of the asselnbly co11taining the
control.
ProductVersion Gets tl1e version of tl1e assembly containing the
control.
RecreatingHandle Gets a value indicating ,;yhether the control is
currently re-creating its handle.
Region Gets or sets the windo\;v region associated with the
control.
RenderRightToLeft Obsolete.This properly is now obsolete.
ResizeRedraw Gets or sets a value indicating whether the control
redraws itself "vhen resized.
Right Gets the distai1ce, in pixels, between the right edge of
the control and the left edge of its container's client
area.
RigbtToLeft Gets or sets a value indicating whether control's
eleme11ts are aligned to support locales using right-to-
left fonts.
RightToLeftLayout Gets or sets a value indicating whether the contents of
the TrackBar will be laid out from right to left.
ScaleCbildren Gets a value that determines tl1e scaling of clrild
controls.
SbowFocusCues Gets a value indicating \;yhether tl1e control should
display focus rectangles.
ShowKeyboard
Cues Gets a value indicating \ hether the user it1terface is in
the appropriate state to sho"v or hide keyboard
accelerators.
Site Gets or sets the site of the control.
Size Gets or sets the height and width of the control
Small Change Gets or sets the value added to or subtracted from the
Value property \hen the scroll box is inoved a small
distance.
Tabln.dex Gets or sets the tab order of tl1e control within its
co ntai11er.
530 I PowerShell Studio - A Comprehensive Guide
TREEVIEW
PROPERTY DESCRIPTION
Accessibil.ityObject
--
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDesc1;ption Gets or sets the default action desc1iption of the
control for use by accessibility clie11t applications.
Accessib leDescri 1>tion Gets or sets the desc1iption of the control used by
accessibility client applications.
AccessibleName Gets or sets the na1ne of the control tISed by
accessibility client applications.
AccessibleRole Gets or sets the accessible role of the control
AllowDrop Gets or sets a value indicating whether the control can
accept data tl1at the user drags onto it.
Anchor Gets or sets the edges of the container to which a
control is bound and detennines how a control is
resized with its parent.
AutoScrollOtfset Gets or sets \.Vhere this control is scrolled to in
ScrollControllntoView.
PowerShell Studio - Reference Guide I 531
Auto Size This API supports the product infrastructure and is not
intended to be used directly from yo1u code. This
property is not relevant for this class.
BackColor Gets or sets the background color for the
control.(Overrides Control.BackColor.)
Backgrouncllm.age This API supports the prod11ct infrastructure and is not
intended to be used directly from your code. Gets or
set tl1e background iI1IBge for the TreeView
control. (Overrides Contra l.Backgroundlmage.)
Backgrou ndlmageLayou t This API supports the product infrastn1cture and is not
intended to be used directly fro1n your code. Gets or
sets the layout of tl1e background image for tl1e
TreeView control.(Overrides
Control.BackgroundlmageLayout.)
Bin dingContext Gets or sets the BindingContext for the control.
BorderStyle Gets or sets the border style of tl1e tree vie'v control.
Bottom Gets the distance, in pLxels, beuveen the bottom edge
of tl1e control and tl1e top edge of its container's client
area.
Bounds Gets or sets the size and location of the control
including its nonclient elen1ents, in pixels, relative to
the pare11t control.
CanEnablelme Gets a value indicating whether the ImeMode
property can be set to an active value, to enable IME
support.
CanFocus Gets a value indicating whether the control can
receive focus.
CanRaiseEvents Determines if events can be raised on the control.
CanSelect Gets a value indicating \V hether the control can be
selected.
Capture Gets or sets a value indicating whether the control has
captured the n1ouse.
CausesValidation Gets or sets a value indicating ' vhetl1er the control
causes validation to be perforn1ed on any controls tl1at
require validation when it receives focus.
CheckBoxes Gets or sets a value indicating whether check boxes
are displayed next to the tree nodes in the tree view
control.
ClientRectan gle Gets the rectangle that represents the client area of tl1e
control.
ClientSize Gets or sets the height and width of the client area of
the contro1.
Com1>anyName Gets the nan1e of the company or creator of the
application containing the co11trol.
Container Gets the IContainer that contains the Co1nponent.
ContainsFocus Gets a value indicating whether the contro~ or one of
its child controls, cu1Tently has the input foCllS.
ContextMenu Gets or sets the shortcut menu associated with the
control.
532 I PowerShell Studio - A Comprehensive Guide
VSCROLLBAR
AccessibilityObject
Gets the AccessibleObject assigned to the control.
AccessibleDefaultActionDesc1iption Gets or sets the default action description of the
control for use by accessibility client applications.
AccessibleDescription Gets or sets the description of the control used by
accessibility client applications.
AccessibleN ame Gets or sets the nan1e of the control used by
accessibility client applications.
i\ccessible:R.ole Gets or sets the accessible role of the control
Allo,vDro1> Gets or sets a value indicating vvhether the control can
accept data that the user drags onto it.
Anchor Gets or sets the edges of the container to which a
control is bound and determines how a control is
resized with its parent.
AutoScrollOffset Gets or sets where this contTol is scrolled to in
ScrollControllntoVievv.
Auto Size Gets or sets a value indicating whether the ScrollBar
is automatically resized to fit its contents.(Inherited
from ScrollBar.)
BackColor This API supports the product infrastn1cture and is not
intended to be used directly fro1n.your code. Gets or
sets the background color for the co11trol.(I11herited
from ScrollBar.)
Backgroundlmage This API supports the product infrastructure and is not
intended to be used directly from your code. Gets or
sets the background inIBge displayed in the
control.(Inherited from ScrollBar.)
Backgrou ndlmageLayout This API supports the product infrastn1cture and is 11ot
intended to be used directly fro1n your code. Gets or
sets the background il1i.age layout as defined in the
ImageLayont enumeration. (Inherited from ScrollBar.)
Bin dingContext Gets or sets the BindingContext for the control.
Bottom Gets the distance, in pixels, between tl1e botto1n edge
of the control and the top edge of its container's client
area.
Bounds Gets or sets the size and location of tl1e control
including its nonclient elements, in pixels, relative to
tl1e parent control.
CanEnablelme Gets a value indicating whether the ImeMode
property ca11 be set to an active value, to enable IME
support.
PowerShell Studio - Reference Guide I 537
WEBBROWSER
PROPERTY DESCRIPTION
AccessibilityO bject Gets the AccessibleObject assigned to the control.
Accessi.b leDefaultActionDescription Gets or sets the default action desc1iption of the
control for use by accessibility client applications.
AccessibleDescription Gets or sets the description of the control used by
accessibility client applications.
AccessibleName Gets or sets the name of the control used by
accessibility client aeplications.
AccessibleRole Gets or sets the accessible role of the control
PowerShell Studio - Reference Guide I 541
UseW aitCursor This API supports the product infrastructure and is not
intended to be used directly from your code. This
property is not supported by this control.(Inherited
fro1n WebBro"1serBase.)
Version Gets tl1e version of Internet Explorer installed.
Visible Gets or sets a value indicating whether tlle control and
all its child controls are displayed.
WebBrowserShortcutsEnabled Gets or sets a value indicating whether keyboard
shortcuts are enabled within the WebBro,vser control.
Width Gets or sets the width of the control.
Windo,vTarget This API supports the product infrastn1cture and is not
intended to be used directly from your code. This
property is not relevant for this class.
PowerShell Studio - Reference Guide I 547
INDEX
IMEMODE... 155, 340, 341, 344, 345, 352, 354, NOTIFYICON .......... ............................... 129, 262
364, 365, 369, 371,375,376, 379, 381,401, NUMERICUPDOWN ............................. 129, 266
403, 417, 419, 423,425,427, 429, 433, 435,
0
448, 449, 452, 454, 458,459, 471,473,488,
491, 494, 496, 499, 500, 519, 521 , 525,527, OBJECT BROWSER PANE ............................ 114
530, 532, 536, 537, 541 , 543 OFFLINE ACTIVATION .............................. ...... 21
INSTALLATION OPENFILEDIALOG .......... ........ 81, 267, 268, 336
COMPLETE................................................... 19 OPENFILEDIALOG ................................ 129, 267
CUSTOM .. ........... .... .................... ............... .. 19 OUTPUT FOLDER ............................................. 89
TYPICAL ....................................................... 19 OUTPUT PANE ............................................... 115
ISMIDCONTAINER ......................................... 160 OUTPUT SETIINGS ........................................... 82
L p
LABEL .. 167, 222, 234, 235 , 249, 27 6, 291, 293, PACKAGER .................................................... 80
296, 307, 401,403,404 PADDING .... 158, 341, 346, 350, 354, 361, 366,
LA BEL .................................................... 128, 234 372,377, 381,393, 399,403, 409,415,420,
LINKLABEL ............................................. 128, 235 425, 430, 435, 450,455,460, 466, 474, 485,
LISTBOX .................. ............................... 128, 236 491,496, 501, 507,516, 522, 528, 533, 538,
LISTVIEW........................................ 128, 133, 238 544
LOCAL CACHE ............................................... 58 PANEL ................................................... 129, 269
LOCAL SCOPE .............................................. 170 PANEL SETIINGS ............................................. 48
PAN ES ........................................................... l 0 7
M
PERFORMANCE PANE................................. 116
MANIFEST ................................................ 83, 173 PICTUREBOX ........ 270, 271, 307, 444, 445, 447
MASKEDTEXTBOX ................................. 128, 252 PICTUREBOX .......................... ............... 129, 270
MAXIMUMSIZE .... 158, 299, 34 l , 345, 354, 366, PLATFORM ....... ... ............ .... .... ... ..... ... ......... ... . 58
372, 377,381, 403, 420, 425,429 , 435, 450, POWERREGEX ................................................ 98
455, 460, 473, 491 , 496, 501, 522, 528, 533, POWERSHELL BROWSER .............................. 114
538, 543 POWERSHELL HELPWRITER ............................ 98
MDI FORM ..................................................... 165 POWERSHELL SETIINGS ................................. 49
MENU TEMPLATE ........................................... 148 PRESETS .. ......................... ...................... .......... 36
MENUSTRIP ........................................... 128, 257 PRIMALSCRIPT ........... 82, 95, 98, 332, 333, 336
MINIMUM REQUIREMENT ............................... 19 PRIMALSQL ........................................ ............. 98
MIN IMUMSIZE ..... 158, 341 , 345, 354, 366, 372, PRIMALXML .................................................... 98
377, 381 , 403, 420, 425, 429, 435, 450, 455, PRIVATE SCOPES ......................................... 170
460, 473, 491, 496, 501, 522, 528, 533, 538, PROFILE EDITOR ............................................. 98
543 PROGRESSBA R............................. 129, 133, 271
MODULE PROJECTS ..................................... 172 PROGRESSBAROVERLA Y .................... 129, 271
MONTHCALENDAR ............................. 128, 260 PROJECTPANE ............................................ 117
MSI SETIINGS ... ................................................86 PROPERTY PANE .......................................... 119
MULTI-FORM PROJECTS .... .................. 166, 171 PROPERTYGRID .. .................................. 129, 273
N R
NOTIFYICON .................. 20, 129, 262, 265, 266 RADIOBUTION ..................................... 130, 275
RECOVERY DATA ................................... 30, 167 TA BCONTROL ....................... ............... 130, 284
REMOTE CACHE .................................... 59, 329 TABLELAYOUTPANEL ........................... 131, 286
REMOTE CONNECTION ................................. 59 TEMP LA TES ............................................. 73, 138
REMOTE CONSOLE ........................................ 59 TEXT BOX TEMPLATE ..................................... 150
REMOTE SCRIPT EXECUTION ENGINE .......... 20 TEXT BOX WITH SEARCH TEMPLATE ............ 151
RESTORE POINTS ....... ...................... .............. l 00 TEXTBOX 81, 167, 192, 196, 208, 210, 219 , 220,
REWIND ............................ I 100
222,228, 268, 276, 277, 280, 28 1,287,288,
RICHTEXTBOX ................... ..................... 130, 27 6 293, 307,315,317,336, 361, 507
RIGHTTOLEFTLA YOUT. 154, 377, 430, 450, 497, TEXTBOX ....................................... 131, 133, 288
528,534 TIMER .................................................... 131, 289
RSEE DEPLOYMENT ...................................... 33 1 TOO LBAR .............................................. 131, 292
RSEE RESTRICTIONS ...................................... 334 TOOLBOX PANE ........................................... 125
TOOLS TAB ......................................................92
s
TOOLSTRIP ................................ ............ 131 , 293
SA VEF ILEDIALOG .................. 81, 277, 278, 336 TOOLTIP ................................. ............... 131 , 294
SAVEFILEDIALOG ................................. 130, 277 TRACEPOINTS ................................................. 61
SCOPE VARIABLES ....................................... 170 TRACKBAR ............................................ 13 1, 295
SCRIPT ENGINE SETIINGS .............................. 80 TREEVIEW ...................... ......... ............... 131, 30 l
SCRIPT MODULE .......................... l 72, l 73, 174
SCRIPT SCOPE .............................................. 170
u
SCRIPTMERGE ..................................... 19, 93, 94 UPDATES ........................................................ 104
SIGN SCRIPT .................................................... 9 2 USEMNEMON IC ................... 142, 342, 404, 461
SIGN ING .. .... ....... ... ......... ....... .... .... ............... .. . 83 USEWAITCURSORl 54, 342, 347, 356, 367, 374,
SIGN ING ......... .... .... ... ..... ....... .... ........ .... ... ... .... 90 378,383, 404, 421,426, 431,436,451,456,
SIGNING WIZARD ........................................... 90 461,475,493,498,502,523,529,535,539,
SINGLE THREADED APARTMENT ...81 , 155, 336 545
SN IPPET EDITOR ............................................ 121
v
SN IPPETS PANE ............................................. 121
SOURCE CONTROL SETTINGS ....................... 50 VER IFY SCRIPT ....................... ..........................9 7
SOURCE CONTROL TAB ................................ 99 VERSION INFORMATION ................................ 85
SPLITCONTAINER .................................. 130, 278 VERSIONRECALL .......... ...... 26, 51, 98, 100, 101
SPLITIER................................................. 130, 280 VIEWTAB ....................................................... 104
STA ............................................ 8 l , 8 2, l 55, 33 6 VSCROLLBAR ....................................... 132, 302
STAGING FOLDER ................................... ....... 89 w
STARTPOSITION ............................ 158, 159, 299
STARTUP.PSS ......................... 166, 168, 169, 172 WEBBROWSER ...... 303, 540, 542, 543, 544, 545
STATUSBAR ....... ..................................... 130, 28 1 WEBBROWSER ....................... ............... 132, 303
STATUSSTRIP .......................................... 130, 282 WIZARD TEMPLATE ....................................... 152
WMI BROWSER ............................................. 114
T WMI EXPLORER ............ ......... ... .......................98
TAB CONTROL TEMPLATE .................. .......... 149 WRAP COMMANDS ................ ....................... 39
TAB ORDER .............................................. . 72, 73