cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to identify a user in Performance Advisor

JamesAvis
13-Aquamarine

How to identify a user in Performance Advisor

The only user id information I can find in performance advisor, as shown in https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS197086‌, appears to be encrypted.  How can I use this to identify a user?

1 ACCEPTED SOLUTION

Accepted Solutions
STEVEG
21-Topaz I
(To:JamesAvis)

In the startup batch file for Creo I have for everyone I put some lines in to find them and record them.

There is a file (something like Creo_Parametric_2_0_M150.xxxxxxxxxxxxxx.xml) that has it.  It is located in <usersprofile>\AppData\Local\PTC\QualityAgent\UnprocessedFiles.

My batch file looks at this file and searches for the line with "User_ID" and "UUID".  The it outputs it to a text file for me.

View solution in original post

16 REPLIES 16

The idea is to mask the users in a way there is no possibility to conclude back to them.

Hence, the only place where the ID is related to the user, is on the user machine, where it is visible in the PTC Diagnostic Tool (User ID in the application tabs).

Currently for an administrator (or any other legitimate person) to identify users, the users will have to send their UUIDs, so they can be collected.

corrected: UUID on the bottom of System Info is the masked machine ID - User ID, the masked user, is in the header of the application tabs

STEVEG
21-Topaz I
(To:JamesAvis)

In the startup batch file for Creo I have for everyone I put some lines in to find them and record them.

There is a file (something like Creo_Parametric_2_0_M150.xxxxxxxxxxxxxx.xml) that has it.  It is located in <usersprofile>\AppData\Local\PTC\QualityAgent\UnprocessedFiles.

My batch file looks at this file and searches for the line with "User_ID" and "UUID".  The it outputs it to a text file for me.

JamesAvis
13-Aquamarine
(To:STEVEG)

That'll do it, thanks!

byork
17-Peridot
(To:STEVEG)

Steve Galayda‌ would you mind posting the portion of your bat file that collects the User_Id and UUID?

Thanks in advance!

STEVEG
21-Topaz I
(To:JamesAvis)

This may not be the most elegant way to do it but it's work flawlessly so far for me.

cd C:\Users

:: I have a few users that the name of the profile is <username>.<domain name> instead of just <username>

:: So I search for the domain name profile first.

if exist C:\Users\%username%.<domain name>\AppData\Local\PTC\QualityAgent\SentFiles (

set NUP=%username%.<domain name>

goto _IDS

)

if exist C:\Users\%username%\AppData\Local\PTC\QualityAgent\SentFiles (

set NUP=%username%

goto _IDS

)

goto SC

:_IDS

if exist C:\Users\%NUP%\AppData\Local\PTC\QualityAgent\SentFiles (

if exist C:\Users\%NUP%\AppData\Local\PTC\QualityAgent\UnprocessedFiles (

cd C:\Users\%NUP%\AppData\Local\PTC\QualityAgent\UnprocessedFiles

))

for /F %%a in ('dir /B Creo_Parametric*') do set CP=%%a

if not defined CP goto SC

for /F "tokens=1-3 delims=<> " %%b in (%CP%) do (

if %%b==User_ID (

set UID=%%c

))

if not defined UID goto SC

for /F "tokens=1-3 delims=<> " %%i in (%CP%) do (

if %%i==UUID (

set CID=%%j

))

:: This section is to check if the info is already recorded.  If so then skip it.

for /F "tokens=1-3 delims=, " %%a in (<network loc>\_PA_IDs.txt) do (

if /I %%a==%username% (

if /I %%c==%computername% (

goto SC

)))

echo %username%, %UID%, %computername%, %CID% >> <network loc>\_PA_IDs.txt

:SC

Continue with batch file.

byork
17-Peridot
(To:STEVEG)

Awesome!  Thanks so much!

Thanks for this. I do have one question on this though.

What is this section doing?

for /F %%a in ('dir /B Creo_Parametric*') do set CP=%%a

if not defined CP goto SC

I keep getting stalled on this. It runs the first time but the second time it stops the batch file.

It's getting the name of the file that has the Diagnostic Tools user ID and computer ID.

dir /B Creo_Parametric*     list out the bare format of any file that starts with Creo_Parametric

for /F says when it finds the file that starts with Creo_Parametric then set the variable CP to that value.

     So the actual file name is something like: Creo_Parametric_2_0_M170.20150918112008.xml

The last line If not defined CP goto SC means if the variable CP is not defined then go to the section labeled SC.

So you have to have an area in your batch file that labeled like this:

:SC

That is the second to last line I put in my post originally.  Do you have that line?

STEVEG
21-Topaz I
(To:JamesAvis)

*** Update ***

I have had to revise the batch file slightly.

The problem is it seems the UID and UUID value has changed from M150 to M170 for each user and computer.  So instead of this:

for /F "tokens=1-3 delims=, " %%a in (<network loc>\_PA_IDs.txt) do (

if /I %%a==%username% (

if /I %%c==%computername% (

goto SC

)))

I now have this:

for /F "tokens=1-4 delims=, " %%a in (<network loc>\_PA_IDs.txt) do (

if /I %%b==%UID% (

if /I %%d==%CID% (

goto SC

)))

The changes are highlighted in red.  Everything else is the same.

The way it was before was searching for and comparing the username and computername.  So when the UID and UUID changed it wouldn't record the new values since the username and computername are the same.

Mats_Bj
11-Garnet
(To:STEVEG)

Hi

This is an old article, but we have used it for a while with great success. I added "wmic csproduct get name" in our version so we also got the type of machine for each user. That also worked fine until Windows 11 arrived...

 

So, for any interested I have rewritten the script into Powershell instead. As it's my first attempt, it works, but anyone out there can probably improve it.

Here it is (I call it "get_uuid.ps1")

 

# Script to rip out UUID from Creo and send it to a text file. Based on the script below.
# https://community.ptc.com/t5/Performance-Advisor/How-to-identify-a-user-in-Performance-Advisor/m-p/382262#M179%3F&art_lang=en&posno=2&q=collect%20UUID&source=search
# 221230 Converted to Powershell
# 230104 Added OS version

# Set file where to put the result
$NETWORK_LOC='\\file_server\uuids.txt'

# Change to location where thee PTC Diagnostic tool is
cd $env:localappdata\PTC\QualityAgent\SentFiles

# Change the versions below at update
if (Test-Path -Path PTC_Creo_Parametric_7_0_7080.xml){
$CP='PTC_Creo_Parametric_7_0_7080.xml'}
if (Test-Path -Path PTC_Creo_Parametric_7_0_7090.xml){
$CP='PTC_Creo_Parametric_7_0_7090.xml'}
if (Test-Path -Path PTC_Creo_Parametric_9_0_9020.xml){
$CP='PTC_Creo_Parametric_9_0_9020.xml'}

$File = Get-ChildItem -Path $CP
# Search for the User id.
$String = ($File | Select-String -Pattern 'User_ID')
$a,$b,$c,$d = $String -split '[<>]'
$UID = $c
# Search for the Computer id.
$String2 = ($File | Select-String -Pattern 'UUID')
$e,$f,$g,$h = $String2 -split '[<>]'
$CID = $g

#Find OS version
$String3 = (get-wmiobject Win32_Operatingsystem | select Caption).Caption
$i,$j,$k,$l = $String3 -split '[" "]'
$os_version = -join($j, " ", $k)

# Search for the type of computer.
$computer_name = (Get-CimInstance -ClassName Win32_ComputerSystem -Property Model).Name
$machine_type = (Get-CimInstance -ClassName Win32_ComputerSystem -Property Model).Model

