<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/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>Search results for 'sectionid:230' matching tags 'Powershell' and 'If'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=sectionid%3A230&amp;tag=Powershell%2CIf&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'sectionid:230' matching tags 'Powershell' and 'If'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Powershell bug or is it working as designed?</title><link>http://powershell.com/cs/forums/thread/15307.aspx</link><pubDate>Tue, 13 Mar 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:15307</guid><dc:creator>freakling</dc:creator><description>&lt;div&gt;
&lt;div&gt;I&amp;#39;ll start off explaining the scenario.&lt;/div&gt;
&lt;div&gt;i&amp;#39;m using a get-permissions &amp;gt; XML in another script.&lt;/div&gt;
&lt;div&gt;I&amp;#39;m then using a if to read which permissions to set.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;$delegation = &amp;lt;array of all accounts nestled in xml&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;of the 7 trustees i have nestled the first two are gpocustom, and the last two are wellknowngroup&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;The following code snippet should work, but it does not.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; foreach($account in $delegation){&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; $GPtrustee = $account.Trustee&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; $GPType = $account.TrusteeType&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; $GPPermission = $account.Permission&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; if(($GPPermission -ne &amp;quot;GpoCustom&amp;quot;) -or ($GPType -ne &amp;quot;WellKnownGroup&amp;quot;)){&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Allow&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;##########&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; else{&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;Disallow&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;##########&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;This code snippet returns&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;However, if i change the order to allow it works&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;quot;if(($GPPermission -eq &amp;quot;GpoCustom&amp;quot;) -or ($GPType -eq &amp;quot;WellKnownGroup&amp;quot;))&amp;quot;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Or if i change the &amp;quot;-or&amp;quot; to a &amp;quot;-and&amp;quot; it works.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;quot;if(($GPPermission -ne &amp;quot;GpoCustom&amp;quot;) -and ($GPType -ne &amp;quot;WellKnownGroup&amp;quot;))&amp;quot;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Allow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;Disallow&lt;/div&gt;
&lt;div&gt;##########&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;It would seem as if the double negative operators are screwing up the -or operator.&lt;/div&gt;
&lt;div&gt;Is this design or is it a PS bug?&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Thanks in advance&lt;/div&gt;
&lt;div&gt;Freakling&lt;/div&gt;</description></item></channel></rss>