SQLServerCentral.com / Programming / Powershell / Powershell script enhancement / Latest PostsInstantForum.NET v2.9.0SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comSun, 02 Aug 2015 12:45:03 GMT20RE: Powershell script enhancementhttp://www.sqlservercentral.com/Forums/Topic1505157-1351-1.aspxSomething like this?foreach ($CurrentlyProcessingDB in $MyListOfDBs) { if ($ListOfDbsToIgnore -notcontains $CurrentlyProcessingDB) { Do stuff } }Thu, 17 Oct 2013 10:06:29 GMTschleepPowershell script enhancementhttp://www.sqlservercentral.com/Forums/Topic1505157-1351-1.aspxHi everyone.I have a script that works great at the moment. The Script I use checks all SQL servers in a table for the last backup status. It then emails out an exception report for databases missing a full backup etc.As I mentioned script works fine for all databases on the instances being checked.The enhancement I want to do is to amend the script to ignore certain databases that exist in say an exception table.This is the code segment that I think I need to amend.[code="other"]# COMMENT: This script checks every server in the inventory, and gets the databases # that have not been backed up for some time defined by minutes. # An exception report is created and sent to the DBA group.# Loop through the list OF SQL Server instances AND run the CHECK-Backups FUNCTION# against each instance TO get the BACKUP exceptions.Foreach ($sqlServer IN $sqlServers) { $sqlNetworkName=$sqlServer.SQLNetworkName $sqlInstanceName=$sqlServer.instanceName $tcpPort=$sqlServer.tcpPort $strResult="" IF ($sqlInstanceName -ieq 'MSSQLSERVER') { $strResult=(CHECK-Backups "$sqlNetworkName,$tcpPort"$backupType $minutes) IF ($strResult -ne "" { $exceptions=$exceptions + $strResult + "`n" } } ELSE { $strResult=(CHECK-Backups "$sqlNetworkName\$sqlInstanceName,$tcpPort"$backupType $minutes) IF ($strResult -ne "" { $exceptions=$exceptions + $strResult + "`n" } }}[/code]I am guessing I need some kind of table created that holds the databases to be excluded. The Script will then run against all the database in inventory , but then exclude those databases it finds in the exception table.Just not sure on how to code that ??Any help or advice appreciated,Wed, 16 Oct 2013 06:36:50 GMTMickyD