Advertisement
Guest User

Untitled

a guest
Sep 10th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #This script requires Powershell, sqlplus aka Oracle command line client and tnsname resolution of your target databases
  2. #A typical use case would be to find the lock status of an account in multiple databases
  3. $databases = @("fndev", "fntst")
  4. $credential = Get-Credential
  5. $username = $credential.GetNetworkCredential().username
  6. $password = $credential.GetNetworkCredential().password
  7. if (!$password) { Write-Host "password is null"; Exit }
  8.  
  9. foreach ($db in $databases)
  10. {
  11. $sqlQuery = @"
  12. set NewPage none
  13. set heading off
  14. set feedback off
  15. select count(*) from psoprdefn where oprid='PS' and ACCTLOCK = '0';
  16. exit
  17. "@
  18. write-host -nonewline -f yellow $db
  19. $sqlQuery | sqlplus -silent $username/$password@$db | write-host
  20. write-host
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement