How can I filter Submitted list by multiple user in Perforce? - perforce

How can I filter the "Submitted" view by multiple users in perforce?
I want to just see only a few(4-5?) people in the "Submitted" view.
There is a filter function, but filter doesn't take multiple users.
So, can I specify multiple users in the "Submitted" view at perforce?

You are right, there doesn't seem to be a way to accomplish this in either p4v (the GUI) or p4 (CLI). Your best bet is to pass this as a feature request to the excellent perforce support.

I have created a power shell script that could be helpful.
It filters for a specific user, date and you can chose the last number of entries you want to search within (this accelerates the command return).
The result is shown in a power shell grid window which helps you to sort the result entries.
Please feel free to modify variables for your requirements:
$date1 = Get-Date -UFormat "%Y/%m/%d" #today
#$date1 = "2013/09/11" #other day
$users = "user1|user2|user3"
$title = "Submitted changes on: "+$date1+" and users: "+$users
$maxLines = 100
Write-host -foregroundcolor 'cyan' $title
$out = (p4 changes -t -s submitted -m 512 | select-string -Pattern $users | select-string -Pattern $date1)
$out | Select-Object LineNumber,Line,Matches | Out-GridView -Title $title -PassThru
Ihsan

Ok... Just my two cents:
I wanted to filter the submitted list to avoid changelists from other projects on the same P4 server. I tried to filter by user at first, but no luck, just like you.
But! I finally achieved what I wanted by filtering by file path. That way, only my project is visible. I find this quite usefull, as it will show any activity from someone I didn't expect on my project. It's event better than filtering by name. In ma specific case at least.
It doesn't answer the question directly, but it fix the problem I did face :)

