{"id":19,"date":"2006-12-19T04:00:00","date_gmt":"2006-12-19T12:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2006\/12\/19\/drive-it-home\/"},"modified":"2006-12-19T04:00:00","modified_gmt":"2006-12-19T12:00:00","slug":"drive-it-home","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2006\/12\/19\/drive-it-home\/","title":{"rendered":"Drive it Home"},"content":{"rendered":"<p>An exciting feature of PowerShell is that you can present things like the registry as a drive. This is accomplished with the PSDriveInfo object. If you run Get-PSDrive in PowerShell you will see all the &#8220;drives&#8221; that you can connect to.&nbsp; You can also create additional drives with New-PSDrive.<\/p>\n<p>The path to My Documents is just too darn long to type everytime I want to change to it. In PowerShell I can simplify this by assigning a drive letter to the path like this:<\/p>\n<p><span style=\"font-family: Courier New,Courier,mono;\">new-psdrive U -psprovider FileSystem -root &#8220;$env:Userprofile\\my documents&#8221;<\/span><\/p>\n<p>Now drive U: is the root of the My Documents folder. This drive mapping is not available outside the scope of my existing PowerShell session. If I open a second PowerShell window, it won&#8217;t know anything about drive U. When I close my first PowerShell session and restart, drive U is gone.&nbsp; I&#8217;d have to add this expression to my profile if I always wanted it to be available.&nbsp; I could also have used something like:<br \/>&nbsp;<br \/><span style=\"font-family: Courier New,Courier,mono;\">new-psdrive Docs -psprovider FileSystem -root &#8220;$env:Userprofile\\my documents&#8221;<\/span><\/p>\n<p>and created a drive called Docs. To change to that &#8220;directory&#8221; I would have to do this:<\/p>\n<p><span style=\"font-family: Courier New,Courier,mono;\">set-location docs:<\/span><\/p>\n<p>The advantage of using a drive letter is that it makes changing drives a little easier.&nbsp; I also don&#8217;t have to worry that any applications or scripts that I start will get confused with a drive letter of docs:.<\/p>\n<p>You can achieve similar results in the CMD world by using SUBST. Any SUBST mappings that you create in CMD.exe will be recognized in PowerShell.<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An exciting feature of PowerShell is that you can present things like the registry as a drive. This is accomplished with the PSDriveInfo object. If you run Get-PSDrive in PowerShell you will see all the &#8220;drives&#8221; that you can connect to.  You can also create additional drives with New-PSDrive.<\/p>\n","protected":false},"author":3,"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,"footnotes":""},"categories":[2,25],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-general","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}