I am trying to use vssadmin.exe within a Windows 2012 R2 server Powershell script, but I cannot workout how to get the Shadow ID & Volume Name as variables?
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
Successfully created shadow copy for 'C:\'
Any help will be appreciated.
As it's a script, I guess it doesn't matter if you don't see output for vssadmin?
Select the two strings from the command's output and assign them to a variable.
$string = vssadmin create shadow /for=C: | Select-String 'Shadow Copy ID','Shadow Copy Volume' $id = ($string -split 'ID:').trim() $Volume = ($string -split 'Name:').trim() Write-Output "ID = $id, Volume = $Volume"
This only handles your example, if you were using list shadows you'd need a different technique as you'll probably have multiple IDs and volume names.
Thank you Matt, that is exactly what I needed.
Without great people like yourself, I would be completely lost with PowerShell.!!
Thank you again.
You must be logged in to reply to this topic.