hi, can you please let me know does Dataminer script supports PowerShell scripts?
purpose: I am trying to schedule a task that can copy the logging folder weekly to NFS through scripts
$cDate = Get-Date -format yyyy-MM-dd
$NewPath = "\\192.168.10.10\AMS_DTH_A\testams\logs\$cDate"
New-Item -Path $NewPath -ItemType Directory
Copy-Item -Path "C:\Skyline DataMiner\Logging\*" -Destination $NewPath -Recurse
If you have any template script please do share
Thanks
The easiest way to achieve this is by using the supported C# code into DataMiner Automation scripts. The System.IO library can be used to perform similar actions.
Example could be following. Note that the DMA should have permissions on the shared folder.
File.Copy(@"c:\skyline dataminer\info.xml", @"\\LEANDERD\Share\file.xml", true);
It is possible to run PowerShell scripts from a C# block action.
Example:
"{
var ps1File = @"C:\my script folder\script.ps1";
var startInfo = new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-NoProfile -ExecutionPolicy unrestricted -file \"{ps1File}\"",
UseShellExecute = false
};
Process.Start(startInfo);
}"
You can also manage PowerShell Scripts directly:
Adding and invoking commands - PowerShell | Microsoft Docs
The example is pseudo code. It is not made to actually run as code.
You need to follow the C# rules in order to let this work, like adding the needed namespaces.
Also, the pesudo code is based on C# version 8.0
Hi :
Just like to know if i can run my powershell script from C# QAction code?
Also, my powershell prints the output on stdout or a file. If the QAction can run the powershell script how can i get the output into the dataminer element page?
THanks
i tried this script have 5 valid errors!