<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Convert system.string to .....</title><link>https://communities.bentley.com/products/projectwise/f/projectwise-powershell-extensions-forum/189659/convert-system-string-to</link><description>Cannot convert the &amp;quot;riler&amp;quot; value of type &amp;quot;System.String&amp;quot; to type &amp;quot;Bentley.ProjectWise.PowerShell.Common.User&amp;quot; 
 
 I get this message when I try to create this 
 
 $Users = Get-PWUsersByMatch | select-object name 
 foreach ($User in $Users) { 
 Get-PWUserSettingByUser</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/572867?ContentTypeID=1</link><pubDate>Fri, 06 Mar 2020 20:52:53 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:4e2485b9-8d90-49dd-b82c-123aaccb558a</guid><dc:creator>Luc Poulin</dc:creator><description>&lt;p&gt;Thank you....&lt;/p&gt;
&lt;p&gt;And I was hoping&amp;nbsp;I was getting&amp;nbsp;&amp;nbsp;my coding skills up one notch.&amp;nbsp;Looks like it&amp;#39;s more a little tiny fraction of a notch........&lt;/p&gt;
&lt;p&gt;Thank&amp;nbsp;you again&amp;nbsp; Kevin, have a good weekend&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/572856?ContentTypeID=1</link><pubDate>Fri, 06 Mar 2020 19:37:23 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:da5b3aea-fe2a-4017-acb2-2018895f5b05</guid><dc:creator>Kevin van Haaren</dc:creator><description>&lt;p&gt;hmmm, I think you need a bit more info on objects and properties.&lt;/p&gt;
&lt;p&gt;In Powershell an object is a type of data. In this case user data.&amp;nbsp;Objects have properties associatied with them. These properties are accessed via dot notation.&lt;/p&gt;
&lt;p&gt;of If you got data on one user:&lt;/p&gt;
&lt;p&gt;$user = Get-PWUsersByMatch -email &amp;#39;user@example.com&amp;#39;&lt;/p&gt;
&lt;p&gt;and then just typed:&lt;/p&gt;
&lt;p&gt;$user&lt;/p&gt;
&lt;p&gt;you&amp;#39;d see the properties for that user:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CreationDate     : 1/1/0001 12:00:00 AM
LastLogin        :
Description      : Example User
Disabled         : False
IsDisabled       : False
Email            : user@example.com
ID               : 1
UserID           : 1
IsConnected      : False
Name             : user
UserName         : user
SecProvider      :
Type             : Logical
Identity         :
IdentityProvider :&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So the value of $user.ID is an integer which is what Get-PWUsersByMatch -UserID expects&lt;/p&gt;
&lt;p&gt;However $user is still an object, not an integer. Additionally the Select statement creates a new object with just the selected properties, so:&lt;/p&gt;
&lt;p&gt;$user = Get-PWUsersByMatch -email &amp;#39;user@example.com&amp;#39; | Select ID&lt;/p&gt;
&lt;p&gt;$user is still an object with a single property called ID. so&lt;/p&gt;
&lt;p&gt;Get-PWUsersByMatch -UserID $user&lt;/p&gt;
&lt;p&gt;fails because $user is an object, not an integer. $user.id the value of the property is an integer and would work.&lt;/p&gt;
&lt;p&gt;(when your Get-PWUsersByMatch returns multiple users they are grouped into an array and the foreach is just breaking the array up so you can work on individual users.&lt;/p&gt;
&lt;p&gt;Now, there are some tools in PowerShell that make what you&amp;#39;re trying to do much easier. First, Select allows you to specify multiple properties to keep in one command. 2nd you&amp;nbsp;can do many bulk commands on a group of an object without breaking them up in a foreach loop.&lt;/p&gt;
&lt;p&gt;So for what it appears you are trying to do you can smash it down into a single line:&lt;/p&gt;
&lt;p&gt;$dt = Get-PWUsersByMatch | Select Name,Description,Email&lt;/p&gt;
&lt;p&gt;$dt will now be an array of objects where each object has 3 properties: Name, Description and Email.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/572844?ContentTypeID=1</link><pubDate>Fri, 06 Mar 2020 18:46:42 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:a65a3aa0-1fa6-4029-b15e-fc6ef782475c</guid><dc:creator>Luc Poulin</dc:creator><description>&lt;p&gt;Hello Kevin&lt;/p&gt;
&lt;p&gt;I try to apply the lesson from the previous code&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;laquo;...it&amp;#39;s because of the select statment when creating $users. you&amp;#39;re stripping out all the other properties...&amp;raquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I may have miss something.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I got this to create a list&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$Users&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Get-PWUsersByMatch&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;And I also try ( just&amp;nbsp;in case)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$Users&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Get-PWUsersByMatch&lt;/span&gt; | select-Object ID&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then I try to create a foreach item in the list&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span style="color:#00008b;font-family:Lucida Console;font-size:xx-small;"&gt;foreach&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; (&lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$User&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#00008b;font-family:Lucida Console;font-size:xx-small;"&gt;in&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$Users&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;){ &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dr&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dt&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;NewRow()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dr&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;Name &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Get-PWUsersByMatch&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#000080;font-family:Lucida Console;font-size:xx-small;"&gt;-UserID&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$User&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;|&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Select-Object&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#8a2be2;font-family:Lucida Console;font-size:xx-small;"&gt;Name &lt;/span&gt;&lt;span&gt;(then I have the same message as before &lt;em&gt;***&lt;/em&gt;......)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dr&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;Description &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Get-PWUsersByMatch&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#000080;font-family:Lucida Console;font-size:xx-small;"&gt;-UserId&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$User&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;|&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Select-Object&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#8a2be2;font-family:Lucida Console;font-size:xx-small;"&gt;Description&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dr&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;Email &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;=&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Get-PWUsersByMatch&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#000080;font-family:Lucida Console;font-size:xx-small;"&gt;-UserId&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$User&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;|&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;font-family:Lucida Console;font-size:xx-small;"&gt;Select-Object&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt; &lt;/span&gt;&lt;span style="color:#8a2be2;font-family:Lucida Console;font-size:xx-small;"&gt;email&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dt&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;Rows&lt;/span&gt;&lt;span style="color:#a9a9a9;font-family:Lucida Console;font-size:xx-small;"&gt;.&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;Add(&lt;/span&gt;&lt;span style="color:#ff4500;font-family:Lucida Console;font-size:xx-small;"&gt;$dr&lt;/span&gt;&lt;span style="font-family:Lucida Console;font-size:xx-small;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;**** Get-PWUsersByMatch : Cannot bind parameter &amp;#39;UserId&amp;#39;. Cannot convert the &amp;quot;Bentley.ProjectWise.PowerShell.Common.User&amp;quot; value of type &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;Bentley.ProjectWise.PowerShell.Common.User&amp;quot; to type &amp;quot;System.Int32&amp;quot;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any chance you can give a hand on this too?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/558525?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 22:56:30 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:747d2dc3-151a-48f0-a498-4b282a15c868</guid><dc:creator>Kevin van Haaren</dc:creator><description>&lt;p&gt;oh, it&amp;#39;s because of the select statment when creating $users. you&amp;#39;re stripping out all the other properties. I missed that first time&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;$users = Get-PWUsersByMatch
foreach ($user in $users) {
    Get-PWUserSettingByUser -InputUsers $user -SettingName WorkDir_WhenUsingPWExplorer
}

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/558524?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 22:52:04 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:468699b4-cee9-4170-9c5b-75963a24cf81</guid><dc:creator>Luc Poulin</dc:creator><description>&lt;p&gt;Same result&lt;/p&gt;
&lt;p&gt;Maybe my programmer skills still need&amp;nbsp;to be polish :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/343592/001.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert system.string to .....</title><link>https://communities.bentley.com/thread/558523?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 22:30:46 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:8b76ed1d-749c-497b-872d-fe600ed7ad44</guid><dc:creator>Kevin van Haaren</dc:creator><description>&lt;p&gt;Generally the pwps_dab parameters that start with -Input take the full object, not a part of it.&amp;nbsp; So just feed it $User&lt;/p&gt;
&lt;p&gt;Get-PWUserSettingByUser -InputUsers &lt;strong&gt;$User&lt;/strong&gt; -SettingName WorkDir_WhenUsingPWExplorer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>