{"id":4200,"date":"2015-01-23T12:41:22","date_gmt":"2015-01-23T17:41:22","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4200"},"modified":"2015-01-23T12:46:51","modified_gmt":"2015-01-23T17:46:51","slug":"friday-fun-creating-sample-files","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/","title":{"rendered":"Friday Fun: Creating Sample Files"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-4001\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png\" alt=\"document\" width=\"144\" height=\"144\" \/><\/a>Not too long ago I came across a PowerShell snippet, probably via Twitter, that showed how to use a few classes from the System.IO namespace to create dummy files. Sadly I forgot the record where I saw this first mentioned. What I liked about the code I saw was the ability to create a dummy file of any size. You're probably wondering why you would ever want to do this. Way, way back in the day when storage was expensive I used to create a few 100MB of dummy files using an old command line utility which I think was called creatfil.exe. The reasoning was that if the server started running out of disk space unexpectedly, I could delete the dummy files and buy myself a little time and breathing room. Fortunately, I think we've advanced where that technique is no longer necessary.<\/p>\n<p>But, where you might want some dummy or sample files, is to simulate a user folder with a variety of files. You could use this test directory to hone your PowerShell scripts. Any you may have your own reasons for needing a bunch of sample files. So I took the original code and ran with it, as I usually do. I came up with a function called New-SampleFile.<\/p>\n<pre class=\"lang:ps decode:true \">#requires -version 4.0\r\n\r\nFunction New-SampleFile {\r\n&lt;#\r\n.SYNOPSIS\r\nCreate sample files\r\n.DESCRIPTION\r\nThis command will create sample, or dummy files of random sizes in the folder you specified.\r\n.PARAMETER Path\r\nThe folder where the files will be created. The default is the current location.\r\n.PARAMETER Filename\r\nYou can specify a filename or let the function create a random name.\r\n.PARAMETER MaximumSize\r\nThe maximum file size in bytes for the sample file. The minimum is 5 bytes.\r\n.PARAMETER Force\r\nOverwrite existing files with the same name.\r\n.PARAMETER Passthru\r\nWrite the new file to the pipeline.\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; new-samplefile -path c:\\files -filename fileA.txt\r\n\r\nCreate a random sized file called FileA.txt in C:\\files.\r\n.EXAMPLE\r\nPS C:\\&gt; (1..5).foreach({new-samplefile -path c:\\work -Filename \"file$_.txt\" -Passthru -MaximumSize 1kb -Force})\r\n\r\n\r\n    Directory: C:\\work\r\n\r\n\r\nMode                LastWriteTime     Length Name                                       \r\n----                -------------     ------ ----                                       \r\n-a---         1\/20\/2015   9:11 AM        296 file1.txt                                  \r\n-a---         1\/20\/2015   9:11 AM         22 file2.txt                                  \r\n-a---         1\/20\/2015   9:11 AM        979 file3.txt                                  \r\n-a---         1\/20\/2015   9:11 AM        320 file4.txt                                  \r\n-a---         1\/20\/2015   9:11 AM        855 file5.txt \r\n\r\nCreate 5 files, file1.txt to file5.txt under C:\\work with a maximum size of 1KB.\r\n\r\n.NOTES\r\nNAME        :  New-SampleFile\r\nVERSION     :  1.0   \r\nLAST UPDATED:  1\/20\/2015\r\nAUTHOR      :  Jeff Hicks (@JeffHicks)\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"bFLrdSRsQ0\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\">Essential PowerShell Learning Resources<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Essential PowerShell Learning Resources&#8221; &#8212; The Lonely Administrator\" src=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/embed\/#?secret=yq5WpPnaBW#?secret=bFLrdSRsQ0\" data-secret=\"bFLrdSRsQ0\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n\r\n.INPUTS\r\nNone\r\n.OUTPUTS\r\nSystem.IO.FileInfo\r\n#&gt;\r\n[cmdletbinding(SupportsShouldProcess)]\r\nParam(\r\n[Parameter(Position=0)]\r\n[string]$Path=\".\",\r\n[string]$Filename = [System.IO.Path]::GetRandomFileName(),\r\n[ValidateNotNullorEmpty()]\r\n[int]$MaximumSize = 100KB,\r\n[switch]$Force,\r\n[switch]$Passthru\r\n)\r\n\r\nWrite-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n\r\n#validate path to make sure it is valid and a FileSystem path\r\nif ((Test-Path $Path) -AND ((Resolve-Path $path).Provider.Name -eq 'FileSystem')) {\r\n\r\n    #define the output path\r\n    $Output = Join-Path -Path (Convert-Path $path) -ChildPath $Filename\r\n\r\n    #delete existing file if found and using $Force, otherwise \r\n    #the function will throw an exception\r\n    if ($Force -AND (Test-Path -Path $Output)) {\r\n        Write-Verbose \"Deleting existing file\"\r\n        Remove-Item -Path $Output\r\n    } #if $force and output file exists\r\n\r\n    #generate a random file size\r\n    $Size = Get-Random -Minimum 5 -Maximum $MaximumSize\r\n\r\n    Write-Verbose -message \"Creating $output with size $Size\"\r\n\r\n    if ($PSCmdlet.ShouldProcess($Output)) {\r\n        $stream = New-Object System.IO.FileStream($Output, [System.IO.FileMode]::CreateNew)\r\n        $stream.Seek($Size, [System.IO.SeekOrigin]::Begin) | Out-Null\r\n        $stream.WriteByte(0)\r\n        $Stream.Close()\r\n\r\n        Write-Verbose \"File created.\"\r\n\r\n        if ($Passthru) {\r\n            Get-Item -Path $Output\r\n        }\r\n    } #close should process\r\n\r\n} #if path test\r\nelse {\r\n    Write-Warning \"Could not verify $(Convert-path $Path) as a filesystem path.\"\r\n}\r\n\r\nWrite-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"  \r\n\r\n} #end New-SampleFile function<\/pre>\n<p>The function will create a randomly sized file in the specified folder. The default is the current location. As you look through the code you'll see I've added a test to verify the path and to make sure it is a FileSystem path and not something like the registry. Also by default the function will use a randomly generated file name which will be something like rcstwqyg.34e. Personally, I'm going to specify a filename. The function will create the file of a random size between 5 bytes and the value of the MaximumSize parameter, which has a default of 100KB.<\/p>\n<p>The function will not overwrite existing files unless you use \u2013Force. Nor will you see any output unless you use \u2013Passthru. Even those are common parameters, I had to write the PowerShell expressions to implement them. The same is true of \u2013WhatIf. You'll see in the cmdletbinding attribute that the function supports ShouldProcess. However, the .NET classes I'm calling have no concept of WhatIf. I had to handle that myself<\/p>\n<pre class=\"lang:ps decode:true \">if ($PSCmdlet.ShouldProcess($Output)) {\r\n    $stream = New-Object System.IO.FileStream($Output, [System.IO.FileMode]::CreateNew)\r\n    $stream.Seek($Size, [System.IO.SeekOrigin]::Begin) | Out-Null\r\n    $stream.WriteByte(0)\r\n    $Stream.Close()\r\n\r\n    Write-Verbose \"File created.\"\r\n\r\n    if ($Passthru) {\r\n        Get-Item -Path $Output\r\n    }\r\n} #close should process<\/pre>\n<p>Here's the function in action:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/012315_1741_FridayFunCr1.png\" alt=\"\" \/><\/p>\n<p>This also makes it easy to create multiple files.<\/p>\n<pre><code>1..10 | foreach { new-samplefile -Path c:\\work -Filename \"TestFile_$_.dat\" -passthru -MaximumSize 50KB}<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/012315_1741_FridayFunCr2.png\" alt=\"\" \/><\/p>\n<p>Or how about this? I want to create a variety of files with different names.<\/p>\n<pre class=\"lang:ps decode:true \">$extensions = \".txt\",\".docx\",\".xlsx\",\".pdf\",\".pptx\",\".doc\",\".png\",\".mp3\"\r\n$names = \"sales\",\"data\",\"marketing\",\"file\",\"demo\",\"test\",\"finance\",\"HR\",\"MFG\",\"project\"\r\n$path = \"C:\\SampleFiles\"\r\n1..10 | foreach {\r\n$file = \"{0}_{1}{2}\" -f (Get-Random -InputObject $names),(Get-Random -Minimum 10 -Maximum 1000),(Get-Random -InputObject $extensions)\r\nNew-SampleFile -Path $path -Filename $file -Passthru \u2013Force\r\n}<\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/012315_1741_FridayFunCr3.png\" alt=\"\" \/><\/p>\n<p>Now I have some test files I can work with<\/p>\n<p>Normally I prefer to use cmdlets wherever possible. But since there is no cmdlet from Microsoft to create dummy files, I have no problem resorting to the .NET Framework. However, I think it is still worth the time to wrap the .NET commands in a user-friendly and easy to use advanced function as I've done today.<\/p>\n<p>If you find a way to use this function, I hope you'll let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not too long ago I came across a PowerShell snippet, probably via Twitter, that showed how to use a few classes from the System.IO namespace to create dummy files. Sadly I forgot the record where I saw this first mentioned. What I liked about the code I saw was the ability to create a dummy&#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! Friday Fun: Creating Sample Files 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":[271,4],"tags":[123,97,568,534,540,485],"class_list":["post-4200","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-files","tag-filesystem","tag-friday-fun","tag-powershell","tag-scripting","tag-whatif"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: Creating Sample Files &#8226; The Lonely Administrator<\/title>\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\/4200\/friday-fun-creating-sample-files\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: Creating Sample Files &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Not too long ago I came across a PowerShell snippet, probably via Twitter, that showed how to use a few classes from the System.IO namespace to create dummy files. Sadly I forgot the record where I saw this first mentioned. What I liked about the code I saw was the ability to create a dummy...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-01-23T17:41:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-01-23T17:46:51+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: Creating Sample Files\",\"datePublished\":\"2015-01-23T17:41:22+00:00\",\"dateModified\":\"2015-01-23T17:46:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/\"},\"wordCount\":508,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/document.png\",\"keywords\":[\"Files\",\"FileSystem\",\"Friday Fun\",\"PowerShell\",\"Scripting\",\"WhatIf\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/\",\"name\":\"Friday Fun: Creating Sample Files &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/document.png\",\"datePublished\":\"2015-01-23T17:41:22+00:00\",\"dateModified\":\"2015-01-23T17:46:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#primaryimage\",\"url\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/document.png\",\"contentUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/document.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4200\\\/friday-fun-creating-sample-files\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: Creating Sample Files\"}]},{\"@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":"Friday Fun: Creating Sample Files &#8226; The Lonely Administrator","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\/4200\/friday-fun-creating-sample-files\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: Creating Sample Files &#8226; The Lonely Administrator","og_description":"Not too long ago I came across a PowerShell snippet, probably via Twitter, that showed how to use a few classes from the System.IO namespace to create dummy files. Sadly I forgot the record where I saw this first mentioned. What I liked about the code I saw was the ability to create a dummy...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-01-23T17:41:22+00:00","article_modified_time":"2015-01-23T17:46:51+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png","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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: Creating Sample Files","datePublished":"2015-01-23T17:41:22+00:00","dateModified":"2015-01-23T17:46:51+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/"},"wordCount":508,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png","keywords":["Files","FileSystem","Friday Fun","PowerShell","Scripting","WhatIf"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/","name":"Friday Fun: Creating Sample Files &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png","datePublished":"2015-01-23T17:41:22+00:00","dateModified":"2015-01-23T17:46:51+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#primaryimage","url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png","contentUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/09\/document.png"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4200\/friday-fun-creating-sample-files\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: Creating Sample Files"}]},{"@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":3579,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3579\/friday-the-13th-powershell-fun\/","url_meta":{"origin":4200,"position":0},"title":"Friday the 13th PowerShell Fun","author":"Jeffery Hicks","date":"December 13, 2013","format":false,"excerpt":"Well here are once again and another Friday the 13th. I love these days because I feel challenged to come up with 13 PowerShell related tidbits which I hope you'll find fun and maybe even a little educational. Today's collection should work primarily on PowerShell 3.0. Most items might also\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"friday13","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/12\/friday13-150x150.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2471,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/2471\/friday-fun-save-all-open-powershell-ise-files\/","url_meta":{"origin":4200,"position":1},"title":"Friday Fun: Save All Open PowerShell ISE Files","author":"Jeffery Hicks","date":"August 3, 2012","format":false,"excerpt":"Here's a little tidbit that I previously shared on Twitter and Google Plus. The PowerShell ISE obviously has a Save menu choice. But there's no menu option to save all open files. But you can add one yourself. All of the open files are part of the $psise.CurrentPowerShellTab.Files collection. Each\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4895,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4895\/friday-fun-a-sysinternals-powershell-workflow\/","url_meta":{"origin":4200,"position":2},"title":"Friday Fun: A SysInternals PowerShell Workflow","author":"Jeffery Hicks","date":"February 12, 2016","format":false,"excerpt":"Over the years I've come up with a number of PowerShell tools to download the SysInternals tools to my desktop. And yes, I know that with PowerShell 5 and PowerShellGet I could download and install a SysInternals package. But that assumes the package is current.\u00a0 But that's not really the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2330,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2330\/friday-fun-get-latest-powershell-scripts\/","url_meta":{"origin":4200,"position":3},"title":"Friday Fun: Get Latest PowerShell Scripts","author":"Jeffery Hicks","date":"May 18, 2012","format":false,"excerpt":"Probably like many of you I keep almost all of my scripts in a single location. I'm also usually working on multiple items at the same time. Some times I have difficult remembering the name of a script I might have been working on a few days ago that I\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\/2012\/05\/get-latestscript-300x133.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2673,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2673\/friday-fun-edit-recent-file\/","url_meta":{"origin":4200,"position":4},"title":"Friday Fun: Edit Recent File","author":"Jeffery Hicks","date":"January 4, 2013","format":false,"excerpt":"As you might imagine I work on a lot of PowerShell projects at the same time. Sometimes I'll start something at the beginning of the week and then need to come back to it at the end of the week. The problem is that I can't always remembered what I\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"Edit-RecentFile","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/Edit-RecentFile-300x209.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4169,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4169\/friday-fun-updated-ise-scripting-geek-module\/","url_meta":{"origin":4200,"position":5},"title":"Friday Fun: Updated ISE Scripting Geek Module","author":"Jeffery Hicks","date":"January 9, 2015","format":false,"excerpt":"A few years ago I published a module with a number of functions and enhancements for the PowerShell ISE. This ISEScriptingGeek module has remained popular over the last few years. But I wrote it for PowerShell v2. I have also come up with a number of new additions to the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"geek","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/geek-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4200","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=4200"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4200\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}