<?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>New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/products/projectwise/f/projectwise-powershell-extensions-forum/169795/new-pwdocumentversion-error-exception-handling</link><description>I am using New-PWDocumentVersion cmdlet as part of a script to synchronize DGN files on a server drive with the respective holdings on ProjectWise. 
 To deal with problems and exceptions in my script I have the following set: 
 $ErrorActionPreference</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/492137?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 13:24:15 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:4a5bc0b9-044d-4d06-a2dd-7863a9c76d68</guid><dc:creator>Brian Flaherty</dc:creator><description>&lt;p&gt;The New-PWDocumentVersion cmdlet has been updated to return a more informative message if/when and error occurs. Look for the update in a future release of the PWPS_DAB module.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/491341?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 13:48:13 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:48fb5d35-023e-49f8-abfe-d8f05c4e8758</guid><dc:creator>Dean Lyon</dc:creator><description>&lt;p&gt;I have the same issue with Update-PWDocumentAttributes.&amp;nbsp; &amp;nbsp;It will start to fail over and over, failing to allocate memory around the 30,000th document process. However, instead of triggering the try catch, it continues until PowerShell hangs and quits.&amp;nbsp; I tried it with and without the&amp;nbsp;-ErrorAction Stop.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/491254?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 09:08:12 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:22c1cda0-2e01-423b-ad9b-d4ec9a9c817a</guid><dc:creator>Jim Turner</dc:creator><description>&lt;p&gt;I am managing thousands of documents.&amp;nbsp; Today, when using PowerShell to create new document versions using &lt;em&gt;New-PWDocumentVersion&lt;/em&gt;, two documents out of a thousand failed (for no explicable reason).&amp;nbsp; The only notification is an error printed to screen:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Error changing document &amp;#39;XXX.dwg&amp;#39; to new version &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because it&amp;#39;s not raised as an exception I cannot detect the error and the next command in my script overwrites the old version and &lt;b&gt;the previous&amp;nbsp;data is lost&lt;/b&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How do I detect these errors?&amp;nbsp; I need an&amp;nbsp;update on this please, because as it stands now I will have to stop using PowerShell.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/488197?ContentTypeID=1</link><pubDate>Mon, 29 Oct 2018 11:22:24 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:fc1f34a0-c4d6-41e4-8f54-43ea0fb12241</guid><dc:creator>Jim Turner</dc:creator><description>&lt;p&gt;This is another example where a&amp;nbsp;command has&amp;nbsp;failed but not raised an exception in the expected way.&amp;nbsp; This time using the Set-PWDocumentState cmdlet.&amp;nbsp;&amp;nbsp;Is there a way to capture/detect these errors and then stop the script running?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="background-color:blue;color:white;"&gt;PS C:\WINDOWS\system32&amp;gt; Get-PWDocumentsBySearch -FolderPath $pwfolder -FileName $theFile&amp;nbsp; | Set-PWDocumentState -State $stateShared | out-null&lt;/p&gt;
&lt;p style="background-color:blue;color:white;"&gt;Failed to change state to &amp;#39;Shared&amp;#39; for &amp;#39;XXXX.dgn&amp;#39;. &lt;strong&gt;Error: 58268&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/487531?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 08:27:20 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:58ec01d8-275d-42f4-b42b-e0fa3105ef9e</guid><dc:creator>Jim Turner</dc:creator><description>&lt;p&gt;I have recreated the &lt;em&gt;source&lt;/em&gt; of the error: the&amp;nbsp;&lt;span&gt;$verString was&amp;nbsp;invalid as it was identical to the current version.&amp;nbsp; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However this request is rather to to ask that when errors happen they are correctly raised as exceptions so that they can be detected.&amp;nbsp; See this try-catch which fails to catch the error:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/343592/Bentley_5F00_PWnewVersionError2.png" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: New-PWDocumentVersion Error/Exception Handling</title><link>https://communities.bentley.com/thread/487379?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 16:16:17 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:6354c79b-1d3f-4816-b106-cfb9de1857a3</guid><dc:creator>Brian Flaherty</dc:creator><description>&lt;p&gt;Can you checkout the document you are attempting to create a new version for?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>