Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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
Solved! Go to Solution.
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 }
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:
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 }
I include .exe always because it avoids powershell aliases
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.
oh, and of course you can use any command like createissue or editissue in similar ways to what is shown above.