Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SQLDBAWithABeard/accd7f509d431b10349637518db44949 to your computer and use it in GitHub Desktop.
Save SQLDBAWithABeard/accd7f509d431b10349637518db44949 to your computer and use it in GitHub Desktop.
Comparing Arrays in powershell
# There must be a better way to do this
$Sps = $srv.Databases['DBA-Admin'].StoredProcedures.Where{$_.Schema -eq 'dbo'}.Name
$Return.OlaProcs = $true
$I = 4
if($Sps -notcontains 'CommandExecute')
{$I --}
if($Sps -notcontains 'DatabaseBackup')
{$I --}
if($Sps -notcontains 'DatabaseIntegrityCheck')
{$I --}
if($Sps -notcontains 'IndexOptimize')
{$I --}
if($i -lt 4){$Return.OlaProcs = $false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment