I was using azure cli command to run RunPowerShellScript to execute powershell script on the targetted VM. My powershell script was executing properly to mount the file share to VM. But in VM after mounting drive is showing like Disconnected Network drive(Z:) MAFS Please check below screenshot for the above issue.
$connectTestResult = Test-NetConnection -ComputerName "BLOB STORAGE LOCATION HERE" -Port 445
if ($connectTestResult.TcpTestSucceeded) {
# Save the password so the drive will persist on reboot
cmd.exe /C "cmdkey /add:`"Filesharelocation`" /user:`"Filesharename`" /pass:`"ACCESS KEY HERE`"
# Mount the drive
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\Filesharelocation\FOLDER TO MAP" -Persist
} else {
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}
After restarting/stopping the vm the fileshare was disconnecting automatically. The same powershell script was working fine when running that on vm powershell terminal. Can any one help me to mount fileshare properly without disconnecting when restarting the vm.