{"id":942,"date":"2019-01-14T17:55:22","date_gmt":"2019-01-14T16:55:22","guid":{"rendered":"https:\/\/vblog.hochsticher.de\/?p=942"},"modified":"2023-03-30T10:30:08","modified_gmt":"2023-03-30T08:30:08","slug":"check-deprecated-powercli-cmdlets","status":"publish","type":"post","link":"https:\/\/vblog.hochsticher.de\/?p=942","title":{"rendered":"Check deprecated PowerCLI CMDlets"},"content":{"rendered":"\n<p>I think most of you have a set of various PowerCLI Scripts that runs automatically day by day. Have you ever checked if your older scripts contain some deprecated commands? Here is a handy way to check &#8230;<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>If you read the Change Log from PowerCLI <a href=\"https:\/\/vdc-download.vmware.com\/vmwb-repository\/dcr-public\/306e3e41-2a54-497e-8377-11a1cf36c107\/76c39d63-455d-4f3a-af2a-368f3ea6647c\/changelog.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">here<\/a> you find some deprecated or even deleted commands. So that is the reason why you should check from time to time your daily running scripts.<\/p>\n\n\n\n<p>At the last VMworld 2018 in Barcelona, I spoke to <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/twitter.com\/kmruddy\" target=\"_blank\">Kyle Ruddy<\/a> after the Session &#8220;<a rel=\"noreferrer noopener\" href=\"https:\/\/my.vmworld.com\/widget\/vmware\/vmworld18eu\/eucatalog?search=DEV3504BE\" target=\"_blank\">DEV3504BE<\/a>&#8221; about a way to check on deprecated commands. I hope to get a list from him soon but in the meantime I looked at a easy way to check the content of a Script folder against a JSON-File. And this was much easier than I thought \ud83d\ude09<\/p>\n\n\n\n<p>All we need is a JSON File filled and a few lines of PowerShell.<\/p>\n\n\n\n<p>The JSON File could look like this:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"deprecatedcmd\": &#91;\n    \"Get-DrmInfo\",\n    \"Get-OrgNetwork\",\n\t\"Get-VMGuestNetworkInterface\",\n\t\"Set-VMGuestNetworkInterface\",\n\t\"Get-VMGuestRoute\",\n\t\"New-VMGuestRoute\",\n\t\"Remove-VMGuestRoute\",\n\t\"Get-VMHostPatch\",\n\t\"Test-VsanStoragePerformance\"\n      ],\n  \"delcmd\": &#91;\n    \"Get-DrmInfo\",\n    \"Get-VMGuestNetworkInterface\",\n\t\"Set-VMGuestNetworkInterface\",\n\t\"Get-VMGuestRoute\",\n\t\"New-VMGuestRoute\",\n\t\"Remove-VMGuestRoute\",\n\t\"New-CustomField\",\n\t\"Remove-CustomField\",\n\t\"Set-CustomField\"\n  ]\n}<\/code><\/pre>\n\n\n\n<p>To check your usage of deprecated or deleted commands you could use this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$uri = \"https:\/\/vblog.hochsticher.de\/wp-content\/uploads\/2019\/01\/old-cmds.json\"\n$path = \"C:\\scripts\"\n\nInvoke-RestMethod -Uri $uri | Select -ExpandProperty deprecatedcmd\nInvoke-RestMethod -Uri $uri | Select -ExpandProperty delcmd\n\n$deprecatedcmd = Invoke-RestMethod -Uri $uri | Select -ExpandProperty deprecatedcmd\n$delcmd = Invoke-RestMethod -Uri $uri | Select -ExpandProperty delcmd\n\nGet-ChildItem -recurse -Path $path| Select-String -pattern $deprecatedcmd | select Path,LineNumber,Line\n\nGet-ChildItem -recurse -Path $path| Select-String -pattern $delcmd | select Path,LineNumber,Line<\/code><\/pre>\n\n\n\n<p>The output tells you in which file and line you used one of those commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS C:\\Users\\xyz&gt; \nGet-ChildItem -recurse -Path $path| Select-String -pattern $deprecatedcmd | select Path,LineNumber,Line\nPath                                    LineNumber Line       \n----                                    ---------- ----       \nC:\\scripts\\temp\\Test-Deprecated-CMD.ps1         50 Get-DrmInfo<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I think most of you have a set of various PowerCLI Scripts that runs automatically day by day. Have you ever checked if your older scripts contain some deprecated commands? Here is a handy way to check &#8230;<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[4],"tags":[8],"class_list":["post-942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powercli","tag-powercli"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=942"}],"version-history":[{"count":10,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/942\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/942\/revisions\/1104"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}