0

I backup my SQL Server to an Azure location.

The way I do this is by mapping the Azure location as a drive in SQL Server and then direct my backups to that location.

When I run the following script I can see my mapped drive S:

DECLARE @CommandPath AS NVARCHAR(MAX);

SET @CommandPath = 'EXEC XP_CMDSHELL ''NET USE * /DELETE /NO'''

EXEC sp_executesql @CommandPath

image

When I run the command below I cannot see the S:\ is there any way I could see mapped drives using wmic?

DECLARE @COMMAND NVARCHAR(2000);

SET @COMMAND ='wmic /FailFast:ON logicaldisk where (drivetype ="3" and volumename!="RECOVERY" AND volumename!="System Reserved") get deviceid,volumename /Format:csv'

EXEC master..xp_cmdshell @COMMAND

this returns the following result:

image

the S: drive is not in there.

or using PowerShell I get to the same list of drives by running this command:

gwmi Win32_LogicalDisk -Filter “Drivetype=3” |select Computername, Name, FreeSpace,BlockSize,Size | % {$_.Computername=($env:COMPUTERNAME);$_.BlockSize=(($_.FreeSpace)/($_.Size))*100;$_.FreeSpace=($_.FreeSpace/1GB);$_.Size=($_.Size/1GB);$_} | Format-Table Computername, Name, @{n=’Capacity_Gb’;e={‘{0:N3}’ -f $_.Size}}, @{n=’FreeGb’;e={‘{0:N2}’-f $_.FreeSpace}}, @{n=’Free_%’;e={‘{0:N2}’-f $_.BlockSize}} -AutoSize

image

Is there a way to show the S: drive in there?

What I really need is the free space available in the mapped drive in Azure.

Is there any way I can achieve this?

0 Answers0