HannesS
HannesS

Reputation: 173

Powershell Script to compare VolumeID to DriveLetter

I have a powershell script running wbadmin with source C: to a target iSCSI volume which is specified by its volume ID (\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}). The backup itself runs perfectly fine, I just wanted to add an offsite-backup functionality to the script. Sadly, robocopy cannot use the Volume ID as source for the copy job and will reject it as unknown parameter.

Is there a way to conveniently get the actual drive letter from the volume ID so i can replace it before calling robocopy?

The output of "mountvol" looks very promising, but if there is a powershell integrated feature, I would preferably use it.

I already tried Get-PSDrive and Get-Volume, there seems to be no way of getting them to output the VolumeID.

Upvotes: 3

Views: 1725

Answers (1)

CB.
CB.

Reputation: 60910

maybe this should help:

gwmi Win32_Volume |
    ? { $_.deviceID -eq '\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\'} 
          | select -expand name

Upvotes: 8

Related Questions