Hi,
I am trying to fetch a path from a database and map a drive to that path with the code below:
$ArchivePath = Invoke-Sqlcmd -query "SELECT [value] FROM [MyDB].[dbo].[PartitioningConfiguration] (nolock) WHERE name = 'ArchivePath'"
If (!(Test-Path A:)) {net use A: $ArchivePath[0]}
The first command works fine and populates $ArchivePath variable with a correct value.
The second command fails with the following error:
"The network name can not be found"
I can confirm that the path exists and accessible. The net use command works if I just hardcode the value into the command, but does not work with a variable.
Any ideas?
Thanks.