{"id":8409,"date":"2021-05-18T10:37:29","date_gmt":"2021-05-18T14:37:29","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8409"},"modified":"2021-05-18T10:37:31","modified_gmt":"2021-05-18T14:37:31","slug":"custom-csv-import-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/","title":{"rendered":"Custom CSV Import with PowerShell"},"content":{"rendered":"\n<div class=\"wp-block-image is-style-default\"><figure class=\"alignleft size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"213\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg\" alt=\"Photo by Vitaly Vlasov from Pexels\n\" class=\"wp-image-8410\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg 320w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460-300x200.jpg 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>I am always looking for opportunities to use PowerShell in a way that adds value to my work. And hopefully yours. This is one of the reasons it is worth the time and effort to learn PowerShell. It can be used in so many ways beyond the out-of-the-box commands. Once you understand the PowerShell language and embrace the paradigm of objects in the pipeline, PowerShell offers unlimited possibilities. In my case, I wanted to do more with the native Import-Csv command. I wanted to keep the original functionality, but I wanted it to do more. Here's how I did it. Even if you don't have a need for the end result, I hope you'll pay attention to the PowerShell scripting techniques and concepts. These are items that you can apply to your own work.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copy-Command<\/h2>\n\n\n\n<p>I started by using the <a href=\"http:\/\/bit.ly\/31Ty8Sm\" target=\"_blank\" rel=\"noreferrer noopener\">Copy-Command<\/a> function from the <a href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\" target=\"_blank\" rel=\"noreferrer noopener\">PSScriptTools <\/a>module. I knew I wanted to add some parameters and functionality. I originally thought I'd create a proxy function and replace Import-CSV with my custom version. But ultimately decided to create a \"wrapper\" function. This type of function shares most, if not all, of the parameters of a target command which are passed to it. The Copy-Command function copies the parameters from the original command to your new command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adjusting Parameters<\/h2>\n\n\n\n<p>Once I had the new parameters, I began tweaking. First, I got rid of the LiteralPath parameter and combined it with the Path parameter. In essence, I'm treating every path as a literal path. I also added custom parameter validation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">[Parameter(\n\u00a0\u00a0\u00a0\u00a0Position\u00a0=\u00a00,\n\u00a0\u00a0\u00a0\u00a0Mandatory,\n\u00a0\u00a0\u00a0\u00a0ValueFromPipeline,\n\u00a0\u00a0\u00a0\u00a0ValueFromPipelineByPropertyName,\n\u00a0\u00a0\u00a0\u00a0HelpMessage\u00a0=\u00a0\"The\u00a0path\u00a0to\u00a0the\u00a0CSV\u00a0file.\u00a0Every\u00a0path\u00a0is\u00a0treated\u00a0as\u00a0a\u00a0literal\u00a0path.\"\n\u00a0\u00a0\u00a0\u00a0)]\n[ValidateNotNullOrEmpty()]\n#Validate\u00a0file\u00a0exists\n[ValidateScript({\n\u00a0\u00a0\u00a0\u00a0If\u00a0((Test-Path\u00a0$_)\u00a0-AND\u00a0((Get-Item\u00a0$_).PSProvider.Name\u00a0-eq\u00a0'FileSystem'))\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$True\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Warning\u00a0\"Failed\u00a0to\u00a0verify $($_.ToUpper())\u00a0or\u00a0it\u00a0is\u00a0not\u00a0a\u00a0file\u00a0system\u00a0object.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Throw\u00a0\"Failed\u00a0to\u00a0validate\u00a0the\u00a0path\u00a0parameter.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$False\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0})]\n[Alias(\"PSPath\")]\n[string[]]$Path,<\/code><\/pre>\n\n\n\n<p>The validation script verifies the path and that it is a file system object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/validate-test.png\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"127\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/validate-test.png\" alt=\"\" class=\"wp-image-8412\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/validate-test.png 847w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/validate-test-300x45.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/validate-test-768x115.png 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/a><\/figure>\n\n\n\n<p>I also knew there were two optional features I wanted to add when importing CSV data. First, I wanted to capture the source file. I wanted it to be another property in the custom output.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">[Parameter(HelpMessage\u00a0=\u00a0\"Add\u00a0a\u00a0custom\u00a0property\u00a0to\u00a0reflect\u00a0the\u00a0import\u00a0source\u00a0file.\")][switch]$IncludeSource,<\/code><\/pre>\n\n\n\n<p>I also wanted the ability to define a typename. When you import data from a CSV file, PowerShell writes a generic custom object to the pipeline. But if I give it a typename, and use custom format files (which you know I do), I can improve the import experience. We'll get to that in a bit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">System.Collections.Generic.List[]<\/h2>\n\n\n\n<p>Both of these actions will require that I modify the data after it has been imported with the native Import-Csv command. Remember, I'm writing a wrapper function that offers the same functionality plus my additions. Because I need to modify objects after the import and before I write them to the pipeline, I need a temporary place to hold them. Technically, an array would work. I could initialize an empty array and then add the imported items to the array. However, technically, when you add an item to an array, PowerShell is destroying and recreating the array. For small datasets, this is not that critical. But I like to practice efficiency when I can, so I've been using generic lists.<\/p>\n\n\n\n<p>You can define a new list object like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$in = [System.Collections.Generic.List[object]]::New()<\/code><\/pre>\n\n\n\n<p>You can specify what type of object is in the list, such as string, or in my case the generic 'object'. In my function, I'm taking advantage of the Using statement. Before the function I have this line of code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Using\u00a0Namespace\u00a0System.Collections.Generic<\/code><\/pre>\n\n\n\n<p>In my function, this simplifies the code necessary to create the list object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$in\u00a0=\u00a0[List[object]]::New()<\/code><\/pre>\n\n\n\n<p>You can add a single object to the list with the Add() method, or multiple all at once with AddRange(). I haven't found much difference between the two so to keep it simple, I'll add each imported item to the list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Microsoft.PowerShell.Utility\\Import-Csv\u00a0@PSBoundParameters\u00a0|\u00a0ForEach-Object\u00a0{\u00a0$in.Add($_)\u00a0}<\/code><\/pre>\n\n\n\n<p>Notice that I'm splatting PSBoundParameters to the native command. I'm using the fully qualified command name. This allows me to call my function Import-Csv which would take precedence at a command prompt. By the way, I'm not. My function is called Import-CsvCustom, but I wanted to include this in case you decide to rename and to demonstrate a scripting concept.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Customizing Objects<\/h2>\n\n\n\n<p>With all of the imported data in the list, I can now modify the objects. If the user-specified to include the source path, I'll add a note property to the objects in the list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">if\u00a0($IncludeSource)\u00a0{\n\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[PROCESS]\u00a0Adding\u00a0CSVSource\u00a0property\"\n\u00a0\u00a0\u00a0\u00a0$in\u00a0|\u00a0Add-Member\u00a0-MemberType\u00a0NoteProperty\u00a0-Name\u00a0CSVSource\u00a0-Value\u00a0$cPath\u00a0-Force\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/csvsource.png\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"358\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/csvsource.png\" alt=\"\" class=\"wp-image-8414\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/csvsource.png 631w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/csvsource-300x170.png 300w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><\/a><\/figure>\n\n\n\n<p>I'm toying with some ideas on how to make this a hidden property and to let me specify the property name. It is unlikely I'll have a column called CSVSource in any of my CSV files. But as a rule, I like to have flexibility.<\/p>\n\n\n\n<p>As I mentioned, when you import a CSV file, you get generic custom objects.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-defaultmember.png\"><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"311\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-defaultmember.png\" alt=\"\" class=\"wp-image-8415\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-defaultmember.png 733w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-defaultmember-300x127.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/a><\/figure>\n\n\n\n<p>And as you can see in the previous image, I get a list of all objects and properties. But what if I had a custom format file that I've loaded into my session?<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-FormatData C:\\scripts\\bedrock.format.ps1xml<\/code><\/pre>\n\n\n\n<p>Now, I can import the data and assign a type name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-customtype.png\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"219\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-customtype.png\" alt=\"\" class=\"wp-image-8416\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-customtype.png 725w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/importcsv-customtype-300x91.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Import-CsvCustom<\/h2>\n\n\n\n<p>Want to try for yourself?<\/p>\n\n\n\n<pre title=\"Import-CsvCustom.ps1\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">#requires\u00a0-version\u00a05.1\n\n&lt;#\nThis\u00a0is\u00a0a\u00a0copy\u00a0of:\n\nCommandType\u00a0Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Version\u00a0Source\n-----------\u00a0----\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-------\u00a0------\nCmdlet\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Import-Csv\u00a03.1.0.0\u00a0Microsoft.PowerShell.Utility\n\nCreated:\u00a017\u00a0May\u00a02021\nAuthor\u00a0:\u00a0Jeff\u00a0Hicks\u00a0\n\nLearn\u00a0more\u00a0about\u00a0PowerShell:\u00a0http:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\n\n#>\n\n&lt;#\nI\u00a0am\u00a0using\u00a0a\u00a0namespace\u00a0to\u00a0make\u00a0defining\u00a0a\u00a0List[]\u00a0object\u00a0easier\u00a0later\nin\u00a0the\u00a0script.\n#>\nUsing\u00a0Namespace\u00a0System.Collections.Generic\n\nFunction\u00a0Import-CSVCustom\u00a0{\n\n\u00a0\u00a0\u00a0\u00a0#TODO\u00a0-\u00a0Add\u00a0comment-based\u00a0help\n\u00a0\u00a0\u00a0\u00a0[CmdletBinding(DefaultParameterSetName\u00a0=\u00a0'Delimiter')]\n\u00a0\u00a0\u00a0\u00a0Param(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(ParameterSetName\u00a0=\u00a0'Delimiter',\u00a0Position\u00a0=\u00a01)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNull()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[char]$Delimiter,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Position\u00a0=\u00a00,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Mandatory,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ValueFromPipeline,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ValueFromPipelineByPropertyName,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HelpMessage\u00a0=\u00a0\"The\u00a0path\u00a0to\u00a0the\u00a0CSV\u00a0file.\u00a0Every\u00a0path\u00a0is\u00a0treated\u00a0as\u00a0a\u00a0literal\u00a0path.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNullOrEmpty()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#Validate\u00a0file\u00a0exists\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateScript({\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0If\u00a0((Test-Path\u00a0$_)\u00a0-AND\u00a0((Get-Item\u00a0$_).PSProvider.Name\u00a0-eq\u00a0'FileSystem'))\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$True\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Warning\u00a0\"Failed\u00a0to\u00a0verify\u00a0$($_.ToUpper())\u00a0or\u00a0it\u00a0is\u00a0not\u00a0a\u00a0file\u00a0system\u00a0object.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Throw\u00a0\"Failed\u00a0to\u00a0validate\u00a0the\u00a0path\u00a0parameter.\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$False\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0})]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Alias(\"PSPath\")]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[string[]]$Path,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(ParameterSetName\u00a0=\u00a0'UseCulture',\u00a0Mandatory)]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNull()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[switch]$UseCulture,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNullOrEmpty()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[string[]]$Header,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateSet('Unicode',\u00a0'UTF7',\u00a0'UTF8',\u00a0'ASCII',\u00a0'UTF32',\u00a0'BigEndianUnicode',\u00a0'Default',\u00a0'OEM')]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[string]$Encoding,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(HelpMessage\u00a0=\u00a0\"Add\u00a0a\u00a0custom\u00a0property\u00a0to\u00a0reflect\u00a0the\u00a0import\u00a0source\u00a0file.\")]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[switch]$IncludeSource,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[Parameter(HelpMessage\u00a0=\u00a0\"Insert\u00a0an\u00a0optional\u00a0custom\u00a0type\u00a0name.\")]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[ValidateNotNullOrEmpty()]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[string]$PSTypeName\n\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0Begin\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[BEGIN\u00a0\u00a0]\u00a0Starting\u00a0$($MyInvocation.Mycommand)\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[BEGIN\u00a0\u00a0]\u00a0Using\u00a0parameter\u00a0set\u00a0$($PSCmdlet.ParameterSetName)\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0($PSBoundParameters\u00a0|\u00a0Out-String)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#remove\u00a0parameters\u00a0that\u00a0don't\u00a0belong\u00a0to\u00a0the\u00a0native\u00a0Import-Csv\u00a0command\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($PSBoundParameters.ContainsKey(\"IncludeSource\"))\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[void]$PSBoundParameters.Remove(\"IncludeSource\")\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($PSBoundParameters.ContainsKey(\"PSTypeName\"))\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[void]$PSBoundParameters.Remove(\"PSTypeName\")\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\u00a0#begin\n\n\u00a0\u00a0\u00a0\u00a0Process\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;#\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Initialize\u00a0a\u00a0generic\u00a0list\u00a0to\u00a0hold\u00a0each\u00a0imported\u00a0object\u00a0so\u00a0it\u00a0can\u00a0be\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0processed\u00a0for\u00a0CSVSource\u00a0and\/or\u00a0typename\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$in\u00a0=\u00a0[List[object]]::New()\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#convert\u00a0the\u00a0path\u00a0value\u00a0to\u00a0a\u00a0complete\u00a0filesystem\u00a0path\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$cPath\u00a0=\u00a0Convert-Path\u00a0-Path\u00a0$Path\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#update\u00a0the\u00a0value\u00a0of\u00a0the\u00a0PSBoundparameter\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$PSBoundParameters[\"Path\"]\u00a0=\u00a0$cPath\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[PROCESS]\u00a0Importing\u00a0from\u00a0$cPath\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;#\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Add\u00a0each\u00a0imported\u00a0item\u00a0to\u00a0the\u00a0collection.\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0It\u00a0is\u00a0theoretically\u00a0possible\u00a0to\u00a0have\u00a0a\u00a0CSV\u00a0file\u00a0of\u00a01\u00a0object,\u00a0so\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0instead\u00a0of\u00a0testing\u00a0to\u00a0determine\u00a0whether\u00a0to\u00a0use\u00a0Add()\u00a0or\u00a0AddRange(),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0I'll\u00a0simply\u00a0Add\u00a0each\u00a0item.\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0I'm\u00a0using\u00a0the\u00a0fully\u00a0qualified\u00a0cmdlet\u00a0name\u00a0in\u00a0case\u00a0I\u00a0want\u00a0this\u00a0function\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0to\u00a0become\u00a0my\u00a0Import-Csv\u00a0command.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Microsoft.PowerShell.Utility\\Import-Csv\u00a0@PSBoundParameters\u00a0|\u00a0ForEach-Object\u00a0{\u00a0$in.Add($_)\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[PROCESS]\u00a0Post-processing\u00a0$($in.count)\u00a0objects\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($IncludeSource)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[PROCESS]\u00a0Adding\u00a0CSVSource\u00a0property\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$in\u00a0|\u00a0Add-Member\u00a0-MemberType\u00a0NoteProperty\u00a0-Name\u00a0CSVSource\u00a0-Value\u00a0$cPath\u00a0-Force\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if\u00a0($PSTypeName)\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[PROCESS]\u00a0Adding\u00a0PSTypename\u00a0$PSTypeName\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$($in).foreach({\u00a0$_.psobject.typenames.insert(0,\u00a0$PSTypeName)})\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#write\u00a0the\u00a0results\u00a0to\u00a0the\u00a0pipeline\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$in\n\u00a0\u00a0\u00a0\u00a0}\u00a0#process\n\n\u00a0\u00a0\u00a0\u00a0End\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Write-Verbose\u00a0\"[END\u00a0\u00a0\u00a0\u00a0]\u00a0Ending\u00a0$($MyInvocation.Mycommand)\"\n\u00a0\u00a0\u00a0\u00a0}\u00a0#end\n\n}\u00a0#end\u00a0Import-CsvCustom<\/code><\/pre>\n\n\n\n<p>Save the code to a file that you can dot source in your PowerShell session. Then import CSV files and try it out. The function should work in Windows PowerShell and PowerShell 7.x. The function includes Verbose output and hopefully plenty of internal documentation to help you understand what I am doing.<\/p>\n\n\n\n<p>I hope you find this useful, or at least informative. And just maybe you too will begin thinking of ways to use PowerShell to do more.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am always looking for opportunities to use PowerShell in a way that adds value to my work. And hopefully yours. This is one of the reasons it is worth the time and effort to learn PowerShell. It can be used in so many ways beyond the out-of-the-box commands. Once you understand the PowerShell language&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Custom CSV Imports with #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[224,534,540],"class_list":["post-8409","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-function","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Custom CSV Import with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"PowerShell commands are handy but with the right skills, you can make them awesome. Here&#039;s how I created a custom Import-Csv command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom CSV Import with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"PowerShell commands are handy but with the right skills, you can make them awesome. Here&#039;s how I created a custom Import-Csv command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-18T14:37:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-18T14:37:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Custom CSV Import with PowerShell\",\"datePublished\":\"2021-05-18T14:37:29+00:00\",\"dateModified\":\"2021-05-18T14:37:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/\"},\"wordCount\":894,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/pexels-vitaly-vlasov-1342460.jpg\",\"keywords\":[\"Function\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/\",\"name\":\"Custom CSV Import with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/pexels-vitaly-vlasov-1342460.jpg\",\"datePublished\":\"2021-05-18T14:37:29+00:00\",\"dateModified\":\"2021-05-18T14:37:31+00:00\",\"description\":\"PowerShell commands are handy but with the right skills, you can make them awesome. Here's how I created a custom Import-Csv command.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/pexels-vitaly-vlasov-1342460.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/pexels-vitaly-vlasov-1342460.jpg\",\"width\":320,\"height\":213},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8409\\\/custom-csv-import-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Custom CSV Import with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Custom CSV Import with PowerShell &#8226; The Lonely Administrator","description":"PowerShell commands are handy but with the right skills, you can make them awesome. Here's how I created a custom Import-Csv command.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Custom CSV Import with PowerShell &#8226; The Lonely Administrator","og_description":"PowerShell commands are handy but with the right skills, you can make them awesome. Here's how I created a custom Import-Csv command.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2021-05-18T14:37:29+00:00","article_modified_time":"2021-05-18T14:37:31+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Custom CSV Import with PowerShell","datePublished":"2021-05-18T14:37:29+00:00","dateModified":"2021-05-18T14:37:31+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/"},"wordCount":894,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg","keywords":["Function","PowerShell","Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/","name":"Custom CSV Import with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg","datePublished":"2021-05-18T14:37:29+00:00","dateModified":"2021-05-18T14:37:31+00:00","description":"PowerShell commands are handy but with the right skills, you can make them awesome. Here's how I created a custom Import-Csv command.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/pexels-vitaly-vlasov-1342460.jpg","width":320,"height":213},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8409\/custom-csv-import-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Custom CSV Import with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4586,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/4586\/a-spooky-powershell-halloween\/","url_meta":{"origin":8409,"position":0},"title":"A Spooky PowerShell Halloween","author":"Jeffery Hicks","date":"October 31, 2015","format":false,"excerpt":"I shared some code yesterday on Twitter and Facebook, but you may have missed it and I wanted to have a more permanent record so this is it. In the spirit of the holiday, I thought it would spooky to have a little fun with the PowerShell ISE. A spooky\u2026","rel":"","context":"In &quot;Miscellaneous&quot;","block_context":{"text":"Miscellaneous","link":"https:\/\/jdhitsolutions.com\/blog\/category\/miscellaneous\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2062,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2062\/export-and-import-hash-tables\/","url_meta":{"origin":8409,"position":1},"title":"Export and Import Hash Tables","author":"Jeffery Hicks","date":"February 2, 2012","format":false,"excerpt":"I use hash tables quite a bit and with the impending arrival of PowerShell 3.0 I expect even more so. PowerShell v3 allows you to define a hash table of default parameter values. I'm not going to to cover that feature specifically, but it made me realize I needed a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1874,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1874\/background-performance-counters\/","url_meta":{"origin":8409,"position":2},"title":"Background Performance Counters","author":"Jeffery Hicks","date":"December 6, 2011","format":false,"excerpt":"Windows Powershell makes it relatively easy to collect performance counter information via the Get-Counter cmdlet. Because I'm assuming you want to collect more than a few seconds of performance information, you'll need to take advantage of PowerShell background jobs if you want your prompt back. Of course, you can always\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/12\/listcounters-300x206.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1136,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1136\/friday-fun-snappy-shortcuts\/","url_meta":{"origin":8409,"position":3},"title":"Friday Fun &#8211; Snappy Shortcuts","author":"Jeffery Hicks","date":"February 11, 2011","format":false,"excerpt":"In one of my recent Prof. PowerShell columns, I wrote about using the Wscript.Shell VBScript object in PowerShell to retrieve special folder paths. Another handy trick is the ability to create shortcut links to either file or web resources. Let me show you how to accomplish this in PowerShell and\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/02\/create-shortcuts-300x185.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1156,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1156\/powershell-ise-most-recent-files\/","url_meta":{"origin":8409,"position":4},"title":"PowerShell ISE Most Recent Files","author":"Jeffery Hicks","date":"February 21, 2011","format":false,"excerpt":"The PowerShell ISE is a handy tool for editing and testing your scripts, functions and modules. If you can't afford a good commercial editor then you should at least be using the ISE. One benefit of the ISE is that it has its own object model which means it is\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/02\/isemenu-300x198.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4609,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4609\/historically-speaking\/","url_meta":{"origin":8409,"position":5},"title":"Historically Speaking","author":"Jeffery Hicks","date":"November 24, 2015","format":false,"excerpt":"So I've recently had a need to begin using Slack. I started out using a web browser, but since there is a Windows client I decided to give it a go. This article isn't about Slack as much as what I was curious about and how I decided to tackle\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8409"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8409\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}