0

Trying to mount Azure FS from Powershell runbook in Azure Automation. Via username and key

$UserName = "localhost\trex4xfs"
$Key = "Zav---mykey-----1Tdw=="
$RemotePath = "\\myshare.file.core.windows.net\mainfs"
$MapDrive = "z:"

Get-Command -Name *SmbMapping* | ft

[securestring]$pass = ConvertTo-SecureString $key -AsPlainText -Force
$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $UserName, $pass

new-psdrive -name T -PsProvider FileSystem -root $RemotePath -credential $credential
Get-PSDrive | ft

echo "--------now import smb"
Import-Module smbshare
echo "--------now smb"
New-SmbMapping -LocalPath $MapDrive -RemotePath $RemotePath -UserName $UserName -Password $Key

Above works great on "plain Powershell on Windows"

Tried

  • Runbook with 5.1 and 7.1 PS version
  • new-psdrive (error: This function is not supported on this system )
  • New-SmbMapping (error 7.1: The 'New-SmbMapping' command was found in the module 'SmbShare', but the module could not be loaded. For more information, run 'Import-Module SmbShare'
  • New-SmbMapping (error 5.1: Cannot connect to CIM server. The specified service does not exist as an installed service. )
  • Import-Module smbshare (error Failed to generate proxies for remote module 'smbshare'. Cannot overwrite the item C:\Users\Client\Temp\tmp_5t22mi1k.oh0\remoteIpMoProxy_smbshare_2.0.0.0_localhost_f29e4e95-e8cf-4256-a4db-fc9381c6563c.format.ps1xml with itself.)
  • New-CimSession (error: The specified service does not exist as an installed service.)

Seem to be related to New-CimSession not available on Azure Automation runbook

other questions related to this:

Tilo
  • 1,110
  • 3
  • 21
  • 42

1 Answers1

0

One of the related question which you have shared already provides the answer (i.e., this one) which basically says to use hybrid runbook worker in your use case scenario.

KrishnaG
  • 3,340
  • 2
  • 6
  • 16