none
VSS Can't enable Shadow copies using powershell script RRS feed

  • Pregunta

  • The code which I did for VSS is :

    $array = @() $arrayforC=@() $checkC = gwmi -class Win32_Share | Where-Object {$_.path -match "C:"} $checkD = gwmi -class Win32_Share | Where-Object {$_.path -match "D:"} foreach ( $checkin in $check ) {$arrayforC = $checkin | where-object {$_.name -ne 'Admin$' ` -and ($_.name -ne 'C$') -and ($_.name -ne 'print$') ` -and ($_.name -ne 'IPC$')} } foreach ( $checkin in $check ) {$arrayford = $checkin | where-object {$_.name -ne 'Admin$' ` -and ($_.name -ne 'D$') -and ($_.name -ne 'print$') ` -and ($_.name -ne 'IPC$')} } #if ( $arrayforC -eq $null ) {Write-host Null} if ( $arrayforC -ne $null ) { vssadmin add shadowstorage /for=C: /on=C: /maxsize=10% vssadmin create shadow /for=C: Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=C:" $Trigger=new-scheduledtasktrigger -daily -at 6:00AM Register-ScheduledTask -TaskName ShadowCopyC_AM -Trigger $Trigger -Action $Action -Description "ShadowCopyC_AM" } if ( $arrayforD -ne $null ) { vssadmin add shadowstorage /for=D: /on=D: /maxsize=10% vssadmin create shadow /for=D: Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=D:" $Trigger=new-scheduledtasktrigger -daily -at 7:00AM Register-ScheduledTask -TaskName ShadowCopyD_AM -Trigger $Trigger -Action $Action -Description "ShadowCopyD_AM" }

    First and main problem is when I used this script it's created a shadow copies with my arguments , but when you go to C disk, and right click on it, and click Configure Shadow Copies I see that it's not Enable Shadow Copy

    and the second problem is :Register-ScheduledTask : Cannot create a file when that file already exists. At line:22 char:1 + Register-ScheduledTask -TaskName ShadowCopyC_AM -Trigger $Trigger -Ac ...

    I do not know why it said, because every time when it's creates a file it's always with a different name

    viernes, 17 de enero de 2020 13:57

Todas las respuestas