Archive

Archive for October, 2016

PowerShell – Out-GridView Headers

October 26, 2016 5 comments

I’ve liked the simplicty of PowerShell when using the Out-GridView against a data set when you want a quick sortable list.

If you use Out-GridView most likely you’re cutting and pasting into an Excel sheet

Out-GridView dosen’t allow you to copy the header row. But, a simple process will help

For example:

From example #4 on this page. https://technet.microsoft.com/en-us/library/hh849920.aspx

($A = Get-ChildItem -Path $pshome -Recurse) | Out-GridView

This displays the header bar but you’re unable to copy this header directly that I’ve not found.

outgridview1

CTRL+A and no grid headers selected.

outgridview2

Now create a simple object and function to run for storing header values:

$global:ReportHeaders = @()

function Report-Headers() {
 # There are a few methods for createing objects. Keeping this simple
 # to show the possibilities

# Sets up dummy object with headers for use in out-gridview
 $local:TestCollection = @()
 $TestProperties = new-Object Object
 add-Member -inputobject $TestProperties -membertype NoteProperty 
-Name "Mode" -Value ""
 add-Member -inputobject $TestProperties -membertype NoteProperty 
-Name "LastWriteTime" -Value ""
 add-Member -inputobject $TestProperties -membertype NoteProperty 
-Name "Length" -Value ""
 add-Member -InputObject $TestProperties -MemberType NoteProperty 
-Name "Name" -Value ""

$TestProperties.Mode = "Mode"
 $TestProperties.LastWriteTime = "Last Write Time"
 $TestProperties.Length = "Length"
 $TestProperties.Name = "Name"
 $local:TestCollection += $TestProperties
 $global:ReportHeaders = $local:TestCollection
 }

Report-Headers
 ($A = Get-ChildItem -Path $pshome -Recurse) | Out-GridView
 $global:ReportHeaders +=  $a
 $global:ReportHeaders | Out-GridView

Now there are simple headers to copy into excel or other tools.

outgridview3

Sample Excel:

outgridview4

Well, something very simple. If you’ve found a different way to do this please let me know.

Joseph

PowerShell -: Certificate Research

October 25, 2016 Leave a comment

I recently had an opportunity to interview for a gig setting up a CA (certificate authority) for a bank.  I’m familiar with the design and implementation of a CA, However, When you’re not constantly working with something on a day to day basis, a bit of studying won’t hurt anyone especially me.  This deep dive and refresh of knowledge has been good for the old noggin.

I’ve chosen to use PowerShell to assist with finding, managing and just generally working with PKI and certificates. I thought I’d jump in and reacquaint myself with the process and jump in I did.

I wanted to do the following.

  1. Monitor certificates on a machine
  2. Determine Validity of Certs on Machine
  3. Add Certs found on machine to Database for further analysis.
  4. Provide Reporting on a certs found created SSRS reports.
  5. Create an XML Object Model of a CERT.

 

Categories: PowerShell Posts

PowerShell The Basics ( for me anyway )

October 5, 2016 Leave a comment

PowerShell The Basics ( Profiles )

If you use one of the search engines now available you’ll find tons of information containing videos and blogs on what PowerShell is and explanations showing how to use it.  Simply put it could be any one of these things

  • What is PowerShell?
  • PowerShell Cmdlets
  • PowerShell Snapins
  • PowerShell Modules
  • PowerShell Remoting
  • Navigating in PowerShell
  • PowerShell Profiles

These are a  few things that I like to do when setting up PowerShell on my machine and machines in the environments where I typically work.  Providing that you have access to machines in your domain and the role you have can limit some processes within PowerShell. For example you might not have AD (Active Directory) access to review users or computer roles. But, if access is granted PowerShell can be of value. Read more…