{"action":"created","issue":{"url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/2480","repository_url":"https://api.github.com/repos/sqlcollaborative/dbatools","labels_url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/2480/labels{/name}","comments_url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/2480/comments","events_url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/2480/events","html_url":"https://github.com/sqlcollaborative/dbatools/issues/2480","id":267220372,"number":2480,"title":"Copy-DbaAgentAlert not recognizing jobs on destination","user":{"login":"CharterSteel","id":27444214,"avatar_url":"https://avatars0.githubusercontent.com/u/27444214?v=4","gravatar_id":"","url":"https://api.github.com/users/CharterSteel","html_url":"https://github.com/CharterSteel","followers_url":"https://api.github.com/users/CharterSteel/followers","following_url":"https://api.github.com/users/CharterSteel/following{/other_user}","gists_url":"https://api.github.com/users/CharterSteel/gists{/gist_id}","starred_url":"https://api.github.com/users/CharterSteel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CharterSteel/subscriptions","organizations_url":"https://api.github.com/users/CharterSteel/orgs","repos_url":"https://api.github.com/users/CharterSteel/repos","events_url":"https://api.github.com/users/CharterSteel/events{/privacy}","received_events_url":"https://api.github.com/users/CharterSteel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-10-20T15:49:54Z","updated_at":"2017-10-24T04:06:26Z","closed_at":null,"author_association":"NONE","body":"\r\n## Bug Report\r\n\r\n### General Troubleshooting steps\r\n\r\n- [ ] Verified running latest release of dbatools?\r\n- [ ] Verified errors are not related to permissions?\r\n- [ ] Can duplicate in new/fresh PowerShell.exe session?\r\n\r\n### Version Information\r\n\r\nUsing Copy_DbaAgentAlerts on \r\n - Operating System (Name|Version): Server 2016\r\nMajor  Minor  Build  Revision\r\n10     0      14393  0  \r\n\r\n - PowerShell Version:   PSVersion                      5.1.14393.1358       \r\n - Get-Module dbatools returns  0.9.72                                                                                                          \r\n \r\n - SQL Server (Edition|Version): Source = sql 2008R2 (10.50.6220.0), \r\n                                                  dest=sql 2017 (14.0.1000.169)\r\n\r\n## Steps to Reproduce\r\nI execute this code:\r\nCopy-DbaAgentAlert -Source mfgSKVdb -Destination zvr_skv_mes1\\mfgSKVdb  -Alert 'Sev. 17 Errors' -Force \r\n\r\nInstead of copying just one alert, it attempts to copy all alerts, but giving a warning that the job does not exist, and then skipping. Here is sample of the results:\r\n\r\nWARNING: [Copy-DbaAgentAlert][09:39:05] Alert [Sev. 17 Errors] has job [SQL Sentry 2.0 Alert Trap] configured as response. The job does not exist on destination . Skipping.\r\nSourceServer      : mfgSKVdb\r\nDestinationServer : zvr_skv_mes1\\mfgSKVdb\r\nName              : Sev. 17 Errors\r\nType              : Agent Alert\r\nStatus            : Skipped\r\nDateTime          : 2017-10-20 09:39:05.421\r\n\r\nThe job does exist, having just copied it over using Copy-DbaAgentJob. I tried with the job enabled/disabled and it made no difference.\r\n\r\n![image](https://user-images.githubusercontent.com/27444214/31829558-3cbde8f0-b583-11e7-92d9-d1977cbcc1d0.png)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/comments/338867302","html_url":"https://github.com/sqlcollaborative/dbatools/issues/2480#issuecomment-338867302","issue_url":"https://api.github.com/repos/sqlcollaborative/dbatools/issues/2480","id":338867302,"user":{"login":"nvarscar","id":30303784,"avatar_url":"https://avatars3.githubusercontent.com/u/30303784?v=4","gravatar_id":"","url":"https://api.github.com/users/nvarscar","html_url":"https://github.com/nvarscar","followers_url":"https://api.github.com/users/nvarscar/followers","following_url":"https://api.github.com/users/nvarscar/following{/other_user}","gists_url":"https://api.github.com/users/nvarscar/gists{/gist_id}","starred_url":"https://api.github.com/users/nvarscar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvarscar/subscriptions","organizations_url":"https://api.github.com/users/nvarscar/orgs","repos_url":"https://api.github.com/users/nvarscar/repos","events_url":"https://api.github.com/users/nvarscar/events{/privacy}","received_events_url":"https://api.github.com/users/nvarscar/received_events","type":"User","site_admin":false},"created_at":"2017-10-24T04:06:26Z","updated_at":"2017-10-24T04:06:26Z","author_association":"CONTRIBUTOR","body":"Hey! Thanks for noticing more issues - that's great! Apparently, a very few people have such alerts as yourself. Would you mind sharing the alerts' code so that I could rig some tests to avoid this issue in future? The best ones would be probably CSMD_SchedDetect, CSRD_NCMR and xferERP_NewSUP.\r\nI do see a couple more issues in the code and I will look into it tomorrow. There is a check to avoid creating a severity when such already exists, but that should not probably account for severity 0 -> a different type of alert, where severity simply wasn't specified. Also, there is probably a need to refresh the SMO object after the severity has been deleted in order to pass the same severity check, but I need to test it properly to be sure."}}
{"actor":{"display_login":"nvarscar"}}