{"id":8526,"date":"2021-08-19T11:53:05","date_gmt":"2021-08-19T15:53:05","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8526"},"modified":"2021-08-19T11:53:08","modified_gmt":"2021-08-19T15:53:08","slug":"doing-more-with-myinvocation","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/","title":{"rendered":"Doing More with $MyInvocation"},"content":{"rendered":"\n<p>Not that long ago someone made a comment to me on Twitter about something I had shared related to PowerShell. He wanted to know more about the $MyInvocation variable. This is something that isn't well documented, yet can be very useful in your PowerShell scripting. Let's take a look at it in a bit more detail.<\/p>\n\n\n\n<p>The $MyInvocation variable is automatically created when you run a PowerShell script or function. Technically, it is a System.Management.Automation.InvocationInfo object. You can find Microsoft's documentation <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/system.management.automation.invocationinfo?view=powershellsdk-1.1.0\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. But let's explore this from a practical perspective.<\/p>\n\n\n\n<p>Here's a simple demonstration function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Get-Foo {\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory)]\n        [string]$Name,\n        [datetime]$Since = (Get-Date).AddHours(-24)\n        )\n\n        $MyInvocation\n\n        Write-Host \"Getting $name since $since\" -fore yellow\n}<\/code><\/pre>\n\n\n\n<p>To get the most from $MyInvocation, I have found it is best to dot source your script file or import the module, into your PowerShell session. This function doesn't do anything other than show $MyInvocation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"682\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.png\" alt=\"\" class=\"wp-image-8527\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-300x200.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-768x511.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-850x566.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation.png 1262w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Even though this is a rich object, there are probably only a handful of properties you will find useful in your PowerShell scripting. I use the MyCommand property all the time. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MyInvocation.Mycommand<\/h2>\n\n\n\n<p>Here's another version of the demo function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Get-Foo {\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory)]\n        [string]$Name, [\n        datetime]$Since = (Get-Date).AddHours(-24)\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Name\"\n\n        #create a global copy for testing purposes\n        $global:mi = $myinvocation\n\n        Write-Host \"Getting $name since $since\" -fore yellow\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}<\/code><\/pre>\n\n\n\n<p>This is the format of almost all of my PowerShell functions. The Begin and End script blocks have Verbose statements that reflect the command name. I like this approach because if I change the function name, I don't have to modify any other code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"894\" height=\"172\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2.png\" alt=\"\" class=\"wp-image-8528\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2.png 894w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2-300x58.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2-768x148.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation2-850x164.png 850w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/a><\/figure>\n\n\n\n<p>Where this is truly useful is when I have functions calling other functions. These verbose statements make it easier to track the flow.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Get-Foo {\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory)]\n        [string]$Name, [\n        datetime]$Since = (Get-Date).AddHours(-24)\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Name\"\n\n        #create a global copy for testing purposes\n        $global:mi = $myinvocation\n\n        Write-Host \"Getting $name since $since\" -fore yellow\n        If (Test-Foo $name) {\n            $name\n        }\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}\n\nFunction Test-Foo {\n    [cmdletbinding()]\n    Param([string]$Name)\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Testing $name\"\n        $True\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n\n    } #end\n}\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"893\" height=\"344\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3.png\" alt=\"\" class=\"wp-image-8530\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3.png 893w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3-300x116.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3-768x296.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation3-850x327.png 850w\" sizes=\"auto, (max-width: 893px) 100vw, 893px\" \/><\/a><\/figure>\n\n\n\n<p>The verbose output now shows when I am in one command, starting another, and returning to the original command. I have found this technique to be invaluable over the years.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Scripts<\/h2>\n\n\n\n<p>You can also use $MyInvocation with scripts.<\/p>\n\n\n\n<pre title=\"Something.ps1\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">#requires -version 5.1\n\nParam(\n    [Parameter(Position = 0, Mandatory)]\n    [string]$Name,\n    [datetime]$Since = (Get-Date).AddHours(-24)\n)\nwrite-host \"Starting $(Resolve-Path $myinvocation.InvocationName)\" -ForegroundColor green\nwrite-host \"PSScriptroot is $PSScriptRoot\" -ForegroundColor green\n#create a global copy for testing purposes\n$global:mi = $MyInvocation\n\nWrite-Host \"Getting $name since $since\" -fore yellow\nwrite-host \"Ending $($myinvocation.mycommand)\" -ForegroundColor green\n\nthrow \"I failed\"<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"402\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation4.png\" alt=\"\" class=\"wp-image-8531\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation4.png 787w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation4-300x153.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation4-768x392.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/a><\/figure>\n\n\n\n<p>I can capture the script name from $MyInvocation. I'm taking things a step further by using Resolve-Path to convert any PSDrives or relative paths to a full filesystem path. $PSScriptRoot reflects the location of the current command. But here is where things get interesting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">InvocationInfo<\/h2>\n\n\n\n<p>My demo script intentionally threw an exception. Let's look at it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1007\" height=\"739\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo.png\" alt=\"\" class=\"wp-image-8532\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo.png 1007w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo-300x220.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo-768x564.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo-850x624.png 850w\" sizes=\"auto, (max-width: 1007px) 100vw, 1007px\" \/><\/a><\/figure>\n\n\n\n<p>This is the same type of object, but the properties get populated differently. Here I can see where the error occurred, on line 16. In fact, I even see the line text. This has possibilities.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Invoking Debugging<\/h2>\n\n\n\n<p>You can get the same result using functions. In fact, even better when you dot source the ps1 file with your function. This is the InvocationInfo from an exception object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"588\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2-1024x588.png\" alt=\"\" class=\"wp-image-8533\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2-1024x588.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2-300x172.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2-768x441.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2-850x488.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/invocationinfo2.png 1216w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This doesn't tell me what function I ran, but it does show the command I was trying to run inside the function that failed, the line number and the source file!<\/p>\n\n\n\n<p>With this information, I can add code to my script to edit the source file and jump right to the offending line. If you are still using the PowerShell ISE, you can automate it using the $PSISE object model. However, the PowerShell ISE is an editor and you can't get it to automatically run scripts. Instead, I have a helper function to create a temporary file with the required bits of information.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function New-ISETemp {\n    [cmdletbinding()]\n    [Outputtype(\"System.IO.FileInfo\")]\n    Param([string]$FilePath, [int]$LineNumber)\n\n    $content = @\"\n#Press F5 to Run This Script\n\n`$f = `$psise.CurrentPowerShellTab.files.add(\"$FilePath\")\n`$psise.CurrentFile.Editor.Focus()\n`$LineNumber = $LineNumber\n`$f.Editor.SetCaretPosition(`$LineNumber,1)\n`$f.editor.SelectCaretLine()\n\"@\n\n    $tmp = [system.io.path]::GetTempFileName() -replace \"\\.tmp$\", \".ps1\"\n    $content | Out-File -FilePath $tmp\n\n    #write the temp file as the function output\n    $tmp\n}<\/code><\/pre>\n\n\n\n<p>In my function, I have code to open the temp file in the PowerShell ISE when using -Debug with my function.<\/p>\n\n\n\n<pre title=\"Debug with PowerShell ISE\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">\nFunction Get-Foo2 {\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory)]\n        [string]$Name, [\n        datetime]$Since = (Get-Date).AddHours(-24)\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Name\"\n        #create a global copy of myinvocation for testing purposes\n        $global:mi = $myinvocation\n        Write-Host \"Getting $name since $since\" -fore yellow\n\n        Try {\n            Get-Service $name -ErrorAction Stop\n        }\n        Catch {\n            Write-Warning $_.exception.message\n            write-Warning $DebugPreference\n            #export for testing purposes\n            $_.invocationInfo | Export-Clixml d:\\temp\\demo-error.xml\n            if ($DebugPreference -match 'continue|inquire') {\n                $src = $_.invocationInfo.PSCommandPath\n                $line = $_.invocationInfo.ScriptLineNumber\n                Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Debugging line $line\"\n                $f = New-ISETemp -filepath $src -linenumber $line\n                powershell_ise $f\n            }\n        }\n\n    } #process\n\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise.png\"><img loading=\"lazy\" decoding=\"async\" width=\"959\" height=\"335\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise.png\" alt=\"\" class=\"wp-image-8534\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise.png 959w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise-300x105.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise-768x268.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise-850x297.png 850w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/a><\/figure>\n\n\n\n<p>The PowerShell ISE is started with my temp file loaded.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"247\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2-1024x247.png\" alt=\"\" class=\"wp-image-8535\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2-1024x247.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2-300x72.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2-768x185.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2-850x205.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise2.png 1405w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>All I need to do is press F5 and the source file is loaded and the offending line selected.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"510\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3.png\" alt=\"\" class=\"wp-image-8536\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3.png 960w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3-300x159.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3-768x408.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-ise3-850x452.png 850w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Invoke Debugging with VS Code<\/h2>\n\n\n\n<p>If you use VS Code as your editor, this is even easier. Here's the VSCode version of my function.<\/p>\n\n\n\n<pre title=\"Debug with VSCode\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">\nFunction Get-Foo2 {\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory)]\n        [string]$Name, [\n        datetime]$Since = (Get-Date).AddHours(-24)\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Name\"\n        #create a global copy of myinvocation for testing purposes\n        $global:mi = $myinvocation\n        Write-Host \"Getting $name since $since\" -fore yellow\n\n        Try {\n            Get-Service $name -ErrorAction Stop\n        }\n        Catch {\n            Write-Warning $_.exception.message\n            write-Warning $DebugPreference\n            #export for testing purposes\n            $_.invocationInfo | Export-Clixml d:\\temp\\demo-error.xml\n            if ($DebugPreference -match 'continue|inquire') {\n                $src = $_.invocationInfo.PSCommandPath\n                $line = $_.invocationInfo.ScriptLineNumber\n                $goto = \"{0}:{1}\" -f $src, $line\n                Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Debugging $goto\"\n                #launch VS Code and jump to the line\n                code.cmd --goto $goto             \n            }\n        } #catch\n    } #process\n\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}<\/code><\/pre>\n\n\n\n<p>Now when I run the function with -Debug, VS Code loads the file and jumps directly to the line.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode.png\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"510\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode.png\" alt=\"\" class=\"wp-image-8539\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode.png 960w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode-300x159.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode-768x408.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-debug-vscode-850x452.png 850w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>You may not need to incorporate this kind of recursive debugging in your code. But I think it demonstrates how you might take advantage of different properties of an InvocationInfo object. If you've come up with a useful way, I'd love to hear about it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not that long ago someone made a comment to me on Twitter about something I had shared related to PowerShell. He wanted to know more about the $MyInvocation variable. This is something that isn&#8217;t well documented, yet can be very useful in your PowerShell scripting. Let&#8217;s take a look at it in a bit more&#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: Doing More with $MyInvocation and #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":[534,540],"class_list":["post-8526","post","type-post","status-publish","format-standard","hentry","category-powershell","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>Doing More with $MyInvocation &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.\" \/>\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\/8526\/doing-more-with-myinvocation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Doing More with $MyInvocation &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-19T15:53:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-19T15:53:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Doing More with $MyInvocation\",\"datePublished\":\"2021-08-19T15:53:05+00:00\",\"dateModified\":\"2021-08-19T15:53:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/\"},\"wordCount\":661,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/myinvocation-1024x682.png\",\"keywords\":[\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/\",\"name\":\"Doing More with $MyInvocation &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/myinvocation-1024x682.png\",\"datePublished\":\"2021-08-19T15:53:05+00:00\",\"dateModified\":\"2021-08-19T15:53:08+00:00\",\"description\":\"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/myinvocation.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/myinvocation.png\",\"width\":1262,\"height\":840},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8526\\\/doing-more-with-myinvocation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Doing More with $MyInvocation\"}]},{\"@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":"Doing More with $MyInvocation &#8226; The Lonely Administrator","description":"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.","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\/8526\/doing-more-with-myinvocation\/","og_locale":"en_US","og_type":"article","og_title":"Doing More with $MyInvocation &#8226; The Lonely Administrator","og_description":"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/","og_site_name":"The Lonely Administrator","article_published_time":"2021-08-19T15:53:05+00:00","article_modified_time":"2021-08-19T15:53:08+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Doing More with $MyInvocation","datePublished":"2021-08-19T15:53:05+00:00","dateModified":"2021-08-19T15:53:08+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/"},"wordCount":661,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.png","keywords":["PowerShell","Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/","name":"Doing More with $MyInvocation &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation-1024x682.png","datePublished":"2021-08-19T15:53:05+00:00","dateModified":"2021-08-19T15:53:08+00:00","description":"Here are some ways I take advantage of the built-in $MyInvocation variable in my PowerShell scripting.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/myinvocation.png","width":1262,"height":840},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8526\/doing-more-with-myinvocation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Doing More with $MyInvocation"}]},{"@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":1423,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","url_meta":{"origin":8526,"position":0},"title":"Warning Signs","author":"Jeffery Hicks","date":"May 11, 2011","format":false,"excerpt":"I was working on a project with an advanced PowerShell function. One of the goals was to take advantage of the common parameters like -ErrorVariable and -WarningVariable so that when you run the function you can save errors and warnings and work with them later. Turns out one of these\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\/05\/warningvariable-300x184.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4707,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4707\/a-better-powershell-more\/","url_meta":{"origin":8526,"position":1},"title":"A Better PowerShell More","author":"Jeffery Hicks","date":"December 23, 2015","format":false,"excerpt":"In PowerShell, when I have a lot of output, I can use the legacy more.com command to page the results to the screen. Get-Process | more There's not anything inherently wrong with this approach. Although one drawback is that it doesn't work in the PowerShell ISE. For that reason alone\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"More PowerShell Output","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-6.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-6.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-6.png?resize=525%2C300 1.5x"},"classes":[]},{"id":6275,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6275\/powershell-updown-prompt\/","url_meta":{"origin":8526,"position":2},"title":"A PowerShell Up\/Down Prompt","author":"Jeffery Hicks","date":"December 11, 2018","format":false,"excerpt":"It appears many of you are taken with the possibilities of PowerShell prompt functions. In previous posts, I alluded to the fact that you could do just about anything in a prompt function. Today I have an example of what I am talking about. The challenging part of creating a\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\/2018\/12\/image_thumb-7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-7.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2350,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2350\/get-my-variable-revisited\/","url_meta":{"origin":8526,"position":3},"title":"Get My Variable Revisited","author":"Jeffery Hicks","date":"May 29, 2012","format":false,"excerpt":"Last year I wrote a few articles on working with variables. One task I needed was to identify the variables that I had created in a given PowerShell session with a function I wrote called Get-MyVariable. I also posted an article on identifying the object type for a variable value.\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\/10\/talkbubble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2044,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2044\/maximizing-the-powershell-console-title-bar\/","url_meta":{"origin":8526,"position":4},"title":"Maximizing the PowerShell Console Title Bar","author":"Jeffery Hicks","date":"January 31, 2012","format":false,"excerpt":"A few days ago Boe Prox posted some very nifty PowerShell modules for using the title bar as a ticker for RSS feeds like the weather. I thought this was an awesome idea and an easy way to take advantage of what would otherwise be unused screen space. I was\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\/01\/console-title-sysstat-300x85.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8724,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8724\/discovering-aliases-with-the-powershell-ast\/","url_meta":{"origin":8526,"position":5},"title":"Discovering Aliases with the PowerShell AST","author":"Jeffery Hicks","date":"December 15, 2021","format":false,"excerpt":"I've been working on a new PowerShell module that incorporates code from a few of my recent posts on converting PowerShell scripts and functions to files. I even whipped up a script, think of it as a meta-script, to create the module using the commands that I am adding to\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\/2021\/12\/find-alias-string.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/find-alias-string.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8526","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=8526"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8526\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}