{"id":13,"date":"2017-03-03T15:01:42","date_gmt":"2017-03-03T21:01:42","guid":{"rendered":"http:\/\/peterod.azurewebsites.net\/?p=13"},"modified":"2017-03-03T15:01:42","modified_gmt":"2017-03-03T21:01:42","slug":"move-the-azure-temporary-disk-to-a-different-drive-letter-on-windows-server","status":"publish","type":"post","link":"http:\/\/www.perktime.org\/index.php\/2017\/03\/03\/move-the-azure-temporary-disk-to-a-different-drive-letter-on-windows-server\/","title":{"rendered":"Move the Azure temporary disk to a different drive letter on Windows Server"},"content":{"rendered":"<p>On occasion you may have a need to move the Azure temporary drive to a different drive letter. Azure by default is set to use the D drive. This drive letter configuration may conflict with existing scripts or company OS installation standards. I\u2019ve created an ARM template that uses PowerShell DSC to allow you to move the drive letter. It performs the following steps:<br \/>\n1) Disables the Windows Page File and reboots the VM<br \/>\n2) Changes the drive letter from the D drive to a drive letter you specify in the ARM template parameters file<br \/>\n3) Re-enables the Windows page file and reboots the VM<br \/>\nThis project is in GitHub here: <a title=\"https:\/\/github.com\/perktime\/MoveAzureTempDrive\" href=\"https:\/\/github.com\/perktime\/MoveAzureTempDrive\">https:\/\/github.com\/perktime\/MoveAzureTempDrive<\/a>. To use it, modify the azuredeploy.parameters.json file with your vmName and your desired tempDriveLetter:<br \/>\n<span style=\"font-family: Courier New;\">{<br \/>\n&#8220;$schema&#8221;: &#8220;<\/span><a href=\"https:\/\/schema.management.azure.com\/schemas\/2015-01-01\/deploymentParameters.json#&quot;\"><span style=\"font-family: Courier New;\">https:\/\/schema.management.azure.com\/schemas\/2015-01-01\/deploymentParameters.json#&#8221;<\/span><\/a><span style=\"font-family: Courier New;\">,<br \/>\n&#8220;contentVersion&#8221;: &#8220;1.0.0.0&#8221;,<br \/>\n&#8220;parameters&#8221;: {<br \/>\n&#8220;vmName&#8221;: {<br \/>\n&#8220;value&#8221;: <strong>&#8220;&lt;put_your_existing_vm_name_here&gt;&#8221;<\/strong><br \/>\n},<br \/>\n&#8220;assetLocation&#8221;: {<br \/>\n&#8220;value&#8221;: &#8220;<\/span><a href=\"https:\/\/petedscutil.blob.core.windows.net\/scripts&quot;\"><span style=\"font-family: Courier New;\">https:\/\/petedscutil.blob.core.windows.net\/scripts&#8221;<\/span><\/a><br \/>\n<span style=\"font-family: Courier New;\">\u00a0\u00a0\u00a0 },<br \/>\n&#8220;tempDriveLetter&#8221;: {<br \/>\n&#8220;value&#8221;: &#8220;<strong>Z<\/strong>&#8221;<br \/>\n}<br \/>\n}<br \/>\n}<\/span><br \/>\nOptionally, you can copy the MoveAzureTempDrive.ps1.zip DSC file to your own Azure storage account and modify the assetLocation parameter as well. Also, if you have an existing DSC extension you will have to remove it before deploying this.<br \/>\nIf you are interested in how this works, here is the explanation (note: assuming you understand how PowerShell DSC works):<br \/>\nTo disable the Windows page file, we use \u201cgwmi win32_pagefilesetting\u201d which uses WMI to first check if the page file is enabled or not. If it is, we use this script to delete it and restart the VM:<br \/>\n<span style=\"font-family: Courier New;\">gwmi win32_pagefilesetting<br \/>\n$pf=gwmi win32_pagefilesetting<br \/>\n$pf.Delete()<br \/>\nRestart-Computer \u2013Force<\/span><br \/>\nOnce the VM restarts, the PowerShell DSC module will then change the drive letter to your desired drive and then re-enable the page file and reboot:<br \/>\n<span style=\"font-family: Courier New;\">Get-Partition -DriveLetter &#8220;D&#8221;| Set-Partition -NewDriveLetter $TempDriveLetter<br \/>\n$TempDriveLetter = $TempDriveLetter + &#8220;:&#8221;<br \/>\n$drive = Get-WmiObject -Class win32_volume -Filter \u201cDriveLetter = &#8216;$TempDriveLetter&#8217;\u201d<br \/>\n#re-enable page file on new Drive<br \/>\n$drive = Get-WmiObject -Class win32_volume -Filter \u201cDriveLetter = &#8216;$TempDriveLetter&#8217;\u201d<br \/>\nSet-WMIInstance -Class Win32_PageFileSetting -Arguments @{ Name = &#8220;$TempDriveLetter\\pagefile.sys&#8221;; MaximumSize = 0; }<\/span><br \/>\n<span style=\"font-family: Courier New;\">Restart-Computer -Force<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>On occasion you may have a need to move the Azure temporary drive to a different drive letter. Azure by default is set to use the D drive. This drive letter configuration may conflict with existing scripts or company OS installation standards. I\u2019ve created an ARM template that uses PowerShell DSC to allow you to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.perktime.org\/index.php\/2017\/03\/03\/move-the-azure-temporary-disk-to-a-different-drive-letter-on-windows-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Move the Azure temporary disk to a different drive letter on Windows Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/13"}],"collection":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":0,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}