- [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
$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
- 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
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
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
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