Running powershell script from sql agent job step

  • Is this a bug or am I missing something? I created a sql agent job that runs a powershell command. It basically checks for a file and deletes it. Fairly simple. I ran the job and it runs successfully, but when you check the file, its still there.

    I poke a run abit and finally added the SqlServerSQLAgentUser$xxx group to the folder and now when I ran it, it work. It seems logical that I need to add the security group, but what's not logical is why the job ran successfully. Shouldn't the job failed as it would have encountered a security error? You can verify this interactively by logging onto the server with the sql agent service account. Anybody seen this?

    $Database = "DataFile"

    $DatabaseFilePath = "H:\SqlBackup\"

    $DatabaseBackupDescription = ""

    #remove old file

    If (Test-Path ($DatabaseFilePath + $Database + ".cbak.02")) {Remove-Item ($DatabaseFilePath + $Database + ".cbak.02")}

    I

  • I think this is more of a security question and so I will re-post this in the sql security section.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply