[Azure DSC] Scale Sets Mapped Drives

Welcome Forums DSC (Desired State Configuration) [Azure DSC] Scale Sets Mapped Drives

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 9 months ago.

  • Author
  • #59665

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    I am running into an interesting issue. Maybe you fine folks can help me understand what's happening here. If there's a better method, I'm all ears.

    I am running a DSC Configuration on Azure and would like to map a drive. I've read this really isn't what DSC is for, but I am not aware of any other way of doing this outside of DSC with Azure Scalesets. Here's the portion of the script I am running into issues:

    Script MappedDrive
    			SetScript = 
    			$pass = "passwordhere" | ConvertTo-SecureString -AsPlainText -force
    			$user = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "username",$pass
    			New-PSDrive -Name W -PSProvider FileSystem -root \\azurestorage.file.core.windows.net\storage -Credential $user -Persist
    			TestScript = 
    				Test-Path -path "W:"
    			GetScript = 
    			$hashresults = @{}
    			$hashresults['Exists'] = test-path W:

    I've also attempted this code in the SetScript section:

    (New-Object -ComObject WScript.Network).MapNetworkDrive('W:','\\azurestorage.file.core.windows.net\storage',$true,'username','passwordhere')

    Troubleshooting I've done:

      * There is no domain in my environment. I am simply attempting to create a scale set and run DSC to configure the machine using the storage account credentials granted upon creation of the storage account.
      * I am using the username and password that is given to me by the Storage Account user id and access key (randomly generated key, with usually the name of the storage account as the user).
      * Azure throws no errors on running the DSC module (No errors in Event Log, Information Only – Resource execution sequence properly lists all of my sequences in the DSC file.)
      * When I log into the machine and check to see if the drive is mapped, I run into a disconnected network drive on the drive letter I want (W:).
      * If I open Powershell, I receive an error: "Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed."
      * If I run "Get-PSDrive" the W: drive does not appear.
      * If I run the SetScript code manually inside a Powershell Console, the mapped drive works fine under a different drive letter.
      * If I try to disconnect the W: drive, I receive "This network connection does not exist."
  • #59998

    Topics: 13
    Replies: 4872
    Points: 1,844
    Helping HandTeam Member
    Rank: Community Hero

    Yeah, it really isn't what DSC is for ;). I'm not sure Azure is trying to solve this problem space, either.

    Drives are only mapped in a user context, and the LCM doesn't run in a user context. So I'm not even sure this would be something DSC could do. You're seeing it work when you're logged on, because THEN there's a user context.

The topic ‘[Azure DSC] Scale Sets Mapped Drives’ is closed to new replies.