Last active
November 30, 2022 14:09
-
-
Save lechup/12358fb869fdcc64cfb761e900a4b700 to your computer and use it in GitHub Desktop.
Scripts to manage backup on Windows 10 machines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set-ExecutionPolicy Bypass -Scope Process -Force; or use run.bat | |
$cred = Import-Clixml .\backup.cred | |
iex "wbadmin start backup -allCritical -backupTarget:\\backup-server.lan\backup\komputery\ -user:$($cred.UserName) -password:$($cred.GetNetworkCredential().password) -quiet > .\backup.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set-ExecutionPolicy Bypass -Scope Process -Force; or use run.bat | |
param( | |
[string]$credFile | |
) | |
if($credFile -ne '') { | |
Get-Credential | Export-Clixml $credFile | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set-ExecutionPolicy Bypass -Scope Process -Force; or use run.bat | |
$cred = Import-Clixml .\backup.cred | |
iex "net use Z: \\backup-server.lan\backup /Persistent:No /user:$($cred.UserName) $($cred.GetNetworkCredential().password)" > $null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eg. run.bat backup.ps1 | |
@echo off | |
powershell.exe -noprofile -executionpolicy bypass -WindowStyle hidden -file %1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set-ExecutionPolicy Bypass -Scope Process -Force; or use run.bat | |
net use /delete * /Y > $null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eg once a week | |
cmd.exe /c start "backup" /MIN /LOW run.bat backup.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment