Skip to content

Commit

Permalink
ad: avoid error if backup file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrezina committed Jan 4, 2024
1 parent 4efa65b commit 0553e91
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sssd_test_framework/hosts/ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ def backup(self) -> None:
"""
self.ssh.run(
rf"""
Remove-Item C:\multihost_backup.txt
$result = Get-ADObject -SearchBase '{self.naming_context}' -Filter "*"
foreach ($r in $result) {{
$r.DistinguishedName | Add-Content -Path C:\multihost_backup.txt
}}
"""
$backup = "C:\multihost_backup.txt"
if (Test-Path $backup) {{
Remove-Item $backup
}}
$result = Get-ADObject -SearchBase '{self.naming_context}' -Filter "*"
foreach ($r in $result) {{
$r.DistinguishedName | Add-Content -Path $backup
}}
"""
)
self._backup_location = "C:\\multihost_backup.txt"

Expand Down

0 comments on commit 0553e91

Please sign in to comment.