Terminating Errors Added

Added checks to ensure that the script is being ran on a domain-joined machine and with a domain account.
This commit is contained in:
Chris Campbell 2013-07-03 20:31:53 -04:00
parent 371c65c9a7
commit eb85e1ce9d
1 changed files with 5 additions and 1 deletions

View File

@ -60,6 +60,10 @@
catch {Write-Error "$Error[0]"} catch {Write-Error "$Error[0]"}
} }
#ensure that machine is domain joined and script is running as a domain account
if (((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False) {throw 'Machine is not joined to a domain.'}
if (($Env:USERDNSDOMAIN) -eq $Null) {throw 'Account is not a domain account.'}
#discover potential files containing passwords #discover potential files containing passwords
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -Include 'groups.xml','services.xml','scheduledtasks.xml','datasources.xml' $XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -Include 'groups.xml','services.xml','scheduledtasks.xml','datasources.xml'
@ -123,4 +127,4 @@
catch {Write-Error $Error[0]} catch {Write-Error $Error[0]}
} }
} }