Delete Shadow Copies Remotely
You can do this remotely with diskshadow. To accomplish this, write a batch file containing the wanted commands and place it somewhere on the target server, then: psexec \\remotehost diskshadow /s C:\path\to\script.bat
. You can also use a network location for the path.
Related videos on Youtube
john
Technology and programming enthusiast with a solid understanging of network communications. I started out moonlighting as a PHP developer and then got hired as a junior technician in a school. Now, 10 years on, I'm working as a Senior Tech in Infrastructure for an Engineering company. I still maintain my web development skills when I can. My main areas of expertise are automation, virtualisation and storage. I don't think there's ever a time when I don't have a PowerShell console open. I maintain a VM infrastructure, a hybrid Office 365 implementation and an AD forest.
Updated on September 18, 2022Comments
-
john almost 2 years
I currently use
DISKSHADOW
to remove shadow copies from our Hyper-V servers. To do this I have to log onto the server butpsexec
doesn't work.psexec \\hyper-v-server diskshadow DISKSHADOW> Error reading from console. Win32 error: 0x6 The handle is invalid.
I think
vssadmin
works doing the above, but I'd like to script this with PowerShell and slectively remove the shadow copies. Neither of these tools provide usable output in PowerShell.I've done a bit of research but not found any way to query snapshots with PowerShell, either locally or remotely. I imagine doing this will involve use of the
Get-WMIObject
CMDlet to query the relevant info from WMI, but I can only find theWin32_ShadowCopy.Create()
method.EDIT: To be clear, what I would like are objects I can manipulate using PowerShell.
-
john almost 11 yearsThanks @NathanC. I was aware of this also, but I don't like the idea of having to maintain the batch files on each of our hosts. It just feels a bit "hacky".
-
Nathan C almost 11 yearsYou can specify a remote path so you only have to have a single batch file.