Orchestration powershell activity returning "Access to path denied" for file creation on local host

Todor
Kilo Contributor

Hi all,

I've created a custom PowerShell activity with a simple purpose of saving a txt file on the server, where MID server resides. I'm using the MID server credentials and I've tested the PowerShell command locally:

 

New-Item -path $path -Name $file -Value "$data" -ItemType file -force

 

Now, everytime I'm testing this from ServiceNow, I'm getting this:

{
    "hresult": "-2147024891",
    "output": "\n",
    "errorMessages": "Access to the path 'C:\\temp' is denied.Stack Trace:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)at Microsoft.PowerShell.Commands.FileSystemProvider.NewItem(String path, String type, Object value)\n",
    "debugMessages": null,
    "credentialDebugInfo": "2018-08-03 15:47:59 Tried credential: MID service account, status=?\r\n",
    "eccSysId": "604db84c4f3713001521e321a310c74b",
    "tags": {
        "__text__": "\n"
    }
}

 

Please help. Is there a specific place to save files on local host? Is it forbidden totally? I've managed to print from an activity to local printer and managed to retrieve system wmi services flawlessly - all using the MID server credentials, which are local administrator user.

Any ideas?

 

5 REPLIES 5

I think you need to edit the mid server service (in your windows server you can access with services.msc) with the discovery_user credential so that that service can run under this credential.

 

You can google it to find how to make that change.

 

After doing it, please try once again and let me know the result.