CSV Viewer

CSV Viewer is the latest addition to my self made tool box, as always the tool is written in PowerShell and converted into a exe. CSV Viewer is a light tool that you can use on any windows device that has PowerShell 2.0 and .net framework installed. The tool will open a browse for file dialog box that will only allow you to choose a CSV file then once you choose a file a data grid will open the file allowing you to view the content, you can even filter and sort the content of the csv file.

Download CSV Viewer






<#
    .SYNOPSIS
    View CSV files

    .DESCRIPTION
    Opens a browes box to select a CSV file, once a file is chosen a data grid will open the file 

    .NOTES
    Created By: Kris Gross
    Contact: Krisgross@sccmtst.com
    Twitter: @kmgamd
    Version 1.0.0.0

    .LINK
    You can get updates to this script and others from here
    http://www.sccmtst.com/
#>


Function Hide-PowerShellWindow()
{
    <#
        .SYNOPSIS
        Hides the PowerShell Console Window
        .DESCRIPTION
        Hides the PowerShell Console Window
        .PARAMETER Handle
        The Handle of the Window to Hide
        .EXAMPLE
        [Void]$(Hide-PowerShellWindow)
        .INPUTS
        .OUTPUTS
        .NOTES
        .LINK
    #>

    param (
    [IntPtr]$Handle=$(Get-Process -id $PID).MainWindowHandle
    )
    $WindowDisplay = @"
using System;
using System.Runtime.InteropServices;

namespace Window
{
public class Display
{
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

public static bool Hide(IntPtr hWnd)
{
return ShowWindowAsync(hWnd, 0);
}
}
}
"@
    Try
    {
        Add-Type -TypeDefinition $WindowDisplay
        [Window.Display]::Hide($Handle)
    }
    Catch
    {
    }
}
#EndRegion
[Void]$(Hide-PowerShellWindow)
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Function Get-FilePath{
    [CmdletBinding()]
    Param(
        [String]$Filter = "|*.csv",
        [String]$InitialDirectory = "$ENV:SystemDrive\",
        [String]$Title = "CSV Viewer"
        )
        [void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
        $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
        $OpenFileDialog.initialDirectory = $InitialDirectory
        $OpenFileDialog.Title = $Title
        $OpenFileDialog.filter = $Filter
        [void]$OpenFileDialog.ShowDialog()
        $OpenFileDialog.filename
        $Global:CSVFile = $OpenFileDialog.filename
    }


Get-FilePath
If ($Global:CSVFile) {Import-Csv $Global:CSVFile | Out-GridView -Title "CSV Viewer"} else {EXIT 0}

Comments

Popular posts from this blog

Office 365 Deployment - Office 365 Upgrade Task Sequence

SCCM Task Sequence with GUI - How to install more then one image with a single Task Sequence