瀏覽代碼

Support specific disk parameter

David Witham 3 年之前
父節點
當前提交
8a7fb76133
共有 1 個文件被更改,包括 13 次插入2 次删除
  1. 13 2
      backup_aragorn.psm1

+ 13 - 2
backup_aragorn.psm1

@@ -4,14 +4,19 @@ function backup_aragorn {
 
     param(
         [switch]$diskoverride,
-        [switch]$skipappdir)
+        [switch]$skipappdir,
+        [string]$usedisk=$null)
     
     
     . (Join-Path $PSScriptRoot handle_exclude_lists.ps1)
     $myName = $env:COMPUTERNAME
 
     # Identify the backup disk
-    ($backupDisk, $partial) = check_disk $diskoverride
+    if ($usedisk) {
+        ($backupDisk, $partial) = get_specific_disk $usedisk
+    } else {
+        ($backupDisk, $partial) = check_disk $diskoverride
+    }
 
     # Backup folder
     $backup_dir = "$HOME\Local"
@@ -107,6 +112,12 @@ function check_disk($diskoverride=$false) {
     return ($backupDisk.DeviceID, $partialBackup)
 }
 
+function get_specific_disk($letter) {
+    $backupDisk = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DeviceID -imatch $letter}
+    
+    # Return the disk letter and whether to do the full backup
+    return ($backupDisk.DeviceID, $false)
+}
 
 
 function customLogger($backupDisk, $myName) {