# This section is to check if the info is already recorded.  If so then skip it.
$Matches = 'X'
Get-Content $NETWORK_LOC | Where-Object { $_ -match $UID } | Where-Object { $_ -match $CID} | ForEach-Object {$Matches[1]}
if ($Matches -eq 'X'){
	# Finally submit the user and computer data to remote location.
	"$env:username,$UID,$CID,$computer_name,$machine_type,$os_version" | out-file -filepath $NETWORK_LOC -append -Encoding ASCII -Width 200
}

# The End is here

 As a bonus I added the Windows version too in the output.

STEVEG
21-Topaz I
(To:Mats_Bj)

What kind of information can you not get in Windows 11 now?

Mats_Bj
11-Garnet
(To:STEVEG)

I realize now that we added some code ourselves that didn't exist in the original post.

We added "wmic csproduct get name" to get the manufacturer model in the export too. This doesn't work in Windows 11.

 

I also noticed that in our new Power shell script there's some error check in missing. Like if it's a new computer or users the SentFiles folder doesn't exist yet. I'll see if I can add that eventually.

Our old .bat script attached.

 

Sorry for the confusion

Thanks for including the PS script, it looks like you did a great job converting it.  I have been working with PS so it is great to see what you have done.  In case you are curious, here are some comments

  • I didn't know about select-string but that is an awesome and superpowerful cmdlet!  Thanks again for sharing it!
  • $env:ComputerName is an environmental variable that is already available to get the computer name so you don't have to query and store as a separate variable. (similar to $env:username)
  • You could also do an if statement to query the windows version.  Something like this:
    • IF ( $String3 -like '*10*') {$OSm='Win10'} elseif ($String3 -like '*11*') {$OSm='Win11'} else {$osm='other'} ; $OSm
    • -->Win10 (on my machine)
  • Another interesting way to get windows version is:
    • [System.Environment]::OSVersion |Select-Object version -ExpandProperty version | Select-Object -ExpandProperty major
    • -->10 (on my machine)
  • I don't have win11 to test but perhaps you could do something like the following to get the model:
    • Get-ComputerInfo |Select-Object -ExpandProperty csmodel

"When you reward an activity, you get more of it!"

Thanks for the feedback, much appreciated!

 

  • Sometimes things are too easy, of course the existing $env:computername could be used instead, I'll change that.
  • Regarding OS version, it's a little funny as in the Registry in a Windows 11 machine it still says Windows 10. As I understood it, it's to have backward compatibility. Your IF statement looks interesting, I'll try that too.
  • I compared "Get-ComputerInfo" with "Get-CimInstance" and the latter seems to be faster so I'll stick to that.
  • Do you have any tip to check if a folder exist? I mean, in the row where cd is run, there will be problem if that doesn't exist. Ideally it shall just exit the script instead. Probably very simple to solve when you know about it; I'll Google for a solution.
Mats_Bj
11-Garnet
(To:Mats_Bj)

Found that this can be a solution on my problem:

IF (Test-Path $env:localappdata\PTC\QualityAgent\SentFiles)
{cd $env:localappdata\PTC\QualityAgent\SentFiles}
else
{exit}

Test-path is a good solution.  Something like try might work for you too, but I think it will only work if you turn the non-terminating error into a terminating error.  Something like this:

  • Try { $ErrorActionPreference = "Stop"; cd $env:localappdata\PTC\QualityAgent\SentFiles} Catch {exit} Finally {$ErrorActionPreference = "Continue"} 

 

You could also spread it across more than one line for clarity

  • Try {
    • $ErrorActionPreference = "Stop"
    • cd $env:localappdata\PTC\QualityAgent\SentFiles
  • }
  • Catch {exit}
  • Finally {$ErrorActionPreference = "Continue"}

 

This talks about the details:

I thought I used this in a simpler way before but apparently, it was already a "terminating error" that didn't require using the extra variable $errorActionPreference . 

 

Which method you use is probably preference at this point but it is another tool up our sleeves for error handling. 🙂


"When you reward an activity, you get more of it!"
Top Tags