Skip to main content

Posts

Showing posts from August, 2016

Another Advantage of Write-Information

Yesterday, at the end of my post, I mentioned that displaying information on the screen can slow down processing time.  It is true.  Here is a simple test. First of all, execute this code in the ISE Function Test-Information { [ cmdletbinding () ] Param () For ( $X = 0 ; $X -lt 1000 ; $X ++ ) {     Write-Information -MessageData "The value of X is $X " }     Write-Information -MessageData "Script Complete" -InformationAction Continue } Next execute this line of code. PS C:\> Measure-Command -Expression {Test-Information} Script Complete Days              : 0 Hours             : 0 Minutes           : 0 Seconds           : 0 Milliseconds      : 186 Ticks             : 1860662 TotalDays         : 2.15354398148148E-06 TotalHours        : 5.16850555555556E-05 TotalMinutes      : 0.00310110333333333 TotalSeconds      : 0.1860662 TotalMilliseconds : 186.0662 Take note of the milliseconds

How to use Write-Information

It is always fun to write on a topic that people are passionate about.  Yes, we will be talking about Write-Host in this post.  I know, you either love it or you hate it. PowerShell uses different “streams” of information.  Here is a quick visual. Stream |  Definition             | Cmdlet 1      |  Success output         | Write-Output       2      |  Errors                 | Write-Error        3      |  Warning messages       | Write-Warning      4      |  Verbose output         | Write-Verbose      5      |  Debug messages         | Write-Debug        6      |  Informational messages | Write-Information  NA     |  User Experience        | Write-Host          The above is a little display that I use in class.  Yes, it is created with Write-Host .  Write-Host is OK to use if you need to create a user interface of some type.  PowerShell was designed to use the pipeline.  This is stream 1.  Notice that there is no stream for Write-Host .  Write-Host sends inf

What Version of Windows are on my Clients?

It has been a very busy few months for me.  As you can see below, I’ve been spending a little time on board some Ships of the United States Navy.  Time to get back to work!!! So, how do you know what version of PowerShell your clients are running.  There are a variety of ways of doing this.  We are going to use a CIM sessions to remotely pull this information from your client machines.  A few things need to be in place first. PowerShell Remoting needs to be turning on. ( http://mctexpert.blogspot.com/2011/03/enable-powershell-v2-remote-management.html ) Give your clients time to update their group policy.  This may take more than a day depending on how your network is laid out. Query the clients from Active Directory that you want to query.  Here is the link to the Remote Server Administrator Tools for Windows 10.  There are similar versions all the way back to Windows 7.  Install this on your client. ( https://www.microsoft.com/en-us/download/details.aspx?id=45520 )