Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Powershell Tip: Formatting trick to make your search criteria stand out
fuzzylogic181
follow
0
3-24-2008 7:54 PM
372 views
fuzzylogic181
says:
Output format tip for Powershell
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
False Apology Syndrome
World Bank Under Cyber Siege - "unpreceden...
October 11, 1986
"Flipping Rings" Use Illegals As Straw Mor...
Oh, please
Counting one's chickens
Breaking News!!!
More clips from
fuzzylogic181
Accessing Exchange 2007 Unified Messaging ...
Running ESX 3.5 and 3i Under VMWare Workst...
Where did the HP Way go?
Today's Top Clips
Breaking News!!!
Investigation Ties Palin to 'Extreme Right-Wing Fringe'
1st time in US: 2 ethics violators on same ticket
Eye Colour
Street lamps powered by discarded batteries light the neighborhood for cheap
Can human consciousness survive without a brain?
FBI Silences Agents On 9/11 Disclosures
DNA could reveal your surname
McCain Goes After Michelle ...
It's Called Hubris
visit the
Top Clips page
View the Top Clips from
March 24, 2008
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://www.clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/813042cd-8cf3-43aa-98ae-c266ed01eb2b/DD3DC301-9265-43C2-BE09-0E3DF43D5914/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/" href="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/" style="font-size: 11px;">www.systemcenterforum.org</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><H2 class="storytitle"><A rel="bookmark" href="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/">Powershell Tip: Formatting trick to make your search criteria stand out</A></H2> </blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><P>This is quite easily done with a <STRONG>foreach </STRONG>loop and the Powershell equivalent of the if-then statement to change the color of the text based on the value of the <STRONG>ProxyEnabled </STRONG>status for each agent. In this case, if ProxyEnabled = false, text output will be <FONT color="#ff0000"><STRONG>RED</STRONG></FONT>. If ProxyEnabled = true, text output will be <FONT color="#008000"><STRONG>GREEN. </STRONG><FONT color="#000000">I have commented the sample script below to clarify the meaning of each statement.</FONT></FONT></P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><P><EM> <FONT color="#0000ff">#Retrieve all agents and assign to a variable</FONT></EM><FONT color="#0000ff"> $agents = get-agent </FONT></P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><P><FONT color="#0000ff"><EM> #For each agent in the $agents variable, execute the IF statement</EM> foreach ($agent in $agents){</FONT></P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><FONT color="#0000ff"><EM>#If ProxyEnabled = TRUE, write agent Name and ProxyEnabled status to the console in RED.</EM> If ($agent.ProxyingEnabled -match $true) {write-host $agent.name, $agent.proxyingenabled -foregroundcolor “red”}</FONT></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><P><FONT color="#0000ff">else</FONT></P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.systemcenterforum.org/powershell-tip-formatting-trick-to-make-your-search-criteria-stand-out/"><P><FONT color="#0000ff"><EM>#If ProxyEnabled = FALSE write agent Name and ProxyEnabled status to the console in GREEN.</EM> {write-host $agent.name, $agent.proxyingenabled -foregroundcolor “darkgreen”} }</FONT></P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/DD3DC301-9265-43C2-BE09-0E3DF43D5914/blog/" title="blog or email this clip"><img src="http://content9.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK