Delete Shadow Copies Remotely

7,143

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.

Share:
7,143

Related videos on Youtube

john
Author by

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, 2022

Comments

  • john
    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 but psexec 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 the Win32_ShadowCopy.Create() method.

    EDIT: To be clear, what I would like are objects I can manipulate using PowerShell.

  • john
    john almost 11 years
    Thanks @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
    Nathan C almost 11 years
    You can specify a remote path so you only have to have a single batch file.