New to LM: How do I refer to the local filesystem in an embedded PowerShell script of a DataSource?
How do I refer to the local filesystem in an embedded PowerShell script of a DataSource? The below works fine from a PowerShell session console on a Collector server, but fails when running embedded in LogicMonitor. The Active Directory LogicMonitor service account is in the local Administrators group on the Resource server (a LM Collector server in this), same as my admin account using the PowerShell session. It also has explicit NTFS "Full Control" rights on the folder in the path variable below.
Do I have to use the Get-PSDrive cmndlet? Or is there a simple way to do it when running embedded in the LogicMonitor environment?
$textFilePath = 'C:\ps\LM-custom_list.txt' $localList = Get-Content -Path $textFilePath
-Steve
Yes, and you see it worked for me in my screenshot with a full path. The only thing I'm aware of that LM will do to a powershell script is do a search-and-replace of ##TOKEN## but I didn't see any of that in your code. Even your error message isn't show the path getting screwed up and it's powershell telling you the file doesn't exist there.
I would 100% make sure the script is actually running on the server you think it's running on. Does "Write-Output $env:computername" show the name of the server with the file?