First post here!
I'm seeking to improve my monitoring of DFS replication on Windows 2008 R2 and so do not have access to the nicer PS cmdlets available to 2012 and above. I've run into an oddity and wondered hwo to get out of it, please? I'm a bit of a PS-novice so am hoping the solution is easy enough. :-)
I query the DFSR VolumeInfo using WMI (see ref) so:
$DFSVolumeInfo = gwmi -Namespace "root\MicrosoftDFS" -Computer $DFSServer -query "select * from DfsrVolumeInfo"
Now, if I return without, and then with quotes:
write-host $DFSVolumeInfo.VolumePath
\\.\E: \\.\D:
write-host "$DFSVolumeInfo.VolumePath"
\\DC2-SRV-DFS01\root\MicrosoftDFS:DfsrVolumeInfo.VolumeGuid="6C4C4203-2BC9-11E4-9EF3-0050568815FA"
\\DC2-SRV-DFS01\root\MicrosoftDFS:DfsrVolumeInfo.VolumeGuid="D214D634-F794-11E3-9EF3-0050568815FA".VolumePath
The latter gives the VolumeGuid
too.
The Class gives the following properties for VolumePath
VolumePath Data type: string
Access type: Read-only
Qualifiers: DisplayName
("Replication Group GUID") The volume path format; this is either \\.\C:
or \\?\volume{GUID}
.
Is there anyway to return the VolumePath, i.e. C:, D: etc inside of quotes, rather than the GUID?
The output needs to be more human-readable and so I'll be echo-ing the output with quotes i.e. "$DFSVolumeInfo.VolumePath on $DFSServer has a state of $DFSVolumeInfo.State"