]> git.p6c8.net - dsmonrot.git/commitdiff
Suppress output of New-PSDrive and New-Item
authorPatrick Canterino <patrick@patrick-canterino.de>
Tue, 6 Mar 2018 13:35:34 +0000 (14:35 +0100)
committerPatrick Canterino <patrick@patrick-canterino.de>
Tue, 6 Mar 2018 13:35:34 +0000 (14:35 +0100)
TODO.md
dsmonrot.ps1

diff --git a/TODO.md b/TODO.md
index 84b50f28c799ad7d07f02483d7b3a641728eca3c..2326604d8c729ea8d692fe430585fd5ecd056135 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -5,4 +5,4 @@
 - [x] ~~Check if the network drive already exists before connecting~~ ⇒ `New-PSDrive` throws an exception if drive is already connected
 - [ ] Create a log file for the script
 - [ ] Clean up the messages sent to the console or send them to the debug or error streams (e.g. `Write-Debug` or `Write-Error`)
 - [x] ~~Check if the network drive already exists before connecting~~ ⇒ `New-PSDrive` throws an exception if drive is already connected
 - [ ] Create a log file for the script
 - [ ] Clean up the messages sent to the console or send them to the debug or error streams (e.g. `Write-Debug` or `Write-Error`)
-- [ ] Suppress output of some commands
\ No newline at end of file
+- [x] Suppress output of some commands
\ No newline at end of file
index 0323afbbaa4a3516de57cc696481bbf3db00b198..c0ee230622cea573cbd3bdca81315f6036d80aa2 100644 (file)
@@ -134,12 +134,12 @@ if($smbDrive) {
                        $secSmbPassword = $smbPassword | ConvertTo-SecureString -asPlainText -Force\r
                        $smbCredential = New-Object System.Management.Automation.PSCredential($smbUser, $secSmbPassword)\r
 \r
                        $secSmbPassword = $smbPassword | ConvertTo-SecureString -asPlainText -Force\r
                        $smbCredential = New-Object System.Management.Automation.PSCredential($smbUser, $secSmbPassword)\r
 \r
-                       New-PSDrive -Name $smbDrive -PSProvider "FileSystem" -Root $smbPath -Credential $smbCredential -Persist -ErrorAction Stop\r
+                       New-PSDrive -Name $smbDrive -PSProvider "FileSystem" -Root $smbPath -Credential $smbCredential -Persist -ErrorAction Stop | Out-Null\r
                }\r
                else {\r
                        Write-Host "Without credentials"\r
                \r
                }\r
                else {\r
                        Write-Host "Without credentials"\r
                \r
-                       New-PSDrive -Name $smbDrive -PSProvider "FileSystem" -Root $smbPath -Persist -ErrorAction Stop\r
+                       New-PSDrive -Name $smbDrive -PSProvider "FileSystem" -Root $smbPath -Persist -ErrorAction Stop | Out-Null\r
                }\r
                \r
                $smbConnected = $True\r
                }\r
                \r
                $smbConnected = $True\r
@@ -177,7 +177,7 @@ if($errorMessages.Count -eq 0) {
                        Write-Host "Creating directory $backupTargetDiff"\r
                        \r
                        try {\r
                        Write-Host "Creating directory $backupTargetDiff"\r
                        \r
                        try {\r
-                               New-Item -ItemType directory -Path $backupTargetDiff -ErrorAction Stop\r
+                               New-Item -ItemType directory -Path $backupTargetDiff -ErrorAction Stop | Out-Null\r
                        }\r
                        catch {\r
                                Write-Host "Could not create directory $backupTargetDiff`: $_.Exception.Message"\r
                        }\r
                        catch {\r
                                Write-Host "Could not create directory $backupTargetDiff`: $_.Exception.Message"\r
@@ -215,7 +215,7 @@ if($errorMessages.Count -eq 0) {
                        Write-Host "Creating directory $backupTarget"\r
                        \r
                        try {\r
                        Write-Host "Creating directory $backupTarget"\r
                        \r
                        try {\r
-                               New-Item -ItemType directory -Path $backupTarget -ErrorAction Stop\r
+                               New-Item -ItemType directory -Path $backupTarget -ErrorAction Stop | Out-Null\r
                        }\r
                        catch {\r
                                Write-Host "Could not create directory $backupTarget`: $_.Exception.Message"\r
                        }\r
                        catch {\r
                                Write-Host "Could not create directory $backupTarget`: $_.Exception.Message"\r
@@ -228,7 +228,7 @@ if($errorMessages.Count -eq 0) {
                                Write-Host "Creating directory $backupTargetFull"\r
                                \r
                                try {\r
                                Write-Host "Creating directory $backupTargetFull"\r
                                \r
                                try {\r
-                                       New-Item -ItemType directory -Path $backupTargetFull -ErrorAction Stop\r
+                                       New-Item -ItemType directory -Path $backupTargetFull -ErrorAction Stop | Out-Null\r
                                }\r
                                catch {\r
                                        Write-Host "Could not create directory $backupTargetFull`: $_.Exception.Message"\r
                                }\r
                                catch {\r
                                        Write-Host "Could not create directory $backupTargetFull`: $_.Exception.Message"\r

patrick-canterino.de