{"id":12561,"date":"2011-09-28T00:01:00","date_gmt":"2011-09-28T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/09\/28\/simplify-creating-items-with-powershell-providers\/"},"modified":"2011-09-28T00:01:00","modified_gmt":"2011-09-28T00:01:00","slug":"simplify-creating-items-with-powershell-providers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/simplify-creating-items-with-powershell-providers\/","title":{"rendered":"Simplify Creating Items with PowerShell Providers"},"content":{"rendered":"<p><strong>Summary<\/strong>: Learn how to use the same syntax to create different types of items via Windows PowerShell providers.\n&nbsp;\n<img decoding=\"async\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\">Hey, Scripting Guy! I am wondering about the Windows PowerShell idea of providers. I have seen you mention them before, but not recently. I am not even sure that the Scripting Wife has talked about Windows PowerShell providers. Is this something that is not very important? Have you just overlooked something? What is the deal?<\/p>\n<p>&mdash;GB<br \/>&nbsp;\n<img decoding=\"async\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\">Hello GB,\nMicrosoft Scripting Guy Ed Wilson here. This week I am onsite with customers talking to them about Windows PowerShell. In fact, I had a number of questions about providers today, so the ideas are fresh in my mind. I cannot check to see how many articles I have actually mentioned Windows PowerShell providers, because the search is not working very well on the Hey, Scripting Guy! Blog right now. We are in the process of transitioning to a new mechanism, and it is busy rebuilding new indexes.\nThe topic of providers has not been overlooked, but maybe just not highlighted too much. For example, in getting ready for the <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/04\/26\/2010-scripting-games-all-links-on-one-page.aspx\">2010 Scripting Games<\/a>, the <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/04\/20\/hey-scripting-guy-april-20-2010.aspx\">Scripting Wife had a lesson using the registry provider<\/a>.\nThe cool thing about Windows PowerShell providers is they provide a single way to access different types of data. For example, the provider cmdlets all have the word <b>Item<\/b> in the noun (either in part or completely). These cmdlets are shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Get-Command -Noun *item* | Select-Object name<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span><\/p>\n<p style=\"padding-left: 30px\">Clear-Item<\/p>\n<p style=\"padding-left: 30px\">Clear-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Copy-Item<\/p>\n<p style=\"padding-left: 30px\">Copy-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Get-ChildItem<\/p>\n<p style=\"padding-left: 30px\">Get-Item<\/p>\n<p style=\"padding-left: 30px\">Get-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Invoke-Item<\/p>\n<p style=\"padding-left: 30px\">Move-Item<\/p>\n<p style=\"padding-left: 30px\">Move-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">New-Item<\/p>\n<p style=\"padding-left: 30px\">New-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Remove-Item<\/p>\n<p style=\"padding-left: 30px\">Remove-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Rename-Item<\/p>\n<p style=\"padding-left: 30px\">Rename-ItemProperty<\/p>\n<p style=\"padding-left: 30px\">Set-Item<\/p>\n<p style=\"padding-left: 30px\">Set-ItemProperty\nThe reason they use the word <b>Item<\/b> is because they can work against different data sources, so they could be one of many different types of items. For example, if I am on my C: drive, and I use the New-Item cmdlet, I can create either a new file or folder. This command will use the <b>filesystem<\/b> provider. I must tell the provider what I want to create: either a file or folder. This is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; New-Item -Name example1 -Path c: -ItemType directory<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; Directory: Microsoft.PowerShell.CoreFileSystem::C:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Mode<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">LastWriteTime<\/span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Length Name<\/span><\/p>\n<p style=\"padding-left: 30px\">d&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9\/27\/2011&nbsp; 8:51 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DIR&gt; example1&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; New-Item -Name example.txt -Path C:example1 -ItemType file<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; Directory: Microsoft.PowerShell.CoreFileSystem::C:example1<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Mode<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">LastWriteTime<\/span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Length Name<\/span><\/p>\n<p style=\"padding-left: 30px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9\/27\/2011&nbsp; 8:52 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 example.txt<\/p>\n<p style=\"padding-left: 30px\">&nbsp;\nIf I change to the variable drive and use the <b>New-Item<\/b> cmdlet, I will create a new variable. Only one type of item exists on a variable drive (a variable), so there is no need to use the <i>itemtype<\/i> parameter with the command. This technique is shown here where I use the <b>New-Item<\/b> cmdlet to create a new variable. I then call the variable to illustrate that it is created, and that it contains the string value &ldquo;example variable.&rdquo;<\/p>\n<p style=\"padding-left: 30px\">PS C:&gt; Set-Location variable:<\/p>\n<p style=\"padding-left: 30px\">PS Variable:&gt; New-Item -Name example -Value &#8220;example variable&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Value<\/span><\/p>\n<p style=\"padding-left: 30px\">Example&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; example variable<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">PS Variable:&gt; $example<\/p>\n<p style=\"padding-left: 30px\">example variable<\/p>\n<p style=\"padding-left: 30px\">PS Variable:&gt;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;\nWhen I change my working drive to the env (environmental variable drive) drive, the exact same command I used to create an example variable creates an example environmental variable. In the following code, I first change my working drive to the <b>env:<\/b> drive. Next, I create an environmental variable named <b>example<\/b>, and I assign the string value &ldquo;example variable&rdquo; to this environmental variable. I then retrieve the value of the new environmental variable by accessing it from the <b>$env:<\/b> drive. This code is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS Variable:&gt; Set-Location env:<\/p>\n<p style=\"padding-left: 30px\">PS Env:&gt; New-Item -Name example -Value &#8220;example variable&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Value<\/span><\/p>\n<p style=\"padding-left: 30px\">Example&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; example variable&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">PS Env:&gt; $env:example<\/p>\n<p style=\"padding-left: 30px\">example variable<\/p>\n<p style=\"padding-left: 30px\">PS Env:&gt;\nOnce again, I use the <b>Set-Location<\/b> cmdlet to change to a new drive. This time, it is the <b>alias:<\/b> drive. I again use the <b>New-Item<\/b> cmdlet in exactly the same way I used it earlier: to create a new alias for the <b>Get-PSDrive<\/b> cmdlet. To create the new alias, I give it a name, <b>psd<\/b>, and I assign a value, <b>Get-PSDrive<\/b>. The command and associated output are shown here:<\/p>\n<p style=\"padding-left: 30px\">PS Env:&gt; Set-Location alias:<\/p>\n<p style=\"padding-left: 30px\">PS Alias:&gt; New-Item -Name psd -Value Get-PSDrive<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">CommandType<\/span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Definition<\/span><\/p>\n<p style=\"padding-left: 30px\">Alias&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get-PSDrive\nTo see if the new alias works, I type psd on the Windows PowerShell console. The output is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS Alias:&gt; psd<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Used (GB)<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Free (GB)<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Provider<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Root<\/span><\/p>\n<p style=\"padding-left: 30px\">Alias&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alias<\/p>\n<p style=\"padding-left: 30px\">C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 99.85&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 47.66&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C:<\/p>\n<p style=\"padding-left: 30px\">Cert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;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bsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WSMan\nI can even use the function drive to create a new function. This is COOL! In the following example, I create a new function that returns information about the <b>winword<\/b> process (the process name used by Microsoft Word). Normally, I would need to write the function as is shown here:<\/p>\n<p style=\"padding-left: 30px\">Function get-word<\/p>\n<p style=\"padding-left: 30px\">{<\/p>\n<p style=\"padding-left: 30px\">&nbsp;Get-process winword<\/p>\n<p style=\"padding-left: 30px\">}\nThe key items to creating the function are the <b>function<\/b> keyword, the name of the function (<b>get-word<\/b>), the script block <b>{}<\/b>, and the code itself: <b>Get-process winword<\/b>.\nAs shown in the code that follows, by using the function drive and the <b>New-Item<\/b> cmdlet, I leave off the braces that mark the script block and the <b>function<\/b> keyword:<\/p>\n<p style=\"padding-left: 30px\">PS Alias:&gt; sl function:<\/p>\n<p style=\"padding-left: 30px\">PS Function:&gt; New-Item -Name get-word -Value &#8220;get-process winword&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">CommandType<\/span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Definition<\/span><\/p>\n<p style=\"padding-left: 30px\">Function&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get-word&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get-process winword\nBut does the new <b>Get-Word<\/b> function actually work? As shown here, it does work:<\/p>\n<p style=\"padding-left: 30px\">PS Function:&gt; get-word<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">Handles<\/span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">NPM(K)<\/span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">PM(K)<\/span>&nbsp;&nbsp; <span style=\"text-decoration: underline\">WS(K)<\/span>&nbsp;&nbsp; <span style=\"text-decoration: underline\">VM(M)<\/span>&nbsp; <span style=\"text-decoration: underline\">CPU(s)<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Id<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">ProcessName<\/span><\/p>\n<p style=\"padding-left: 30px\">746&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 74&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37872&nbsp;&nbsp; 87000&nbsp;&nbsp; 404&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 31.72&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1280&nbsp;&nbsp;&nbsp;&nbsp; WINWORD\nIf I pop over to the HKCU registry drive, I can even use the <b>New-Item<\/b> cmdlet to create a new registry key:<\/p>\n<p style=\"padding-left: 30px\">PS Function:&gt; Set-Location hkcu:<\/p>\n<p style=\"padding-left: 30px\">PS HKCU:&gt; New-Item -Path HKCU:Software -Name example<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; Hive: HKEY_CURRENT_USERSoftware<\/p>\n<p style=\"padding-left: 30px\"><span style=\"text-decoration: underline\">SKC<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">VC<\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Name<\/span>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"text-decoration: underline\">Property<\/span><\/p>\n<p style=\"padding-left: 30px\">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; example&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {}<\/p>\n<p style=\"padding-left: 30px\">&nbsp;\nSo, GB, I hope this quick tour of the various Windows PowerShell drives that the Windows PowerShell providers create will inspire you to experiment with this powerful tool. The really revolutionary thing is using exactly the same command&mdash;and in any case the same syntax&mdash;to create a new alias, file, folder, variable, environmental variable, function, and registry key. Exploring the Windows PowerShell provider subsystem will pay great dividends.\n&nbsp;\nTomorrow, I will continue talking about Windows PowerShell providers.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<b>Ed Wilson, Microsoft Scripting Guy<\/b>\n&nbsp;\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to use the same syntax to create different types of items via Windows PowerShell providers. &nbsp; Hey, Scripting Guy! I am wondering about the Windows PowerShell idea of providers. I have seen you mention them before, but not recently. I am not even sure that the Scripting Wife has talked about Windows [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[51,3,4,45],"class_list":["post-12561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to use the same syntax to create different types of items via Windows PowerShell providers. &nbsp; Hey, Scripting Guy! I am wondering about the Windows PowerShell idea of providers. I have seen you mention them before, but not recently. I am not even sure that the Scripting Wife has talked about Windows [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=12561"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=12561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=12561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=12561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}