Pipe the output to another filter such as grep. For example,
p4 changes -s submitted | egrep "^[^#]* (tom|dick|harry)#"
You may need to modify the regular expression to suit your output format. The ^[^#]* prevents false positives such as tom# in the summary.

Related

Need to parse thousands of files for thousands of results - prefer powershell

I am getting consistently pinged from our government contract holder to search for IP addresses in our logs. I have three firewalls, 30 plus servers, etc so you can imagine how unwieldy it becomes. To amplify the problem, I have been provided a list of over 1500 IP addresses for which I am to search all log files...
I have all of the logs downloaded and can use powershell to go through them one by one but it takes forever. I need to be able to run the search using multi-thread in Powershell but cannot figure out the logic to do so. Here's my one by one script...
Any help would be appreciated!
$log = (import-csv C:\temp\FWLogs\IPSearch.csv)
$ip = ($log.IP)
ForEach($log in $log){ Get-ChildItem -Recurse -path C:\temp\FWLogs -filter *.log | Select-String $ip -List | Select Path
}

Determine Nemo context menu actions ordering

I am having the following problem / question
and I am seeking for help / answers here. :)
I am using Debian 9 with Cinnamon UI and it works fine so far.
I recently started to get myself familiar with the nemo
actions, in order to extend the context menu with my entries.
While this works, I could not figure out how to determine
in which order the menu points are shown.
I tried the common method of using two-digit starts for the .nemo_action files (like for udev rules etc), changing zhe action names, ....
However, I could not figure out what algorithm is behind this
Can anyone shed some light on this?
I can even live with an answer like: “you need to modify the code here...”
The only thing I found on the internet so far:
https://forums.linuxmint.com/viewtopic.php?t=178757
Thanks in advance.
O.K., found it...nemo_action_manager.c, set_up_actions():
file_list = nemo_directory_get_file_list (directory);
// AlexG: List seems to be retrieved unsorted, so let's sort it.
// Then the order of menu items is == alphabetical order of nemo action file names
file_list = g_list_sort(file_list, _cbSortFileList);
[...]
I obtained a small bash script mints nemo github that allow sorting of Nemo Actions based on name; on demand. The default order is by modification date.
Below you find the script to sort actions and to set the order i named them alphabetically.
#!/bin/bash
if ! zenity --question --no-wrap --icon-name="folder" --title="Sort Nemo Actions?" --no-wrap --text="Sorting actions will close down all existing nemo instances.\n\nWould you like to proceed?"; then
exit 1
fi
mkdir -p /tmp/actions/
mv "$HOME"/.local/share/nemo/actions/*.nemo_action /tmp/actions/
ACTIONS=$(find /tmp/actions -iname '*.nemo_action' | sort -n)
for i in $ACTIONS; do
touch "$i"
done
mv /tmp/actions/*.nemo_action "$HOME"/.local/share/nemo/actions/
nemo -q
nemo-desktop -q
nemo-desktop & disown

Trying to Export a CSV list of users using Active Directory Module for Windows Powershell

So the below is where I'm at so far:
import-module activedirectory
$domain = "ourdomain"
Get-ADUser -Filter {enabled -eq $true} -Properties whenCreated,EmailAddress,CanonicalName |
select-object Name,EmailAddress,CanonicalName,whenCreated | export-csv C:\Data\test.csv
Unfortunately, when I run the above I get dates in two different formats in the CSV, e.g.:
01/01/2017
1/01/2017 8:35:56 PM
The issue this poses is that there isn't really a clean way to sort them. Excel's formatting doesn't change either of these formats to be more like the other, both because of the inclusion of time in one and not the other, and because the time-inclusive format doesn't use trailing zeroes in the single digit numbers, but the time-exclusive format does.
We have an existing script that captures users using the LastLogonTimestamp attribute that does this correctly by changing the bottom line to the following:
select-object Name,EmailAddress,CanonicalName,#{Name="Timestamp"; Expression={[DateTime]::FromFileTime($_.whenCreated).ToString('yyyy-MM-dd_hh:mm:ss')}}
For some reason this expression runs properly when we query the LastLogonTimestamp attribute, but when we run this version querying the whenCreated attribute, we get an entirely blank column underneath the Timestamp header.
I'm not particularly knowledgeable about PowerShell itself, and my colleague who had found the original script for the LastLogonTimestamp just found it online and adapted it as minimally as possible to have it work for us, so I don't know if something in this line would work properly with one of these attributes and not the other. It seems strange to me though that two attributes using dates in the same program would store them in different formats though, so I'm not convinced that's it.
In any case, any help anyone can offer to help us get a uniform date format in the output of this script would be greatly appreciated - it needn't have the time included if it's easier to do away with it, though if they're equally easy we may as well keep it.
whencreated is already a [DateTime]. Notice the difference between the properties when you run something like this:
Get-ADUser TestUser -Properties lastlogon,whenCreated | select lastlogon,whenCreated | fl
(Get-ADUser TestUser -Properties lastlogon).lastlogon | gm
(Get-ADUser TestUser -Properties whenCreated).whenCreated | gm
This means that you don't have to convert to a DateTime before running the toString() method.
select-object #{Name="Timestamp"; Expression={$_.whenCreated.ToString('yyyy-MM-dd_hh:mm:ss')}}

How to get name of a USB device that is already mounted?

I'm actually writing a node script that detect if a specific USB is plugged, then it copy it content to Desktop. This is for Windows principally. To do this I manually check if 'E:\' path exists , 'F:\' , etc...
But I need to be sure that devices are the ones that I need. They got specific names, for example:
MTR12345 or MTR23RR5 or MTRTGX23.
And I need to know theses names. I searched for differents nodejs and powershell solutions but no ones fit my needs.
I need to get the name of the device that is mounted at E:\ . I'm totally new to PowerShell and NodeJS as well.
How can I do this ? Thanks for your help.
Sounds like you are just looking for the volume names. The WMI class Win32_logicaldisk would return that for mounted devices. Assuming it was populated of course. In it's simplest form:
Get-WmiObject Win32_logicaldisk | Where-Object{$_.VolumeName -eq "MyUSBKey"}
You have some specific examples and a regex query that you are trying to use to narrow down the results. So if you want to match a regex query:
Get-WmiObject Win32_logicaldisk |
Where-Object{Where-Object{$_.VolumeName -match "MTR[A-Za-z0-9]+"}} |
Select -Expand DeviceID
You could even simplify that if you wanted. Just match volumes that start with "MTR". Not as perfect as the other one but just as simple.
Get-WmiObject Win32_logicaldisk |
Where-Object{Where-Object{$_.VolumeName -match "^MTR"}} |
Select -Expand DeviceID

replace string if you dont' know rest of string in PowerShell

Please help. Trying to figure out how to replace a string in PowerShell, but don't know the rest of the string. I have this:
(Get-Content $file) -replace[regex]::Escape('file='*''),('file='+$_.BaseName) | Set-Content $file
I don't know what comes after file=
I tried my code, but it replaces it multiple times instead of just once.
So trying to replace file=* with filename=$_.BaseName.
Thanks for looking.
Just an FYI for anyone using the latest version of PowerShell Community Extensions (http://pscx.codeplex.com), there is a new command called Edit-File that handles this sort of thing nicely (works hard to preserve the file's original encoding):
Get-Item test.txt | Foreach {$bn=$_.BaseName; $_} |
Edit-File -Pattern '(file=).*' -Replace "`${1}$bn"
In theory I shouldn't need the Foreach stage but it seems I've found a limitation in how -PipelineVariable does not work with parameters that aren't pipeline bound. Hmm, add that to the Pscx backlog.

Resources