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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to run "im createissue" in MS PowerShell-Script ?

sklemm
5-Regular Member

How to run "im createissue" in MS PowerShell-Script ?


Hi,

I would like to know how to run Integrity-Command "im createissue" in Microsoft PowerShell-Scripts.

For example via the PowerShell-Command "Start-Process" and using "Here-Strings" for the arguments.

So far I had no success with my tests, see used code at the end of this message.

Do you have any code examples or recommendation ?

Best Regards

Stephan

Used code for testing:

Start-Process im createissue -argument @"

--hostname=integrity

--port=xxxx

--user=xxxx

--type="xxxx"

--field="xxxx"

--gui

"@ -NoNewWindow -Wait

ACCEPTED SOLUTION

Accepted Solutions
dhegland
12-Amethyst
(To:sklemm)

Here is a good first thing to do:

    im.exe issues '--query=Quick Query' '--fields=ID,Type,Summary'

The apostrophes are not strictly necessary for all parameters, but in the above example, the query has a space that needs quoting, and the field list has commas.

Every user has a quick query so you know that will work, and ID,Type,Summary are built-in fields.  Now you are off to a start.

You can capture the value of any field into a variable, once you have the id, like this.

   $summary = im.exe issues --fields=Summary $issueid

You can iterate a list of output like this:

   im.exe issues '--query=Quick Query' --fields=ID | foreach { do something in here and use $_ as the id }

View solution in original post

5 REPLIES 5

Hello Stephan Klemm‌,

It looks like within the script you should probably use Invoke-Expression instead of Start-Process, like this:

invoke-expression "& `"$FullPathToIntegrityClientInstallDirectory\bin\im.exe`" createissue --hostname=integrity --port=xxxx --type=`"xxxx`" --field=`"xxxx=value`" --gui" where $FullPathToIntegrityClientInstallDirectory is a variable containing the path to the client install location, or is replaced with the actual full path to the client install directory.

I hope that helps.

Regards,
Kael

References:


Kind Regards,
Kael Lizak

Senior Technical Support Engineer
PTC Integrity Lifecycle Manager
dhegland
12-Amethyst
(To:sklemm)

Here is a good first thing to do:

    im.exe issues '--query=Quick Query' '--fields=ID,Type,Summary'

The apostrophes are not strictly necessary for all parameters, but in the above example, the query has a space that needs quoting, and the field list has commas.

Every user has a quick query so you know that will work, and ID,Type,Summary are built-in fields.  Now you are off to a start.

You can capture the value of any field into a variable, once you have the id, like this.

   $summary = im.exe issues --fields=Summary $issueid

You can iterate a list of output like this:

   im.exe issues '--query=Quick Query' --fields=ID | foreach { do something in here and use $_ as the id }

dhegland
12-Amethyst
(To:dhegland)

I include .exe always because it avoids powershell aliases

dhegland
12-Amethyst
(To:dhegland)

If you really really want to start a new thread you can do so by putting the above examples into arrays of strings and feeding them to invoke-command as Kael suggested and put _that_ within a start-process.

dhegland
12-Amethyst
(To:dhegland)

oh, and of course you can use any command like createissue or editissue in similar ways to what is shown above.

Announcements


Top Tags