Get-DlpDetailReport -DlpCompliancePolicy “Default DLP Monitoring Policy” -DlpComplianceRule “Confidential Label Monitoring” -StartDate “08/1/2022 00:00” -EndDate “08/11/2022 23:59” -PageSize 5000 -EventType DLPRuleHits | where {$_.DlpComplianceRule -eq “Confidential Label Monitoring”} | Select-Object Date, Title, Actor, DlpComplianceRule, Recipients, AttachmentNames | Export-Csv “ConfidentialLabelMonitoring.csv”
I want to set this command to clipboard I Tried using the Set clipboard activity but it is returning Errors
Kindly Help
1 Like
Hi @Ishan_Shelke ,
Could you let us know what were the errors that you received ?
It’s Giving the Error as Expression Expected. Basically I am not able to set this command in the Set to clipboard Activity
@Ishan_Shelke ,
I believe you are directly using the command in the Set Clipboard
Activity.
As an alternate can you place the command in a Text file and read the text file into a String variable and then use the String variable in the Set Clipboard
Activity ?
If you have variables to use, we can also use placeholders for that purpose and then replace the placeholders with the variable values.
Let us know if you have tried this or if you strictly want to enter the value directly in the activity.
Okay This Way Worked, Only Problem My Dates Change Everyday when I fire this Command Everyday How Do I tackle This
@Ishan_Shelke , As I had mentioned we can use placeholders in places where the date value is to be placed and then use Replace method to replace the placeholders with Date value.
If you could provide what are the changing values in the command, we can modify the command statement accordingly.
ppr
(Peter)
August 12, 2022, 10:33am
7
whenever you have a " inside your string you will escape it with " to “”
first is failing
second is escaping
\ is visual and not part of the string
To Be Exact I want the Start Date to be as The First Day of the Current Month and the End Date as the Last Day of the Current Month
Additional Catch I also need the time
For Example The Current Month is August
So My Start Date would Look like 08/01/2022 00:00
And My End Date would Look Like 08/31/2022 23:59
So My Final Command for this Month Should Look Like
Get-DlpDetailReport -DlpCompliancePolicy “Default DLP Monitoring Policy” -DlpComplianceRule “Confidential Label Monitoring” -StartDate “08/01/2022 00:00” -EndDate “08/31/2022 23:59” -PageSize 5000 -EventType DLPRuleHits | where {$_.DlpComplianceRule -eq “Confidential Label Monitoring”} | Select-Object Date, Title, Actor, DlpComplianceRule, Recipients, AttachmentNames | Export-Csv “ConfidentialLabelMonitoring.csv”
@Ishan_Shelke ,
I assume you are already keeping the Command in a text file and reading it using Read Text File
Activity.
In that case, you need to modify your command in the below way :
Get-DlpDetailReport -DlpCompliancePolicy "Default DLP Monitoring Policy" -DlpComplianceRule "Confidential Label Monitoring" -StartDate "#StartDate#" -EndDate "#EndDate#" -PageSize 5000 -EventType DLPRuleHits | where {$_.DlpComplianceRule -eq "Confidential Label Monitoring"} | Select-Object Date, Title, Actor, DlpComplianceRule, Recipients, AttachmentNames | Export-Csv "ConfidentialLabelMonitoring.csv"
As you can see from the above, I have replaced the date values with the placeholders #StartDate#
and #EndDate#
We can simply calculate the start and end dates of the current month in the below way :
startDate = Now.AddDays(-Now.Day+1).ToString("MM/dd/yyyy 00:00")
endDate = (new DateTime(Now.Year,Now.Month,DateTime.DaysInMonth(Now.Year,Now.Month))).ToString("MM/dd/yyyy 23:59")
startDate
and endDate
are String variables. Notice the Time is also handled, as you would require it in that format.
At the End we can just replace the Placeholder values with the startDate
and endDate
variables
command = command.Replace("#StartDate#",startDate).Replace("#EndDate#",endDate)
here command
is a string variable which contains the command from text file.
Let us know if this doesn’t work.
system
(system)
Closed
August 16, 2022, 5:10am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.