{"id":4445,"date":"2015-07-13T10:45:37","date_gmt":"2015-07-13T14:45:37","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4445"},"modified":"2015-07-13T10:45:37","modified_gmt":"2015-07-13T14:45:37","slug":"simulating-a-powershell-demo","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/","title":{"rendered":"Simulating a PowerShell Demo"},"content":{"rendered":"<p>A number of years ago I <a href=\"http:\/\/jdhitsolutions.com\/blog\/scripting\/1473\/friday-fun-start-typeddemo-v2\" target=\"_blank\">published my version<\/a> of a Start-Demo script. In my version, I can create a text file with all of the commands I want to run. It might look like this:<\/p>\n<pre class=\"lang:batch decode:true \" >Get-Date\r\nget-ciminstance win32_logicaldisk | select DeviceID,Size,Freespace\r\n::\r\nget-service |\r\nwhere {$_.status -eq 'running'} |\r\nSelect Name,Status |\r\nFormat-Table -autosize\r\n::\r\nGet-eventlog -list -computername chi-dc04<\/pre>\n<p>The :: indicate the beginning and end of a multi-line command. This will simulate the >> nested prompt. My function reads this file and \"types\" it out so that it looks like you are typing it. You can control the speed and even introduce typos if you are so inclined. I used this a lot in my Pluralsight courses since I can't seem to talk and type at the same time. <\/p>\n<p>I was asked about this function so I dusted it off and made a few minor changes. The main change is that you can specify what PowerShell version to display if you want to simulate starting a brand new PowerShell session. The default is your current version.<\/p>\n<p>Here's the updated function.<\/p>\n<pre class=\"lang:ps decode:true \" >Function Start-TypedDemo {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nSimulate a PowerShell session\r\n.DESCRIPTION\r\nThis command simulates an interactive PowerShell session. It will process a text file of PowerShell commands. The function will insert your prompt and \"type\" out each command when you press any key. At the end of the typed command or whenever a pipe character is inserted, the script will pause. Press Enter or any key to continue. \r\nIf it is the end of the command pressing Enter will execute the command. Use the -NoExecute parameter to run through the demo without executing any commands. Commented lines will be skipped. Press 'q' or ESC at any pause to quit the demo.\r\n\r\nThis function will NOT run properly in the ISE.\r\n\r\nVARIABLE NAMES\r\nDo not use any variables in your script file that are also used in this script. These are the variables you most likely need to avoid:\r\n\r\n $file\r\n $i\r\n $running\r\n $key\r\n $command\r\n $count\r\n\r\nMULITLINE COMMANDS\r\nTo use a multiline command, in your demo file, put a :: before the first line and :: after the last line:\r\n\r\n\r\nGet-Date\r\n::\r\nget-wmiobject win32_logicaldisk -filter \"Drivetype=3\" | \r\nSelect Caption,VolumeName,Size,Freespace | \r\nformat-table -autosize\r\n::\r\nGet-Process\r\n\r\n\r\nThe function will simulate a nested prompt. Press any key after the last &gt;&gt; to execute. Avoid using the line continuation character.\r\n\r\nTIMING\r\nBy default the function will insert a random pause interval between characters. This is a random value in milliseconds between the -RandomMinimum and -RandomMaximum parameters which have default values of 50 and 140 respectively. \r\nIf you want a static or consisent interval, then use the -Pause parameter. The recommended value is 80.\r\n\r\nTYPOS\r\nThe -IncludeTypo parameter will introduce a typo at random intervals, then backspace over it and insert the correct text. You should not use this parameter with the -Transcript parameter. The transcript will have control characters for every backspace. \r\n\r\nIt is not recommended to use -IncludeTypo when running any sort of transcript.\r\n\r\nSCOPE\r\nAll the commands in your demo script are executed in the context of the Start-TypedDemo function. This means you have to be very aware of scope. While you can access items in the global scope like PSDrives, anything you create in the demo script will not persist. This also means that none of the commands in your demo script will show up in PowerShell history.\r\n\r\nCOMMENTS\r\nAny line that begins with # will be treated as a comment and skipped. If you have a multi-line comment you will need to put a # at the begininng of each line. You can't use PowerShell's block comment characters.\r\n\r\n\r\n.PARAMETER File\r\nThe file name of PowerShell commands to execute\r\n.PARAMETER RandomMinimum\r\nThe minimum time interval between characters in milliseconds. The default is 50.\r\n.PARAMETER RandomMaximum\r\nThe maximum time interval between characters in milliseconds. The default is 140.\r\n.PARAMETER IncludeTypo\r\nWhen specified, the function will simulate typing mistakes. It is not recommended to use this parameter with -Transcript.\r\n.PARAMETER Pause\r\nThe typing speed interval between characters in milliseconds. The recommended value is 100.\r\n.PARAMETER Transcript\r\nThe file name and path for a transcript session file. Existing files will be overwritten. It is not recommended to use this parameter with -IncludeTypo.\r\n.PARAMETER NoExecute\r\nDo not execute any of the commands. \r\n.PARAMETER NewSession\r\nSimulate a new PowerShell session with the copyright header and a prompt. This works best if you start your demo from the C: drive.\r\n.PARAMETER PSVersion\r\nUse this to when simulating a new PowerShell session to depict a specific PowerShell version\r\n\r\n. The default is your current version.\r\n.EXAMPLE\r\nPS C:\\&gt; Start-TypedDemo c:\\work\\demo.txt\r\nRun the commands in c:\\work\\demo.txt using the random defaults\r\n.EXAMPLE\r\nPS C:\\&gt; Start-TypedDemo c:\\work\\demo.txt -pause 100 -NoExecute\r\nRun the commands in c:\\work\\demo.txt using a static interval of 100 milliseconds. The function will only type the commands. They will not be executed.\r\n.EXAMPLE\r\nPS C:\\&gt; Start-TypedDemo c:\\work\\demo.txt -transcript c:\\work\\demotrans.txt\r\nRun the commands in c:\\work\\demo.txt using the random defaults and create a transcript file.\r\n.NOTES\r\nNAME        :  Start-TypedDemo\r\nVERSION     :  5.0\r\nLAST UPDATED:  7\/13\/2015\r\nAUTHOR      :  Jeffery Hicks\r\n\r\nThis function was first published at http:\/\/jdhitsolutions.com\/blog\/scripting\/1473\/friday-fun-start-typeddemo-v2\/\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"7bYjX8r0w3\"><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=3nURDpOktu#?secret=7bYjX8r0w3\" data-secret=\"7bYjX8r0w3\" 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.LINK\r\nWrite-Host \r\nInvoke-Command\r\nStart-Sleep\r\nGet-Random \r\n.INPUTS\r\nNone\r\n.OUTPUTS\r\nNone. This only writes to the host console, not the pipeline.\r\n#&gt;\r\n\r\n[cmdletBinding(DefaultParameterSetName=\"Random\")]\r\n\r\nParam(\r\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter the name of a text file with your demo commands\")]\r\n[ValidateScript({Test-Path $_})]\r\n[string]$File,\r\n[ValidateScript({$_ -gt 0})]\r\n[Parameter(ParameterSetName=\"Static\")]\r\n[int]$Pause=80,\r\n[Parameter(ParameterSetName=\"Random\")]\r\n[ValidateScript({$_ -gt 0})]\r\n[int]$RandomMinimum=50,\r\n[Parameter(ParameterSetName=\"Random\")]\r\n[ValidateScript({$_ -gt 0})]\r\n[int]$RandomMaximum=140,\r\n[Parameter(ParameterSetName=\"Random\")]\r\n[switch]$IncludeTypo,\r\n[string]$Transcript,\r\n[switch]$NoExecute,\r\n[switch]$NewSession,\r\n[ValidateSet(2,3,4,5)]\r\n[Int]$PSVersion = $PSVersionTable.PsVersion.MajorVersion\r\n)\r\n\r\n#this is an internal function so I'm not worried about the name\r\nFunction PauseIt {\r\n[cmdletbinding()]\r\nParam()\r\n    Write-Verbose \"PauseIt\"\r\n\r\n    #wait for a key press\r\n    $Running=$true\r\n    #keep looping until a key is pressed\r\n    While ($Running)  {\r\n     if ($host.ui.RawUi.KeyAvailable) {\r\n     $key = $host.ui.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\")\r\n        if ($key) {\r\n         $Running=$False  \r\n         #check the value and if it is q or ESC, then bail out\r\n         if ($key -match \"q|27\") {\r\n           Write-Host \"`r\"\r\n           Return \"quit\"\r\n           } #if match q|27\r\n        } #if $key\r\n      } #if key available\r\n      Start-Sleep -millisecond 100\r\n    } #end While\r\n} #PauseIt function\r\n\r\n#abort if running in the ISE\r\nif ($host.name -match \"PowerShell ISE\") {\r\n    Write-Warning \"This will not work in the ISE. Use the PowerShell console host.\"\r\n    Return\r\n}\r\n\r\nClear-Host\r\n\r\nif ($NewSession) {\r\n#simulate a new v3 session\r\n#define a set of coordinates\r\n$z= new-object System.Management.Automation.Host.Coordinates 0,0\r\nSwitch ($PSVersion) {\r\n2 {$year = 2009}\r\n3 {$year = 2012}\r\n4 {$year = 2013}\r\n5 {$year = 2015}\r\n\r\n}\r\n\r\n\r\n$header=@\"\r\nWindows PowerShell\r\nCopyright (C) $YEAR Microsoft Corporation. All rights reserved.\r\n`r\r\n\"@\r\n\r\n    Write-Host $header\r\n} #if new session\r\n\r\n#Start a transcript if requested\r\n$RunningTranscript=$False\r\n\r\nif ($Transcript)\r\n{\r\n    Try \r\n    {\r\n        Start-Transcript -Path $Transcript -ErrorAction Stop | Out-Null\r\n        $RunningTranscript=$True\r\n    }\r\n    Catch\r\n    {\r\n        Write-Warning \"Could not start a transcript. One may already be running.\"\r\n    }\r\n}\r\n#strip out all comments and blank lines\r\nWrite-Verbose \"Getting commands from $file\"\r\n\r\n$commands = Get-Content -Path $file | Where {$_ -notmatch \"#\" -AND $_ -match \"\\w|::|{|}|\\(|\\)\"}\r\n\r\n$count=0\r\n\r\n#write a prompt using your current prompt function\r\nWrite-Verbose \"prompt\"\r\nWrite-Host $(prompt) -NoNewline\r\n\r\n$NoMultiLine=$True \r\n$StartMulti=$False\r\n\r\n#define a scriptblock to get typing interval\r\nWrite-Verbose \"Defining interval scriptblock\"\r\n$interval={\r\n if ($pscmdlet.ParameterSetName -eq \"Random\")\r\n     {\r\n        #get a random pause interval\r\n        Get-Random -Minimum $RandomMinimum -Maximum $RandomMaximum\r\n     }\r\n     else \r\n     {\r\n        #use the static pause value\r\n        $Pause\r\n     }\r\n} #end Interval scriptblock \r\n\r\n#typo scriptblock\r\nWrite-Verbose \"Defining typo scriptblock\"\r\n$Typo={\r\n   #an array of characters to use for typos\r\n        $matrix=\"a\",\"s\",\"d\",\"f\",\"x\",\"q\",\"w\",\"e\",\"r\",\"z\",\"j\",\"t\",\"x\",\"c\",\"v\",\"b\"\r\n        #Insert a random bad character\r\n        Write-host \"$($matrix | .\\Get-RandomPassword.ps1) \" -nonewline\r\n        Start-Sleep -Milliseconds 500\r\n        #simulate backspace \r\n        Write-host `b -NoNewline\r\n        start-sleep -Milliseconds 300       \r\n        Write-host `b -NoNewline\r\n        start-sleep -Milliseconds 200       \r\n        Write-Host $command[$i] -NoNewline \r\n } #end Typo Scriptblock\r\n\r\nWrite-Verbose \"Defining PipeCheck Scriptblock\"\r\n#define a scriptblock to pause at a | character in case an explanation is needed\r\n$PipeCheck={\r\n     if ($command[$i] -eq \"|\") {\r\n        If ((PauseIt) -eq \"quit\") {Return}\r\n     }\r\n} #end PipeCheck scriptblock\r\n\r\nWrite-Verbose \"Processing commands\"\r\nforeach ($command in $commands) {\r\n   #trim off any spaces\r\n   $command=$command.Trim()\r\n  \r\n   $count++\r\n   #pause until a key is pressed which will then process the next command\r\n   if ($NoMultiLine) {\r\n    If ((PauseIt) -eq \"quit\") {Return}\r\n   }\r\n   \r\n#SINGLE LINE COMMAND\r\n    if ($command -ne \"::\" -AND $NoMultiLine) {  \r\n      Write-Verbose \"single line command\"          \r\n      for ($i=0;$i -lt $command.length;$i++) {\r\n     \r\n     #simulate errors if -IncludeTypo\r\n     if ($IncludeTypo -AND ($(&amp;$Interval) -ge ($RandomMaximum-5)))\r\n     { &amp;$Typo } #if includetypo\r\n     else\r\n     { #write the character\r\n        Write-Verbose \"Writing character $($command[$i])\"\r\n        Write-Host $command[$i] -NoNewline\r\n     }\r\n     #insert a pause to simulate typing\r\n     Start-sleep -Milliseconds $(&amp;$Interval)\r\n     \r\n     &amp;$PipeCheck\r\n     \r\n    }\r\n    \r\n     #remove the backtick line continuation character if found\r\n   if ($command.contains('`')) {\r\n     $command=$command.Replace('`',\"\")\r\n   }\r\n    \r\n    #Pause until ready to run the command \r\n    If ((PauseIt) -eq \"quit\") {Return}\r\n    Write-host \"`r\"\r\n    #execute the command unless -NoExecute was specified\r\n    if (-NOT $NoExecute) {\r\n        Invoke-Expression $command | Out-Default\r\n\r\n    }\r\n    else {\r\n        Write-Host $command -ForegroundColor Cyan\r\n    }\r\n   } #IF SINGLE COMMAND\r\n#START MULTILINE  \r\n    #skip the ::     \r\n    elseif ($command -eq \"::\" -AND $NoMultiLine) {\r\n     $NoMultiLine=$False\r\n     $StartMulti=$True\r\n     #define a variable to hold the multiline expression\r\n     [string]$multi=\"\"\r\n  } #elseif\r\n#FIRST LINE OF MULTILINE\r\n    elseif ($StartMulti) {\r\n       for ($i=0;$i -lt $command.length;$i++) {\r\n        if ($IncludeTypo -AND ($(&amp;$Interval) -ge ($RandomMaximum-5)))\r\n        { &amp;$Typo } \r\n        else   { write-host $command[$i] -NoNewline} #else\r\n        start-sleep -Milliseconds $(&amp;$Interval)\r\n        #only check for a pipe if we're not at the last character\r\n        #because we're going to pause anyway\r\n        if ($i -lt $command.length-1) {\r\n            &amp;$PipeCheck\r\n        }\r\n        } #for\r\n    \r\n        $StartMulti=$False\r\n       \r\n         #remove the backtick line continuation character if found\r\n        if ($command.contains('`')) {\r\n         $command=$command.Replace('`',\"\")\r\n        }\r\n        #add the command to the multiline variable\r\n        $multi+=\" $command\"\r\n    #     if (!$command.Endswith('{')) { $multi += \";\" }\r\n     if ($command -notmatch \",$|{$|}$|\\|$|\\($\") { $multi += \" ; \" }\r\n        If ((PauseIt) -eq \"quit\") {Return}\r\n        \r\n    } #elseif\r\n#END OF MULTILINE\r\n  elseif ($command -eq \"::\" -AND !$NoMultiLine) {\r\n     Write-host \"`r\"\r\n     Write-Host \"&gt;&gt; \" -NoNewline\r\n     $NoMultiLine=$True\r\n      If ((PauseIt) -eq \"quit\") {Return}\r\n     #execute the command unless -NoExecute was specified\r\n    Write-Host \"`r\"\r\n    if (-NOT $NoExecute) {\r\n     Invoke-Expression $multi | Out-Default\r\n    }\r\n    else {\r\n        Write-Host $multi -ForegroundColor Cyan\r\n    }\r\n  }  #elseif end of multiline\r\n#NESTED PROMPTS\r\n else {\r\n    Write-Host \"`r\"\r\n    Write-Host \"&gt;&gt; \" -NoNewLine\r\n    If ((PauseIt) -eq \"quit\") {Return}\r\n    for ($i=0;$i -lt $command.length;$i++) {\r\n      if ($IncludeTypo -AND ($(&amp;$Interval) -ge ($RandomMaximum-5)))\r\n      { &amp;$Typo  } \r\n      else { Write-Host $command[$i] -NoNewline }\r\n      Start-Sleep -Milliseconds $(&amp;$Interval)\r\n      &amp;$PipeCheck\r\n    } #for\r\n   \r\n     #remove the backtick line continuation character if found\r\n     if ($command.contains('`')) {\r\n         $command=$command.Replace('`',\"\")\r\n     }\r\n    #add the command to the multiline variable and include the line break \r\n    #character \r\n    $multi+=\" $command\"\r\n  #  if (!$command.Endswith('{')) { $multi += \";\" }  \r\n    \r\n   if ($command -notmatch \",$|{$|\\|$|\\($\") {\r\n      $multi+=\" ; \"\r\n      #$command\r\n    }\r\n      \r\n   } #else nested prompts  \r\n   \r\n   #reset the prompt unless we've just done the last command\r\n   if (($count -lt $commands.count) -AND ($NoMultiLine)) {\r\n    Write-Host $(prompt) -NoNewline \r\n   } \r\n    \r\n  } #foreach  \r\n  \r\n  #stop a transcript if it is running\r\n  if ($RunningTranscript)\r\n  {\r\n    #stop this transcript if it is running\r\n    Stop-Transcript | Out-Null\r\n  }\r\n  \r\n} #function\r\n\r\n#uncomment if you want to use the alias\r\n#Set-Alias -Name std -Value Start-TypedDemo\r\n<\/pre>\n<p>Have fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A number of years ago I published my version of a Start-Demo script. In my version, I can create a text file with all of the commands I want to run. It might look like this: Get-Date get-ciminstance win32_logicaldisk | select DeviceID,Size,Freespace :: get-service | where {$_.status -eq &#8216;running&#8217;} | Select Name,Status | Format-Table -autosize&#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":"Simulating a #PowerShell Demo Updated","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,8],"tags":[265,534,540],"class_list":["post-4445","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-demo","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>Simulating a PowerShell Demo &#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\/4445\/simulating-a-powershell-demo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simulating a PowerShell Demo &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"A number of years ago I published my version of a Start-Demo script. In my version, I can create a text file with all of the commands I want to run. It might look like this: Get-Date get-ciminstance win32_logicaldisk | select DeviceID,Size,Freespace :: get-service | where {$_.status -eq &#039;running&#039;} | Select Name,Status | Format-Table -autosize...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-13T14:45:37+00:00\" \/>\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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Simulating a PowerShell Demo\",\"datePublished\":\"2015-07-13T14:45:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/\"},\"wordCount\":164,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Demo\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/\",\"name\":\"Simulating a PowerShell Demo &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2015-07-13T14:45:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4445\\\/simulating-a-powershell-demo\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Simulating a PowerShell Demo\"}]},{\"@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":"Simulating a PowerShell Demo &#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\/4445\/simulating-a-powershell-demo\/","og_locale":"en_US","og_type":"article","og_title":"Simulating a PowerShell Demo &#8226; The Lonely Administrator","og_description":"A number of years ago I published my version of a Start-Demo script. In my version, I can create a text file with all of the commands I want to run. It might look like this: Get-Date get-ciminstance win32_logicaldisk | select DeviceID,Size,Freespace :: get-service | where {$_.status -eq 'running'} | Select Name,Status | Format-Table -autosize...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-07-13T14:45:37+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Simulating a PowerShell Demo","datePublished":"2015-07-13T14:45:37+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/"},"wordCount":164,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Demo","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/","name":"Simulating a PowerShell Demo &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2015-07-13T14:45:37+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4445\/simulating-a-powershell-demo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Simulating a PowerShell Demo"}]},{"@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":1247,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1247\/techmentor-orlando-2011-decks-and-demos\/","url_meta":{"origin":4445,"position":0},"title":"Techmentor Orlando 2011 Decks and Demos","author":"Jeffery Hicks","date":"March 21, 2011","format":false,"excerpt":"As promised, I have put together the most current versions of my slide decks and demos. A word of caution on the demos: many of them were designed to be used with my Start-Demo function, which essentially steps through the demo file one line at a time. The AD demos\u2026","rel":"","context":"In &quot;Active Directory&quot;","block_context":{"text":"Active Directory","link":"https:\/\/jdhitsolutions.com\/blog\/category\/active-directory\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/03\/TM_2011spring.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1404,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1404\/start-typeddemo\/","url_meta":{"origin":4445,"position":1},"title":"Start-TypedDemo","author":"Jeffery Hicks","date":"May 3, 2011","format":false,"excerpt":"As you know, I do a lot of presenting and training. Normally I use the ubiquitous Start-Demo function to run through a demo list of commands. Most of this time this works just fine. But when I'm doing videos, especially for a video project, I want the viewer to focus\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":"","width":0,"height":0},"classes":[]},{"id":1220,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1220\/friday-fun-virtual-demos\/","url_meta":{"origin":4445,"position":2},"title":"Friday Fun Virtual Demos","author":"Jeffery Hicks","date":"March 11, 2011","format":false,"excerpt":"I've been prepping my demo scripts for Techmentor using the ubiquitous Start-Demo, and realized I could take things further. I mean, why do I have to do all the talking? Windows 7 has a terrific text to speech engine so why not take advantage of it. With a little work\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3361,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3361\/creating-styling-html-reports-with-powershell\/","url_meta":{"origin":4445,"position":3},"title":"Creating Styling HTML Reports with PowerShell","author":"Jeffery Hicks","date":"August 26, 2013","format":false,"excerpt":"Last month I did an updated version of my presentation on creating styling HTML reports in Windows PowerShell. This presentation was for the PowerShell virtual chapter of SQL PASS. As such, I came up with some SQL related demonstrations and fine tuned some demos from earlier presentations. You can download\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":2306,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2306\/powershell-scripting-with-validatenotnullorempty\/","url_meta":{"origin":4445,"position":4},"title":"PowerShell Scripting with [ValidateNotNullorEmpty]","author":"Jeffery Hicks","date":"May 15, 2012","format":false,"excerpt":"I've been writing about the different parameter validation attributes that you can use in your PowerShell scripting. One that I use in practically every script is [ValidateNotNullorEmpty()]. This validation will ensure that something is passed as a parameter value. I'm not talking about making a parameter mandatory; only that if\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\/2012\/05\/validatenotnullorempty-300x141.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":672,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/672\/teched-2010-demos\/","url_meta":{"origin":4445,"position":5},"title":"TechEd 2010 Demos","author":"Jeffery Hicks","date":"June 10, 2010","format":false,"excerpt":"As promised,\u00a0 I've assembled my demo scripts as well as the transcriptfrom my TechEd 2010 talk Paradigm Shift Microsoft Visual Basic Scripting Edition to Windows PowerShell. The official slide deck is supposed to be available on the TechEd web site.\u00a0 I'm going to post an expanded version of the deck\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4445","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=4445"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4445\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}