tag:blogger.com,1999:blog-78923123152949010542024-03-27T16:54:00.957-07:00Network Audit and Documentation, CENTREL Solutions BlogThis blog is a technical resource for developers and network support engineers and managers as well as providing an insight into the development of our application launcher, network automation and network audit & documentation products. David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.comBlogger426125tag:blogger.com,1999:blog-7892312315294901054.post-21909878000320645872024-03-15T08:43:00.000-07:002024-03-15T08:49:48.013-07:00SOLVED: Get the "connect as" credentials for an IIS web application using the "WebAdministration" PowerShell cmdlets Get-WebApplication<p>When using the <a href="https://learn.microsoft.com/powershell/module/webadministration" rel="nofollow" target="_blank">WebAdministration</a> PowerShell cmdlets <a href="https://learn.microsoft.com/powershell/module/webadministration/get-webvirtualdirectory" rel="nofollow" target="_blank">Get-WebVirtualDirectory</a> the username, password and other virtual directory information as expected.</p><p>However when using the <a href="https://learn.microsoft.com/powershell/module/webadministration/get-webapplication" rel="nofollow" target="_blank">Get-WebApplication</a> cmdlet these properties aren't available even though a web application is a virtual directory.</p><p>If you look at the applicationHost.config file you'll see that the application in fact has a virtual directory (with path "/") associated with it. </p><p>This virtual directory has the additional information required.</p><p><application path="/TestApp" applicationPool="TestSite"><br /> <virtualDirectory path="/" physicalPath="C:\TestApp" userName="administrator" password="[enc:AesProvider:B2sdfsd1213E98dV53cb5NfdZndNWvCUf/AekXE=:enc]" /><br /></application></p><p><br /></p><p>To access this information get the "/" virtual directory from the collection property.</p><p></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">$app</span><span style="color: black; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console"; mso-color-alt: windowtext;"> </span><span style="color: darkgrey; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="color: black; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console"; mso-color-alt: windowtext;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">Get-WebApplication</span><span style="color: black; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console"; mso-color-alt: windowtext;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">"TestApp"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="color: orangered; font-family: "Lucida Console"; font-size: 9pt;">$app</span><span style="color: darkgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Collection</span><span style="color: darkgrey; font-family: "Lucida Console"; font-size: 9pt;">[</span><span style="color: purple; font-family: "Lucida Console"; font-size: 9pt;">0</span><span style="color: darkgrey; font-family: "Lucida Console"; font-size: 9pt;">]|</span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">SELECT</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9pt;">*</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;</span></p><div><br /></div>I was concerned that the "/" virtual directory won't always be the first on in the collection (I can't confirm this) so added the following function to ensure that the correct one is returned.<div><br /><p><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: green;"># Gets the virtual directory
associated with the specified application.<br /></span></span><span style="color: #2b91af; font-family: "Cascadia Mono"; font-size: 9.5pt;">Function</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> Get-ApplicationVirtualDirectory<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">{</span></p><p>
</p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: black; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";"><span style="mso-spacerun: yes;"> </span></span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">[CmdletBinding()]<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">param(</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: black; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";"><span style="mso-spacerun: yes;"> </span></span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">[Parameter()]<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;">[System.Object]</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">$</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">Application</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: black; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";"><span style="mso-spacerun: yes;"> </span></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">)<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: blue;">process<br /></span></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>{<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>foreach</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">($</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">virtualDirectory </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">in</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">$</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">application.Collection</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: blue;">)<br /></span></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>{<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span><span> </span>if</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">($</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">virtualDirectory.Path -eq </span><span style="color: #a31515; font-family: "Cascadia Mono"; font-size: 9.5pt;">"/"</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">)</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> { </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">return</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">$</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">virtualDirectory</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">;</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> }<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>}<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>return</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">$null;</span></p>
<p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: black; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black; font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: "Cascadia Mono";">}</span><o:p></o:p></p><br /><p></p></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-15108519401644389992024-02-20T22:49:00.000-08:002024-02-20T22:49:45.422-08:00SOLVED: The Get-IISAppPool PowerShell cmdlet returns the application pool password encrypted starting [enc:IISWASOnlyCngProvider<p>When you run the <a href="https://learn.microsoft.com/powershell/module/iisadministration/get-iisapppool" rel="nofollow" target="_blank">Get-IISAppPool</a> PowerShell cmdlet and try and view the password of the application pool you may see that the password looks like this:</p><p>[enc:IISWASOnlyCngProvider:uQaGVt5rssdfPO129+N0iAJs3iE0d46qeDy34lnYeOvoMWrts9t+cwY7BgtBnYO+IINgGaPiz+19820knjdaf81ndafjsdfyHzmaF3Cgqg=:enc]</p><p><br /></p><p>To resolve the issue and view the plain text password simply right click the PowerShell console and select <b>Run as Administrator</b>. </p><p><br />When running as administrator the following command will display the application pool's password in plain text.</p><p><br /></p><p>(Get-IISAppPool -Name "<i style="background-color: #fff2cc;">name</i>").ProcessModel.Password</p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-91516586250964671112024-02-20T20:19:00.000-08:002024-02-20T20:19:33.713-08:00SOLVED: The IISAdministration cmdlets don't reflect changes made to a Microsoft IIS Server configuration<p>You might find that when you're running the <a href="https://learn.microsoft.com/powershell/module/iisadministration" rel="nofollow" target="_blank">IISAdministration</a> cmdlets such as <a href="https://learn.microsoft.com/powershell/module/iisadministration/get-iisapppool" rel="nofollow" target="_blank">Get-IISAppPool</a> that the cmdlets return out of date information that doesn't reflect the current configuration settings.</p><p>To resolve the issue you need to run the <a href="https://learn.microsoft.com/powershell/module/iisadministration/reset-iisservermanager" rel="nofollow" target="_blank">Reset-IISServerManager</a> to re-load the latest configuration.</p><p>Reset-IISServerManager -Confirm:$false</p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-71246632689240759642024-02-19T02:09:00.000-08:002024-02-19T02:09:16.437-08:00SOLVED: Find web sites and applications using a Microsoft IIS server application pool using the IISAdministration PowerShell cmdlets<p><span style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;">If you're using the <a href="https://learn.microsoft.com/powershell/module/iisadministration" rel="nofollow" target="_blank">IISAdministration PowerShell module</a> you may want to find out what applications are in use by an application pool.</span></p><p><span style="color: #757575; font-family: Roboto, sans-serif;"><span style="background-color: white; font-size: 15px;">(if you're using the older <a href="https://learn.microsoft.com/powershell/module/webadministration" rel="nofollow" target="_blank">WebAdministration </a>module I've written the <a href="https://david-homer.blogspot.com/2024/02/solved-find-web-sites-and-applications.html" rel="nofollow" target="_blank">solution here</a>).</span></span></p><p><span style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;"><br /></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkgreen;">#
Gets the names of the applications in the specified application pool.</span><br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">Function</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: blueviolet;">Get-ApplicationPoolApplicationNames<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;">{</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">CmdletBinding</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: dimgrey;">]</span><br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span>param</span><span style="font-family: "Lucida Console"; font-size: 9pt;">(</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Parameter</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: dimgrey;">]</span><br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>[</span><span style="color: #006161; font-family: "Lucida Console"; font-size: 9pt;">System.Object</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: #a82d00;">$ApplicationPoolName<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkblue;"> </span><span style="color: darkblue;">process<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>{</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$applicationNames</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">New-Object</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">System.Collections.Generic.List``1[System.String]</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$webSites</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">Get-IISSite</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>foreach</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">in</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSites</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>{<span> <br /></span></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>foreach</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">in</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Applications)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>{<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>if</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">ApplicationPoolName
</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">-eq</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$ApplicationPoolName</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>{<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span>if</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Path
</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">-eq</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"/"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span>{<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span><span> </span>$applicationNames</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Add(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Name);<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span><span> </span>continue</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span>}<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span>$applicationNames</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Add(</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">$(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Name)$(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Path)</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">);<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>}<span> </span></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>}<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>}<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>return</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$applicationNames</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>}<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;">} </span></p><p><br />The results are returned in the format</p><p><br /></p><div style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;">SiteName</div><div style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;"><br /></div><div style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;">or</div><div style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;"><br /></div><div style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;">SiteName\ApplicationName</div><p><span style="background-color: white; color: #757575; font-family: Roboto, sans-serif; font-size: 15px;"><br /></span></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-1544716727508606832024-02-19T01:46:00.000-08:002024-02-19T01:46:25.611-08:00SOLVED: Find web sites and applications using a Microsoft IIS server application pool using the WebAdministration PowerShell cmdlets<p>If you're using the older <a href="https://learn.microsoft.com/powershell/module/webadministration" rel="nofollow" target="_blank">WebAdministration PowerShell module</a> for IIS you'll notice when browing application pools you'll see the applications in the pool.</p><p><br /><a href="https://learn.microsoft.com/powershell/module/webadministration">https://learn.microsoft.com/powershell/module/webadministration</a><br /><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8aj11ELFLIaX7yNou5SskKEUexj8ZbfbExiCT9kZQZ8uwtsv2qDl5BVZuBFSnyOh3UgrmW1ilOzuMulsTeqXvKs-4YAoBZmVIBzY7ThE2KGJ0NYdAe3AH-WJNOvMriAxhO-ACM4j8VhJ4zSOP96b-XkUnwz7aKVDfJoEkMhRiOcWQHYqLv2NHwqrHscqO/s1598/AppPools.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1460" data-original-width="1598" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8aj11ELFLIaX7yNou5SskKEUexj8ZbfbExiCT9kZQZ8uwtsv2qDl5BVZuBFSnyOh3UgrmW1ilOzuMulsTeqXvKs-4YAoBZmVIBzY7ThE2KGJ0NYdAe3AH-WJNOvMriAxhO-ACM4j8VhJ4zSOP96b-XkUnwz7aKVDfJoEkMhRiOcWQHYqLv2NHwqrHscqO/w400-h365/AppPools.png" width="400" /></a></div><div><br /></div><div><br /></div><div>However when you try and get the applications property it's not there because it's provided as a formatted property. You can grab the code from inside the formatter however there is a simpler method by enumerating the web sites and applications - these can be returned in the format</div><div><br /></div><div>SiteName</div><div><br /></div><div>or</div><div><br /></div><div>SiteName\ApplicationName</div><div><br /><p></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkgreen;">#
Gets the names of the applications in the specified application pool.</span><br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">Function</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: blueviolet;">Get-ApplicationPoolApplicationNames<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;">{<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span>[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9pt;">CmdletBinding</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: dimgrey;">]<br /></span></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span>param</span><span style="font-family: "Lucida Console"; font-size: 9pt;">(</span></p>
<p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: black; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console"; mso-color-alt: windowtext;"><span style="mso-spacerun: yes;"> </span></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Parameter</span><span style="color: black; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console"; mso-color-alt: windowtext;">()</span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: dimgrey;">]</span><br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>[</span><span style="color: #006161; font-family: "Lucida Console"; font-size: 9pt;">System.Object</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$ApplicationPoolName</span></p>
<p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: black;"> </span>)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkblue;"> </span><span style="color: darkblue;">process<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>{<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$applicationNames</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">New-Object</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9pt;">System.Collections.Generic.List``1[System.String]</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$webSites</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">Get-Website</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>foreach</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">in</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSites</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>{<span> <br /></span></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>if</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">applicationPool </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">-eq</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$ApplicationPoolName</span><span style="font-family: "Lucida Console"; font-size: 9pt;">) { </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$applicationNames</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Add(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Name); }<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>$applications</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">Get-WebApplication</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-Site</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Name;<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>foreach</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">in</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$applications</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>{<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>if</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> (</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">applicationPool
</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">-eq</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$ApplicationPoolName</span><span style="font-family: "Lucida Console"; font-size: 9pt;">)<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>{<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span><span> </span>$applicationNames</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Add(</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">$(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webSite</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Name)$(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$application</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Path)</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">);<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span><span> </span>}<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span><span> </span>}<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>}<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>return</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$applicationNames</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>}<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;">}</span></p><br /><p></p></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-80538515868765779272024-02-08T01:29:00.000-08:002024-02-08T07:57:53.596-08:00SOLVED: Remote access doensn't work on TeamViewer Quick Support (TeamViewQS) when the remote computer runs an application in UAC<p>You may find that remote access doensn't work on TeamViewer Quick Support (TeamViewQS) when the remote computer runs an application in UAC.</p><p>The remote user will see a UAC prompt:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj43W1VrV5LjoDsr7AjCGUdLJriuXbQpP7-_LQXLEW9qOdmlNrq4lpZPmnnKqHE6S3-5sdvPb9bUC0-tIjP2c8r1kVuVgtdoa59aCxQVya3UFZE91IMdMADGT71oSwfOQFJJFFVh3ZU9OAxNgb-fkklwpQ5WzAHWP52WV9RZZB9_VmsNF7TbjDmgUOPXkgT/s1449/TeamViewer1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1019" data-original-width="1449" height="450" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj43W1VrV5LjoDsr7AjCGUdLJriuXbQpP7-_LQXLEW9qOdmlNrq4lpZPmnnKqHE6S3-5sdvPb9bUC0-tIjP2c8r1kVuVgtdoa59aCxQVya3UFZE91IMdMADGT71oSwfOQFJJFFVh3ZU9OAxNgb-fkklwpQ5WzAHWP52WV9RZZB9_VmsNF7TbjDmgUOPXkgT/w640-h450/TeamViewer1.png" width="640" /></a></div><br /><p></p><p>While the user interacts with the UAC prompt you see the following dialog:</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWlFSBrc55b-uprg5NP4iXpjCiljdOMPDBYdDzSc1aA8AkGsk3YsK6QouS6_-0apf5miCC-Px603XvuQyP4K4bI-omV79iqp62X6BI61p2_wAFuqk4b-iqJLbf57dZrUXGqLfDqSqzqlRPZfyXk4_vUWQhBK_ynCPrhByCpcievJf1U0moSYD0_vwSfFEh/s452/TeamViewer2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="134" data-original-width="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWlFSBrc55b-uprg5NP4iXpjCiljdOMPDBYdDzSc1aA8AkGsk3YsK6QouS6_-0apf5miCC-Px603XvuQyP4K4bI-omV79iqp62X6BI61p2_wAFuqk4b-iqJLbf57dZrUXGqLfDqSqzqlRPZfyXk4_vUWQhBK_ynCPrhByCpcievJf1U0moSYD0_vwSfFEh/s16000/TeamViewer2.png" /></a></div><br /><br /><p>When the action is complete you are returned to the desktop however you now can't control any application on the desktop.</p><p><br /></p><p>To resolve this issue ask the user to disconnect from TeamViewer and restart the TeamViewerQS.exe as Administrator and reconnect.</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinKN6gtL2uQh18_Umw7d_LsPNa5yja5vba5mCbr-9G-NJE4VAtnjo-N57dQTWtdFmqhYgmnfAAT_HTT0anJcsDkz1rmua0icdGQlLhg78On-GQSgHjKduG2lVfJRsGc-zXXZ2-0-GXEkWkYQd3fVDIyOm2G6bzFg8_f3z_Y860p_vlNHMdCGKJV0mYCg7k/s369/TeamViewerRunAsAdministrator.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="369" data-original-width="363" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinKN6gtL2uQh18_Umw7d_LsPNa5yja5vba5mCbr-9G-NJE4VAtnjo-N57dQTWtdFmqhYgmnfAAT_HTT0anJcsDkz1rmua0icdGQlLhg78On-GQSgHjKduG2lVfJRsGc-zXXZ2-0-GXEkWkYQd3fVDIyOm2G6bzFg8_f3z_Y860p_vlNHMdCGKJV0mYCg7k/s320/TeamViewerRunAsAdministrator.png" width="315" /></a></div><br /><p style="text-align: center;"><br /><span style="font-size: large;">While you're here why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/network-documentation-tool.aspx" rel="nofollow" target="_blank">Server Documentation Tool</a>, <a href="https://www.centrel-solutions.com/xiaconfiguration/network-documentation-tool.aspx" rel="nofollow" target="_blank">XIA Configuration Server</a>?</span></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="345" src="https://www.youtube.com/embed/_EHavNNYuTg" width="443" youtube-src-id="_EHavNNYuTg"></iframe></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-92009868975930848972024-01-24T03:54:00.000-08:002024-01-25T07:18:54.715-08:00SOLVED: Microsoft PowerShell cmdlet Get-DnsServerRootHint shows error No root hint found by {server} name server on {servername} server<p>When you run the Microsoft PowerShell cmdlet <a href="https://learn.microsoft.com/powershell/module/dnsserver/get-dnsserverroothint" rel="nofollow" target="_blank">Get-DnsServerRootHint</a> you see the error </p><p><i>No root hint found by {server} name server on {servername} server</i></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhREq6IgnlaUGtkOi-GnXW_nJl1Ih7RD7mr1m8UYR7lFGpebT2ALLsJUkNltfvbp7oQthMOtXNTehH9p5KdbN5782DlPAmDF1ww3-o4gAJkrrzMfN7-1TTIz2jkRTMbELPGBxGMkI5XVUUqFgsFN8CU5eeK9ISk8x4rLdWwAW_re5nVZI7RIblO57k7Slk5/s678/RootHints3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="458" data-original-width="678" height="432" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhREq6IgnlaUGtkOi-GnXW_nJl1Ih7RD7mr1m8UYR7lFGpebT2ALLsJUkNltfvbp7oQthMOtXNTehH9p5KdbN5782DlPAmDF1ww3-o4gAJkrrzMfN7-1TTIz2jkRTMbELPGBxGMkI5XVUUqFgsFN8CU5eeK9ISk8x4rLdWwAW_re5nVZI7RIblO57k7Slk5/w640-h432/RootHints3.png" width="640" /></a></div><br /><i><br /></i><p></p><p>When you view the root hints in the DNS server manager MMC you see the root hint listed as "Unknown".</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSL-CDHh0tLH2TNgCHcMcJiBJ81EPU7CQD5o39oltSbqlmFnWW_h379OFN76TMSTgEx1KigvtR-Y7gBhy-LXeOYoe02mQqBQZmHmQBTU2UOEHYEvweGgNIOWTi6HLyBZ7Nzjkrv9VUD3ubhYO5YzsLWCsqO8PZfiIx9PUwZrvRN3rGgRcT3kjBtkRx9biL/s473/RootHints4.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="473" data-original-width="400" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSL-CDHh0tLH2TNgCHcMcJiBJ81EPU7CQD5o39oltSbqlmFnWW_h379OFN76TMSTgEx1KigvtR-Y7gBhy-LXeOYoe02mQqBQZmHmQBTU2UOEHYEvweGgNIOWTi6HLyBZ7Nzjkrv9VUD3ubhYO5YzsLWCsqO8PZfiIx9PUwZrvRN3rGgRcT3kjBtkRx9biL/w339-h400/RootHints4.png" width="339" /></a></div><br /><p>If the DNS server is Active Directory Integrated this could be because the record is corrupt.</p><p>You can view the raw data using ADSIEdit.msc and going to the following (replacing the distinguished name of the domain as required).</p><p>DC=RootDNSServers,CN=MicrosoftDNS,DC=DomainDnsZones,DC=<span style="background-color: #fff2cc;">demo2019</span>,DC=<span style="background-color: #fff2cc;">int</span></p><p><span style="background-color: #fff2cc;"><br /></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGRLYcqA8cN7WUUr0TPKFXEVk5eckepWeWixccLd41EGLrLYrN-aDZop6llA3Jb4LrhA5UP_mXWr1Jut9jNGP1HigKD2yF28LKjg8OlgkuUSVSt6ObbXPdinsadii_LdC7es-5DBH5rgoWBpOZtVvzSGsGJFGUpLePEjqBotfGkgjNJWJt74LOmI5Ij44S/s1079/RootHints5.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="695" data-original-width="1079" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGRLYcqA8cN7WUUr0TPKFXEVk5eckepWeWixccLd41EGLrLYrN-aDZop6llA3Jb4LrhA5UP_mXWr1Jut9jNGP1HigKD2yF28LKjg8OlgkuUSVSt6ObbXPdinsadii_LdC7es-5DBH5rgoWBpOZtVvzSGsGJFGUpLePEjqBotfGkgjNJWJt74LOmI5Ij44S/w400-h258/RootHints5.png" width="400" /></a></div><br /><p>Check the dnsRecord value if this value is missing or corrupt it will display the error above.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-96V7OgwukxFrSBgbj1prb72_u-YDisrdLUw9k1lZfGat4JZJHY0KWJ_1aju7gm61S7W6eBpA411JekmPEvKQFZHpoC645E1hmhYwMMXHs5EIHjKIlysIt_8jG1wcdbtUMcFXlANMLMaIsNftPqGKGtuZJ_wOKOlPV35ECav5H2PUkzChFlPopdFYo5nO/s455/RootHints6.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="455" data-original-width="400" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-96V7OgwukxFrSBgbj1prb72_u-YDisrdLUw9k1lZfGat4JZJHY0KWJ_1aju7gm61S7W6eBpA411JekmPEvKQFZHpoC645E1hmhYwMMXHs5EIHjKIlysIt_8jG1wcdbtUMcFXlANMLMaIsNftPqGKGtuZJ_wOKOlPV35ECav5H2PUkzChFlPopdFYo5nO/w351-h400/RootHints6.png" width="351" /></a></div><div><br /></div><div><br /></div>If the DNS server is not Active Directory integrated then an error may be found in the cache.dns file found by default in the following location:<div>C:\Windows\System32\dns\cache.dns<br /><div><br /><p>The correct value can be set by clicking the "Edit" button in the DNS manager MMC and entering the correct value, or by clicking "Remove" if the value should not exist.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG9t8GRZvuC8yP_Y26vg2gX_bIRwDjLEUY1h4ugdClIGfzECq-QRi4-3zqNxil8_UHCoTROlSBSr2HL5U6roHGKIoeDFSpUQOJ-nDTnlQL7OwFL2hoKuaiIVVMVdelywTBS0Z8oJltO_BMboEBxdEdt1lf9Q6kXBVPbkYw-pxhu6XuKp3H_LqFE1a84cMG/s530/RootHints7.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="407" data-original-width="530" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG9t8GRZvuC8yP_Y26vg2gX_bIRwDjLEUY1h4ugdClIGfzECq-QRi4-3zqNxil8_UHCoTROlSBSr2HL5U6roHGKIoeDFSpUQOJ-nDTnlQL7OwFL2hoKuaiIVVMVdelywTBS0Z8oJltO_BMboEBxdEdt1lf9Q6kXBVPbkYw-pxhu6XuKp3H_LqFE1a84cMG/w400-h308/RootHints7.png" width="400" /></a></div><br /><p>The PowerShell cmdlet should now work as expected.</p><p><br /></p><p style="text-align: center;"><b><span style="color: #cc0000; font-size: large;">Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-dns-server-audit-and-documentation-tool" target="_blank">DNS server documentation tool</a></span></b></p><p style="text-align: center;"><b><span style="color: #cc0000; font-size: large;"><a href="https://www.centrel-solutions.com/xiaconfiguration/network-documentation-tool.aspx" target="_blank">XIA Configuration Server</a>?</span></b></p><p style="text-align: center;"><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="351" src="https://www.youtube.com/embed/q48423jRvtA" width="422" youtube-src-id="q48423jRvtA"></iframe></div><br /><p style="text-align: center;"><br /></p><p style="text-align: center;"><br /></p><p><br /></p><p><br /></p><p><br /></p></div></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-41144454490356438512024-01-12T02:32:00.000-08:002024-01-12T02:32:34.662-08:00How to delete or deactivate your Twitter (X) Account<p>To delete your Twitter account you need to first deactivate it. </p><p>Deactivation initiates a 30-day window where the account can be reactivated and after 30 days the account is deleted.</p><p><br /></p><p>The quickest way to do this is to go to the direct link:</p><p><a href="https://twitter.com/settings/deactivate">https://twitter.com/settings/deactivate</a></p><p><br /></p><p><br /></p><p>This is quicker than going through the menu system</p><p><a href="https://help.twitter.com/en/managing-your-account/how-to-deactivate-x-account#deactivating-vs-deleting">https://help.twitter.com/en/managing-your-account/how-to-deactivate-x-account#deactivating-vs-deleting</a></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-6767590647279949002024-01-03T03:59:00.000-08:002024-01-03T03:59:43.233-08:00The Azure REST API for Availability Sets does not show the references for virtual machines in the Availability Set<p>When you make a GET rest to the Azure Availability Sets REST API you may notice that the virtual machines that are in the availability set are not shown.<br /><a href="https://learn.microsoft.com/rest/api/compute/availability-sets/get" rel="nofollow" target="_blank">https://learn.microsoft.com/rest/api/compute/availability-sets/get</a></p><p><br /></p><p>For example:</p><p>https://management.azure.com/subscriptions/<span style="background-color: #fff2cc;">00000000-0000-0000-0000-000000000000</span>/providers/Microsoft.Compute/availabilitySets?api-version=2023-09-01</p><p><br /></p><p>For these to be visible you must expand them using the following:</p><p>https://management.azure.com/subscriptions/<span style="background-color: #fff2cc;">00000000-0000-0000-0000-000000000000</span>/providers/Microsoft.Compute/availabilitySets?<span style="background-color: #93c47d;">$expand=virtualMachines/$ref</span>&api-version=2023-09-01</p><p><br /></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-42482847635417148802023-12-30T07:43:00.000-08:002023-12-30T07:43:54.950-08:00Get a screenshot of an Azure virtual machine programmatically using PowerShell and the Azure REST API<p>The Boot Diagnostics menu in an Azure virtual machine displays a screenshot of the virtual machine.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlbkvhjROs4pkV93rVGsM5uHwAnsW_lVwPTZ7IaYapPB8Ejc9AGgkxVrbSi2ZUPz0Q1FoPZH8m0uIvLhuwoea-2WPI_muUZX-n_PF0ENpS9JNXHjDON8otForC7aqQ4JIOSmavMWT1sZxbPtcYZOYa99N2uO4bPM2h36SwHmd9kXR57AOD1oDQRs9198_h/s987/BootDiagnostics.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="775" data-original-width="987" height="502" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlbkvhjROs4pkV93rVGsM5uHwAnsW_lVwPTZ7IaYapPB8Ejc9AGgkxVrbSi2ZUPz0Q1FoPZH8m0uIvLhuwoea-2WPI_muUZX-n_PF0ENpS9JNXHjDON8otForC7aqQ4JIOSmavMWT1sZxbPtcYZOYa99N2uO4bPM2h36SwHmd9kXR57AOD1oDQRs9198_h/w640-h502/BootDiagnostics.png" width="640" /></a></div><br /><p>This screenshot is availabe in the REST API described here.</p><p><a href="https://learn.microsoft.com/rest/api/compute/virtual-machines/retrieve-boot-diagnostics-data" rel="nofollow" target="_blank">https://learn.microsoft.com/rest/api/compute/virtual-machines/retrieve-boot-diagnostics-data</a></p><p><br /></p><p>For this to work you must use a POST method and have the "retrieveBootDiagnosticsData/action" permission.</p><p>The REST API call returns an object with the URL to the image at an Azure storage URL which can then be downloaded with a web client.</p><p><br /></p><p><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkgreen;"><span style="background-color: white;">#
Gets the screenshot for the specified virtual machine.</span><span style="background-color: white;"><br /></span></span></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;">function</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: blueviolet;">Get-AzureVirtualMachineScreenshot</span></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">{<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><br /><span style="color: dimgrey;"><span> </span>[</span></span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9pt;">CmdletBinding</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: dimgrey;">]<br /></span></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span>param</span><span style="font-family: "Lucida Console"; font-size: 9pt;">(</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"><br /><span style="color: dimgrey;"><span> </span><span> </span>[</span></span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9pt;">Parameter</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>[</span><span style="color: #006161; font-family: "Lucida Console"; font-size: 9pt;">Guid</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$SubscriptionIdentifier</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">,<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><br /><span> <span> </span></span>[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9pt;">Parameter</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>[</span><span style="color: #006161; font-family: "Lucida Console"; font-size: 9pt;">String</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$ResourceGroupName</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">,<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><br /><span> </span><span> </span>[</span><span style="color: deepskyblue; font-family: "Lucida Console"; font-size: 9pt;">Parameter</span><span style="font-family: "Lucida Console"; font-size: 9pt;">()</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]<br /></span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>[</span><span style="color: #006161; font-family: "Lucida Console"; font-size: 9pt;">String</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$Name</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"> )<br /></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkblue;"> </span><span style="color: darkblue;">process<br /></span></span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span> </span>{</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";"><span> </span><span> </span>$response</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">Invoke-AzRestMethod</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">-Path</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">"/subscriptions/</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">$SubscriptionIdentifier</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">/resourceGroups/</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">$ResourceGroupName</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">/providers/Microsoft.Compute/virtualMachines/</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">$Name</span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">/retrieveBootDiagnosticsData?api-version=2022-03-01"</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">-Method</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";">POST</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$responseObject</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">ConvertFrom-Json</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$response</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Content;<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$webClient</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">New-Object</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9pt;">System.Net.WebClient;<br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>$screenshot</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webClient</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">DownloadData(</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$responseObject</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">consoleScreenshotBlobUri);<span> </span><span> </span><span> </span><span> </span></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$webClient</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">Dispose();<br /></span><span style="color: darkblue; font-family: "Lucida Console"; font-size: 9pt;"><span> </span><span> </span>return</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$screenshot</span><span style="font-family: "Lucida Console"; font-size: 9pt;">;</span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> }</span><span style="font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">}</span><span style="font-family: "Lucida Console"; font-size: 9pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span></p><p></p><p class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0cm;"><span style="background-color: white; color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$image</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: blue; font-family: "Lucida Console"; font-size: 9pt;">Get-AzureVirtualMachineScreenshot</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: navy; font-family: "Lucida Console"; font-size: 9pt;">-SubscriptionIdentifier</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: Lucida Console;"><span style="background-color: white; font-size: 9pt;">"</span><span style="background-color: #fff2cc; font-size: 12px;">00000000-0000-0000-0000-000000000000</span><span style="background-color: white; font-size: 9pt;">"</span></span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: navy; font-family: "Lucida Console"; font-size: 9pt;">-ResourceGroupName</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="background-color: #fff2cc; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">ResourceGroupName</span><span style="background-color: white; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: navy; font-family: "Lucida Console"; font-size: 9pt;">-Name</span><span style="background-color: white; color: black; font-family: "Lucida Console"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background-color: white; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="background-color: #fff2cc; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">VirtualMachineName</span><span style="background-color: white; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"</span><span style="background-color: white; color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">[</span><span style="background-color: white; color: #006161; font-family: "Lucida Console"; font-size: 9pt;">System.IO.File</span><span style="background-color: white; color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">]::</span><span style="background-color: white; font-family: "Lucida Console"; font-size: 9pt;">WriteAllBytes(</span><span style="background-color: white; color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"c:\image.jpg"</span><span style="background-color: white; color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">,</span><span style="background-color: white; font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="background-color: white; color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$image</span><span style="background-color: white; font-family: "Lucida Console"; font-size: 9pt;">);</span></p><br /><p></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-83696723243966009112023-12-10T00:24:00.000-08:002023-12-10T00:27:51.183-08:00How to programatically identify the latest stable REST API version of Azure management REST<p>If you are making direct calls to the Azure REST API you notice that you need to provide the API version for that specific REST endpoint.</p><p>Sometimes the version provided in the Microsoft documentation is wrong.</p><p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOycJatVfP60UaF-QDfZBuhogowsbocyfTGxehmDQQsPKOs94ADXuo3dTFuZYZNwrThWkYMhJ6eAKWP2abBb1R0KWpqRC15HgpHzt3iX8h36AnYYLUFlM9l3XKwmDJCppT0-ygdk6dinOl6oXkCqkXHzIryvpEOJqZWOAKJVB0_iJi8AsNsWTfdt_C-A7A/s2476/API%20Version.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="1797" data-original-width="2476" height="464" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOycJatVfP60UaF-QDfZBuhogowsbocyfTGxehmDQQsPKOs94ADXuo3dTFuZYZNwrThWkYMhJ6eAKWP2abBb1R0KWpqRC15HgpHzt3iX8h36AnYYLUFlM9l3XKwmDJCppT0-ygdk6dinOl6oXkCqkXHzIryvpEOJqZWOAKJVB0_iJi8AsNsWTfdt_C-A7A/w640-h464/API%20Version.png" width="640" /></a></p><p><br /></p><p>If you provide an invalid API version you receive an error message that contains the available API versions.</p><p>However, should you wish to programatically determine the current latest API version you can use the providers API.</p><p><a href="https://learn.microsoft.com/rest/api/resources/providers" rel="nofollow" target="_blank">https://learn.microsoft.com/rest/api/resources/providers</a></p><p>For example if you would like to know the latest Web Apps API version you can call the providers API and provide the namespace in which the Web Apps API resides (the <b>provider API </b>version is currently 2021-04-01).</p><p>https://management.azure.com/providers/Microsoft.Web?api-version=2021-04-01</p><p>As you can see from the results here shown in <a href="https://www.postman.com/" rel="nofollow" target="_blank">Postman</a> there is a resource type of "Sites" (again Microsoft are a bit inconsistent in their naming between the API and the documentation - web apps are infact "sites" in the REST API).</p><p>You can see the current API version is 2023-01-01 (not what is shown in the documentation).<br /><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl7Lwk3fgF8Vfv_9AQnuKw_uT4NgMCcrSiV0b1TPkF7Cqp_egp7EvWvJM7HAMY-Wkta99DvEk4jpkbMMt3bQG4eDAUq_n0r59wOiIo0IKX3OjFDozu4CCpBRNHLomvIO930AKmwyzYfhescwgVjWuyDHnJ1BIt3j_VnjVSkJ0UgfyCwVxtT16x5I5mbxY8/s2095/APIVersions.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1495" data-original-width="2095" height="456" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl7Lwk3fgF8Vfv_9AQnuKw_uT4NgMCcrSiV0b1TPkF7Cqp_egp7EvWvJM7HAMY-Wkta99DvEk4jpkbMMt3bQG4eDAUq_n0r59wOiIo0IKX3OjFDozu4CCpBRNHLomvIO930AKmwyzYfhescwgVjWuyDHnJ1BIt3j_VnjVSkJ0UgfyCwVxtT16x5I5mbxY8/w640-h456/APIVersions.png" width="640" /></a></div><br /><p><br /></p><p>The equivilant in the Azure Az PowerShell cmdlets would be the <a href="https://learn.microsoft.com/powershell/module/az.resources/get-azresourceprovider" rel="nofollow" target="_blank">Get-AzResourceProvider</a> cmdlet.</p><p>Get-AzResourceProvider -ProviderNamespace "Microsoft.Web"</p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-33381327035109654912023-12-05T07:28:00.000-08:002023-12-05T07:28:42.401-08:00Azure Web App "Application Settings" and "Connection Strings" section missing from "Configuration" Section in the Azure Portal<p>You may find that you can't locate the "Application Settings" and "Connection Strings" sections for an Azure Web App.</p><p>This is because Microsoft's documentation is often wrong.<br /><a href="https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal" rel="nofollow" target="_blank">https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal</a></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguPb6XbB79ChptuPgPdvNpdUt4h3SR84nPw-uOiikXYcJwOfB8syBAE8Ib5FfoWf3vNCK8BMXXZqSkVw3WH7m8uU7A9o3mbejYR0H9MWyiSF8ekYRyi5Whz4LHcDBoRxUB62A_x0-0I66nQqhhKj3N5LpbkyTtn8VJ42kfbDBWNQHd-No39353_fNZxh2Z/s688/Connection.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="447" data-original-width="688" height="416" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguPb6XbB79ChptuPgPdvNpdUt4h3SR84nPw-uOiikXYcJwOfB8syBAE8Ib5FfoWf3vNCK8BMXXZqSkVw3WH7m8uU7A9o3mbejYR0H9MWyiSF8ekYRyi5Whz4LHcDBoRxUB62A_x0-0I66nQqhhKj3N5LpbkyTtn8VJ42kfbDBWNQHd-No39353_fNZxh2Z/w640-h416/Connection.png" width="640" /></a></div><br /><p>These settings are no longer under "Settings > Configuration", but are now under "Settings > Environment Variables".</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNsSE1bsXTqQxjXL-0HDURjAuq5pMfk0w_rn9AyI9ryDasDiYAFXv93z7bYP5clPU4cnhzzRvNMzKr20Ar0VcswyYg1B0gP9Ub9JHxAxRn7EhtIyrlyZ8K_rGDNhXqiZMre2zpmu0YeUwnoyti-4karnh9p_IrOtKHhJruSNnV3-RTJGo0tPjXLIW5Ymcx/s245/EnvironmentVariables.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="70" data-original-width="245" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNsSE1bsXTqQxjXL-0HDURjAuq5pMfk0w_rn9AyI9ryDasDiYAFXv93z7bYP5clPU4cnhzzRvNMzKr20Ar0VcswyYg1B0gP9Ub9JHxAxRn7EhtIyrlyZ8K_rGDNhXqiZMre2zpmu0YeUwnoyti-4karnh9p_IrOtKHhJruSNnV3-RTJGo0tPjXLIW5Ymcx/s1600/EnvironmentVariables.png" width="245" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-23393389500462126792023-11-30T01:56:00.000-08:002023-11-30T01:56:19.678-08:00SOLVED: Error message ResourceTypeNotSupported "Unsupported resource type: 'Microsoft.PolicyInsights/policyStates/summarize'" using the Azure REST API.<p>To generate a state summary of a of an Azure policy assignment you can use the Azure PowerShell cmdlet Get-AzPolicyStateSummary.</p><p>However when you call this using REST you get the error</p><p><span data-offset-key="7v8cn-0-0" style="background-color: white; color: #212121; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Helvetica, Arial, sans-serif; font-size: 12px; white-space-collapse: preserve;"><span data-text="true">https://management.azure.com/Subscriptions/</span></span><span class="resolvedVariable" data-testid="resolvedVariable" spellcheck="false" style="background-color: white; color: var(--base-color-brand); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Helvetica, Arial, sans-serif; font-size: 12px; white-space-collapse: preserve;"><span data-offset-key="7v8cn-1-0">{{subscriptionId}}</span></span><span data-offset-key="7v8cn-2-0" style="background-color: white; color: #212121; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", Helvetica, Arial, sans-serif; font-size: 12px; white-space-collapse: preserve;"><span data-text="true">/providers/Microsoft.Authorization/policyAssignments/SecurityCenterBuiltIn/providers/Microsoft.PolicyInsights/policyStates/latest/summarize?api-version=2019-10-01</span></span></p><div style="background-color: #fffffe; font-size: 12px; line-height: 18px; white-space: pre;"><div>{</div><div> <span style="color: #a31515;">"error"</span>: {</div><div> <span style="color: #a31515;">"code"</span>: <span style="color: #0451a5;">"ResourceTypeNotSupported"</span>,</div><div> <span style="color: #a31515;">"message"</span>: <span style="color: #0451a5;">"Unsupported resource type: 'Microsoft.PolicyInsights/policyStates/summarize'."</span></div><div> }</div><div>}</div></div><p><br /></p><p>This is because the method must be called with the verb POST (not GET).</p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-22505511659674621372023-11-22T08:20:00.000-08:002023-11-22T08:20:52.539-08:00SOLVED: Using the Azure Command-Line Interface (CLI) behind Fiddler - [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate<p>If you want to use Fiddler to monitor the commands and REST calls that are executed by the Microsoft Azure Command-Line Interface (CLI) you may find you hit this error.</p><p>Using the Azure Command-Line Interface (CLI) behind Fiddler - [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate</p><p>The Azure Command-Line Interface (CLI) does use the built in system certificates in the machine store that you probably updated when you installed Fiddler and instead you need to up a configuration file.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi37jL32Q4vvJd-n9Q5ngOc1ffpGmujlBKnpo5dljfKQX160K-uXATgy_QgKJA2r0_xp75N2q2dzPJ8ltGh-qALiZRNwElgVzVlCfcLJQGScEPCerTcBcAQdEjaaWJbnLsc9jndid22NEIFMD1te4Na-UxA_6KZBlXVsb1WGjekl4KAJRwE1R1oeXDxP8pe/s979/Error.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="512" data-original-width="979" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi37jL32Q4vvJd-n9Q5ngOc1ffpGmujlBKnpo5dljfKQX160K-uXATgy_QgKJA2r0_xp75N2q2dzPJ8ltGh-qALiZRNwElgVzVlCfcLJQGScEPCerTcBcAQdEjaaWJbnLsc9jndid22NEIFMD1te4Na-UxA_6KZBlXVsb1WGjekl4KAJRwE1R1oeXDxP8pe/w640-h334/Error.png" width="640" /></a></div><div><br /></div><div><br /></div><div><ul style="text-align: left;"><li>In the certificates MMC find the DO_NOT_TRUST_FidderRoot certificate, right click, and select All Tasks > Export.<br /><div style="text-align: left;"><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXEoUS7hNlUVHwLqFKn8j5-gx5hwQf3BYhQ2cxRgA_1PJZ6FangpyTM1q758GrIHU7O4FA54ETfLg4WhyphenhyphenKX9Ocxei7GxHlxizSTsjhLik0w8RElQvGR7GP_jOaDSrZ5_T9olu2zAAhyfYA6zOuadDWI_s_VClOL3_sPDDHwEK-w_7HXKyk0dHe-N9RMief/s621/ExportCertificate.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="224" data-original-width="621" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXEoUS7hNlUVHwLqFKn8j5-gx5hwQf3BYhQ2cxRgA_1PJZ6FangpyTM1q758GrIHU7O4FA54ETfLg4WhyphenhyphenKX9Ocxei7GxHlxizSTsjhLik0w8RElQvGR7GP_jOaDSrZ5_T9olu2zAAhyfYA6zOuadDWI_s_VClOL3_sPDDHwEK-w_7HXKyk0dHe-N9RMief/w400-h144/ExportCertificate.png" width="400" /></a><br /><br /></div></li><li><div style="text-align: left;">Select to <b>not</b> export the private key.<br /><br /></div></li><li><div style="text-align: left;">Select BASE-64 encoded X.509 (.CER) and select a file location to export the file<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlLVXhYDFiyKG1BXSLlnMqZrpSXH2BXaGo-hu3G7XcCZc6UHurCh75sMkD0O4pCeXJs8ddpv2cpZ38y4dGUPJp5nxo4DEPID8Pma4mNnQLUbUk9KHMzwtc1kdJqLyaIlSPfcbFAvzr2dKZ83mXZQ10N8VMTJUNKxk0_xmFhRyCg2gTSsMb0IYSbfpvSlv9/s535/ExportCertificate2.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="523" data-original-width="535" height="391" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlLVXhYDFiyKG1BXSLlnMqZrpSXH2BXaGo-hu3G7XcCZc6UHurCh75sMkD0O4pCeXJs8ddpv2cpZ38y4dGUPJp5nxo4DEPID8Pma4mNnQLUbUk9KHMzwtc1kdJqLyaIlSPfcbFAvzr2dKZ83mXZQ10N8VMTJUNKxk0_xmFhRyCg2gTSsMb0IYSbfpvSlv9/w400-h391/ExportCertificate2.png" width="400" /></a></div></li></ul></div><div><br /></div><p></p><ul style="text-align: left;"><li>If you <b>don't</b> have the certficate in here you can goto Fiddler goto Tools > Options > HTTPS > Actions > Export Root Certificate to Desktop.<br /><div style="text-align: left;"><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDw_Qi231pHgULuEhQ4znKoLiG4Xua7_cvhl6j-LtHGomvCbr_H6zYGhf6DkDLhJvBYdZDGreQKoCNQVkzzywVOovDjyUZ4gYi-YqlbUKVXpnl4CgzwS0MgeEzonQRL3wZ5olmcWon-vMOQAJjJnMI9IViLtCsQzECNGCdPyFgaHaEYkresBmemlPMqCt5/s714/Fiddler.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="385" data-original-width="714" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDw_Qi231pHgULuEhQ4znKoLiG4Xua7_cvhl6j-LtHGomvCbr_H6zYGhf6DkDLhJvBYdZDGreQKoCNQVkzzywVOovDjyUZ4gYi-YqlbUKVXpnl4CgzwS0MgeEzonQRL3wZ5olmcWon-vMOQAJjJnMI9IViLtCsQzECNGCdPyFgaHaEYkresBmemlPMqCt5/w400-h216/Fiddler.png" width="400" /></a><br /><br /></div></li><ul><li>You can then import the certificate, then export it in BASE-64 encoding.</li></ul></ul><p></p><ul style="text-align: left;"><li>On the file that you exported in BASE-64 format<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuVvt1TzIiJuZyvvMnm6X1W93RHxZFuqPAwTL4atDP0Yl7Ld6VOPjb_JN96-Fh4mvXdzYecAwxda7VUysRbC0DQ7c8uvdKh9EK0ZVeJIHCIKvEktMyke_VEesD2hxwhR5QyS4Kuhy3PmRA0-5eP5kwwtgWLb6y2xBN3L6gD0-FJLXVRkKt6PefTzScsW0o/s995/ExportCertificate3.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="589" data-original-width="995" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuVvt1TzIiJuZyvvMnm6X1W93RHxZFuqPAwTL4atDP0Yl7Ld6VOPjb_JN96-Fh4mvXdzYecAwxda7VUysRbC0DQ7c8uvdKh9EK0ZVeJIHCIKvEktMyke_VEesD2hxwhR5QyS4Kuhy3PmRA0-5eP5kwwtgWLb6y2xBN3L6gD0-FJLXVRkKt6PefTzScsW0o/w400-h236/ExportCertificate3.png" width="400" /></a></li></ul><br /><div><br /></div><div><ul style="text-align: left;"><li>Open the file certificate roots used by the CLI in notepad.exe - by default this is in this location.<br />C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\certifi\cacert.pem<br /><br /></li><li>Paste the exported certificate text to the end of the cacert.pem file and save the file.<br /><div style="text-align: left;"><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKWsxfs6IPoJQ-HLQs-y8PEudnki765sJ3mSFySmdNsqauB9bi4JtQEqE1nSl3tC4RWfWjS-Mrnzbt3FHHnWOJjbW3vSYnpdhHI27qE4sQWBWR_pU06NVdXwp0JJYeG1Kr6Yr-uCFpfMqnCf5Os9BHygWSz7I2FlT2p9AWwOxFvlfWVHUjefVsDfWNodnt/s995/ExportCertificate4.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="589" data-original-width="995" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKWsxfs6IPoJQ-HLQs-y8PEudnki765sJ3mSFySmdNsqauB9bi4JtQEqE1nSl3tC4RWfWjS-Mrnzbt3FHHnWOJjbW3vSYnpdhHI27qE4sQWBWR_pU06NVdXwp0JJYeG1Kr6Yr-uCFpfMqnCf5Os9BHygWSz7I2FlT2p9AWwOxFvlfWVHUjefVsDfWNodnt/w400-h236/ExportCertificate4.png" width="400" /></a><br /><br /><br /></div></li><li><div style="text-align: left;">Executing the Azure Command-Line Interface (CLI) commands should now work as expected.</div></li></ul></div><div><p><br /></p><p><br /></p><p><br /></p></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-80387038907228027432023-11-02T08:42:00.005-07:002023-11-02T08:43:18.455-07:00SOLVED: Connect-ExchangeOnline: Could not use the certificate for signing. See inner exception for details. Possible cause: this may be a known issue with apps build against .NET Desktop 4.6 or lower. <p>When you try and connect to Exchange Online using a service principal and client certificate such as this</p><p>Connect-ExchangeOnline -AppId "<i>identifier</i>" -CertificateThumbprint "<i>thumbprint</i>" -Organization "yourdomain.onmicrosoft.com";</p><p>You may see the following error</p><p><span style="color: red;">Could not use the certificate for signing. See inner exception for details. Possible cause: this may be a known issue with apps build against .NET Desktop 4.6 or lower. Either target a higher version of .NET desktop - 4.6.1 and above, or use a different certificate type (non-CNG) or sign your own assertion as described at https://aka.ms/msal-net-signed-assertion. </span></p><p>Problem: The certificate you're using is <b>too secure</b> for the Exchange Online PowerShell cmdlets.</p><p>If you read the Microsoft Guidance here you'll see their examples use older encryption which does work correctly.</p><p><a href="https://learn.microsoft.com/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps#step-3-generate-a-self-signed-certificate" rel="nofollow" target="_blank">https://learn.microsoft.com/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps#step-3-generate-a-self-signed-certificate</a><br /><br /></p><p>This seems to be an issue with the Exchange Online PowerShell (even at version 3.4.0) perhaps the libraries are compiled using an old version of .NET?</p><p><br /></p><p><b>Solution:</b></p><p>It's not a great solution you'll need to access the Microsoft Authentication libraries (MSAL)<br /><a href="https://www.nuget.org/packages/Microsoft.Identity.Client/">https://www.nuget.org/packages/Microsoft.Identity.Client/</a></p><p>You can then authenticate with the Microsoft authentication servers and get the token to allow access to Exchange that you need yourself. This token can then be passed to the Connect-ExchangeOnline cmdlet.</p><p># Set the variables<br />$msalPath = "D:\CENTRELSolutions\3rdParty\Microsoft\Microsoft Authentication Library (MSAL)";<br />$thumbprint = "<i>yourthumbprint</i>";<br />$applicationIdentifier = "<i>appidentifier</i>";<br />$organization = "<i>yourorganization</i>.onmicrosoft.com";<br />$environment = [Microsoft.Identity.Client.AzureCloudInstance]::AzurePublic;</p><p><br /># Authenticate<br />Add-Type -Path "$msalPath\Microsoft.IdentityModel.Abstractions.dll";<br />Add-Type -Path "$msalPath\Microsoft.Identity.Client.dll";<br />$certificate = Get-ChildItem -Path "Cert:\CurrentUser\My\$thumbprint";<br />[string[]] $Scopes = "https://outlook.office365.com/.default";<br />[Microsoft.Identity.Client.IConfidentialClientApplication] $application =<br />[Microsoft.Identity.Client.ConfidentialClientApplicationBuilder]::Create($applicationIdentifier).WithCertificate($certificate).WithAuthority($environment, $tenantIdentifier).Build();<br />$result = $application.AcquireTokenForClient($scopes).ExecuteAsync().Result;</p><p># You can now connect to Exchange Online<br />Connect-ExchangeOnline -AccessToken $result.AccessToken -Organization $organization;</p><p><br /></p><p><br /></p><div><br /></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-15390848505644360712023-10-31T07:39:00.001-07:002023-10-31T07:39:04.995-07:00SOLVED: C#.NET X509Certificate: System.InvalidOperationException: 'An X509Extension with OID '2.5.29.15' has already been specified.'<p>You may see the error "System.InvalidOperationException: 'An X509Extension with OID '2.5.29.15' has already been specified.'" when creating a self signed certificate.</p><p>This can occur if you try and add multiple KeyUsageFlags as two separate extensions.</p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">certificateRequest.CertificateExtensions.Add(</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">
X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment , </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">));<o:p></o:p></span></p><p>
</p><p class="MsoNormal"><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;">certificateRequest.CertificateExtensions.Add(</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: "Cascadia Mono";">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;"> X509KeyUsageExtension( X509KeyUsageFlags.DigitalSignature, </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: "Cascadia Mono";">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;">));</span><o:p></o:p></p><p>To resolved the issue assign the flags to a single extension.</p><p><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;">certificateRequest.CertificateExtensions.Add(</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%; mso-ansi-language: EN-GB; mso-bidi-font-family: "Cascadia Mono"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;">
X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment |
X509KeyUsageFlags.DigitalSignature, </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%; mso-ansi-language: EN-GB; mso-bidi-font-family: "Cascadia Mono"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt; line-height: 107%;">));</span></p><div><br /></div><div><br /></div><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-65943088610971042932023-10-31T04:10:00.004-07:002023-10-31T04:11:16.641-07:00Properties on the details tab of a certificate in the Certificates MMC in Windows shows with a warning yellow triangle and exclamation mark (exclamation point)<p>You might be wondering why some properties on the details tab of a certificate in the Certificates MMC in Windows shows with a warning yellow triangle and exclamation mark (exclamation point).#</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm_vtEckSvwclJZX0V63-MnIctEJWeWX164vlsdyWD8tM3qCY4hERZnEEnxYo3vaMexwkWu5XdHtIhj0wtzj_rWqPtAzWtKt3Nm0tf78Zp7V1KM1GF-8XKlnIgZdO73QwEfkA154ye91mgyQH_faJKDN7pSAwp4mfvnVbjs6IswTL6JeJyf5i1GmFiYhCj/s1098/Certificate.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1098" data-original-width="810" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm_vtEckSvwclJZX0V63-MnIctEJWeWX164vlsdyWD8tM3qCY4hERZnEEnxYo3vaMexwkWu5XdHtIhj0wtzj_rWqPtAzWtKt3Nm0tf78Zp7V1KM1GF-8XKlnIgZdO73QwEfkA154ye91mgyQH_faJKDN7pSAwp4mfvnVbjs6IswTL6JeJyf5i1GmFiYhCj/w472-h640/Certificate.png" width="472" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p>This simply indicates whether the extension is marked as "Critical".</p><p>The critical setting can be seen in .NET on the constructor of the extension</p><p><a href="https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509extension.-ctor" rel="nofollow" target="_blank">https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509extension.-ctor</a></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-86218369070592463662023-09-29T03:08:00.004-07:002023-09-29T03:08:56.644-07:00Connect to Exchange Online PowerShell with Connect-ExchangeOnline cmdlet and a service principal with client secret<p>Connecting to Azure with a service principal with client secret is quite simple - you can get the credentials and pass them to the Connect-AzAccount cmdlet and specify the -ServicePrincipal parameter. </p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$credential</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: blue;">Get-Credential</span><br /></span><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">Connect-AzAccount</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-Credential</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$credential</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-TenantId</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"<i>your-tenant-identifier</i>"</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-ServicePrincipal </span></p><p><br /></p><p>Connecting to Exchange Online however is somewhat more problematic - there is no "ServicePrincipal" parameter and using the cmdlet with just a credential and organization shows the following error.</p><p><i>The user is not recognized as a managed user, or a federated user.Azure AD was not able to identify the IdP that needs to process the user U/P: Wrong username</i></p><p>It looks like Microsoft haven't implemented the ability to use client secrets as they're not as secure as certificates (and the Connect-ExchangeOnline cmdlet has good support for certficiates).</p><p>Microsoft doesn't appear to have implemented any of their online services with any kind of consistency.</p><p>The cmdlets are all using the Microsoft Authentication Library (MSAL) under the hood which in turn creates and posts a message to the login.microsoftonline.com to generate a JWT (JSON Web Token) also seen as a bearer token so you can do this directly yourself bypassing the cmdlets and MSAL.</p><p><br /></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$clientId</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9pt;"><span style="color: darkred;">"<i>your-service-principal-app-identifier</i>"</span><br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$clientSecret</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"<i>your-client-secret</i>"</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> <br /></span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$tenantId</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"<i>your-tenant-id</i>"</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> <br /></span><br /></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$tokenBody</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> @{
</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">
Grant_Type </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">"client_credentials"</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> Scope </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">"https://outlook.office365.com/.default"</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">
Client_Id </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$clientId</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">
Client_Secret </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$clientSecret</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;">} </span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$tokenResponse</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">=</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Invoke-RestMethod</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">-Uri</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">https://login.microsoftonline.com/</span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 12px;">$tenantId</span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">/oauth2/v2.0/token</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">-Method</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: blueviolet; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">POST</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">-Body</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$tokenBody</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span></p><p>You can then pass this bearer (JWT) token to the Connect-ExchangeOnline cmdlet using the AccessToken parameter</p><p><span style="color: blue; font-family: "Lucida Console"; font-size: 9pt;">Connect-ExchangeOnline</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-AccessToken</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: #a82d00; font-family: "Lucida Console"; font-size: 9pt;">$tokenResponse</span><span style="color: dimgrey; font-family: "Lucida Console"; font-size: 9pt;">.</span><span style="font-family: "Lucida Console"; font-size: 9pt;">access_token</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: navy; font-family: "Lucida Console"; font-size: 9pt;">-Organization</span><span style="font-family: "Lucida Console"; font-size: 9pt;"> </span><span style="color: darkred; font-family: "Lucida Console"; font-size: 9pt;">"<i>your-organization-name.onmicrosoft.com</i>"</span><span style="font-family: "Lucida Console"; font-size: 9pt;">; </span></p><p><br /></p><p>You still need to use the Exchange PowerShell cmdlets rather than access the REST API directly because </p><p></p><ul style="text-align: left;"><li>The REST API isn't public <br /><br /></li><li>The REST API is in BETA (and presumable the PowerShell cmdlets will switch to production when a production API is available)<br /><br /></li><li>The REST API is not a proper REST API - if you look at the endpoint the say the Get-AddressList cmdlet is called you'd expect something like GET /AddressLists - however all the cmdlets that don't start with Get-EXO* actually sent a command to this one /InvokeCommand address<br /><br />https://outlook.office365.com/adminapi/beta/<i>identifier</i>/InvokeCommand<br /><br />The inside of the message posted to this address is some JSON that includes the cmdlet being run. This is pretty poor.<br /><br />{"CmdletInput":{"CmdletName":"Get-AddressList","Parameters":{}}}<br /><br /><br /></li></ul><p></p><p><br /></p><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-81356781390746824412023-09-25T03:07:00.000-07:002023-09-25T03:07:01.252-07:00SOLVED: How to check if a ZIP file is encrypted in C#.NET using Xceed ZIP.NET<p>If you would like to chekc whether a ZIP file is encrypted in C#.NET using Xceed ZIP.NET you can use the following code. <br /><br />As a ZIP file supports the ability to encrypt each individual file (rather than the ZIP archive itself) you need to check the contents of the ZIP file and see if the files inside it are encrypted.</p><p><br /></p><p><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">///</span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;"><summary><br /></span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">///</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: green;"> Determines whether any of the contents of the specified ZIP file
is encrypted<br /></span></span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">///</span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;"></summary><br /></span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">///</span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;"><param</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">name="</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">filename</span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">"></span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;">The absolute path to the ZIP file to evaluate.</span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;"></param><br /></span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;">///</span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: grey; font-family: "Cascadia Mono"; font-size: 9.5pt;"><returns></span><span style="color: green; font-family: "Cascadia Mono"; font-size: 9.5pt;">A System.Boolean value that indicates whether any of the contents
of the specified ZIP file is encrypted.</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: grey;"></returns><br /></span></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">public</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">static</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">bool</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> IsEncrypted(String filename)<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">{<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span style="color: blue;"> </span><span style="color: blue;">try<br /></span></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>{<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>if</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (!File.Exists(filename)) { </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">throw</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">
FileNotFoundException(Resources.CompressionSupport.FileNotFoundException); }<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>AbstractFile zipFile = </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> DiskFile(filename);<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>ZipArchive zip = </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> ZipArchive(zipFile);<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>AbstractFile[] files = zip.GetFiles(</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">);<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>foreach</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (AbstractFile file </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">in</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> files)<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>{<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span><span> </span>ZippedFile zippedFile =
(ZippedFile)file;<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span><span> </span>if</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (zippedFile == </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">null</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">) { </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">continue</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">; }<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span><span> </span>if</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (zippedFile.Encrypted) { </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">return</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">; }<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>}<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span><span> </span>return</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">false</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">;<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>}<br /></span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>catch</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (Exception ex) { </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">throw</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">
CompressionSupportException(String.Format(Resources.CompressionSupport.IsEncryptedException,
filename, ex.Message), ex); <br /><span> </span>}<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">}</span></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-group-policy-gpo-documentation-tool" target="_blank">Group Policy Audit and Documentation Tool</a>?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="343" src="https://www.youtube.com/embed/1qt3Y6_rB40" width="584" youtube-src-id="1qt3Y6_rB40"></iframe></div><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-9806120644155069612023-09-25T03:03:00.002-07:002023-09-25T03:03:26.326-07:00SOLVED: How to load a ZIP file from a byte[] array in C# using Xceed ZIP.NET<p>If you want to load a ZIP file in C# using Xceed ZIP.NET from a byte[] array you can do so easily by creating a MemoryStream and from there you create a StreamFile which can be loaded into the ZipArchive class.</p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">using</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> (MemoryStream stream = </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt; mso-bidi-font-family: "Cascadia Mono";">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> MemoryStream(zipData))<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">{<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>AbstractFile zipFile = </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> StreamFile(stream);<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>ZipArchive zip = </span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">new</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"> ZipArchive(zipFile);<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;"><span> </span>AbstractFile[] files =
zip.GetFiles(</span><span style="color: blue; font-family: "Cascadia Mono"; font-size: 9.5pt;">true</span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">);<br /></span><span style="font-family: "Cascadia Mono"; font-size: 9.5pt;">}</span></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-group-policy-gpo-documentation-tool" target="_blank">Group Policy Audit and Documentation Tool</a>?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="343" src="https://www.youtube.com/embed/1qt3Y6_rB40" width="584" youtube-src-id="1qt3Y6_rB40"></iframe></div><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-3559416575790851772023-09-04T03:00:00.002-07:002023-09-25T01:12:20.487-07:00The Group Policy Management Console XML and HTML reports missing information due to limitations in the GPMC<p>The Group Policy Management console (GPMC) in Active Directory has a nice feature which allows you to generate reports in HTML and XML format of the settings in the Group Policy Object.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhayNVsPa9oX45yQJwP8vjIN9cW1rlYwMz-4Ios45aA3fXGV_JV30jdnvoDUnFwDMl4Ml3n02L1PcWT7rMsVEXcv5KAaEV3WXuwG1ZOilFYshyDMq8yFIqtrn32gmT_gVltyA5aC0cC_WMWqX_0KzVKjdiYZq0D9H4LUssx9HiWQnUBERJ_uocM1M6zkwsi/s657/GPO1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="657" data-original-width="657" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhayNVsPa9oX45yQJwP8vjIN9cW1rlYwMz-4Ios45aA3fXGV_JV30jdnvoDUnFwDMl4Ml3n02L1PcWT7rMsVEXcv5KAaEV3WXuwG1ZOilFYshyDMq8yFIqtrn32gmT_gVltyA5aC0cC_WMWqX_0KzVKjdiYZq0D9H4LUssx9HiWQnUBERJ_uocM1M6zkwsi/s320/GPO1.png" width="320" /></a></div><br /><p><br /></p><p>The report is actually generated by the GPMC itself rather than the domain controller the tool is running against. This is somewhat problematic due to possible version differences between the tool and the Group Policy object settings.</p><p>Also the report only contains as much information as the tool can interpret - whilst the coverage is generally very good Microsoft seem to have become complacent in later versions of Windows where new settings have been added to Group Policy but the GPMC has not been updated to convert these into the settings in the HTML and XML reports. </p><p>This is actually highlighted in the Windows Defender Firewall section where you may see the following:</p><p><i>This rule might contain some elements that cannot be interpreted by the current version of GPMC reporting module</i></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh68oL84xFZet1J9vSKkqeV2JAomwqz2QHi9rW4ycL9-GkJRqu_wxZGRZVRXGvCT5iutVMBqOQ9lWl2T0HSNOdb7aNxWiwhjEQDjn_9PqsJhB8GtRemxf5Eq3JjF02-apEiaqwsiuhpetBc0foNqzMDPteaJiLiGkuz-icjmctdHBqdFACHyqBtxzVtAsnB/s1719/GPO2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1397" data-original-width="1719" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh68oL84xFZet1J9vSKkqeV2JAomwqz2QHi9rW4ycL9-GkJRqu_wxZGRZVRXGvCT5iutVMBqOQ9lWl2T0HSNOdb7aNxWiwhjEQDjn_9PqsJhB8GtRemxf5Eq3JjF02-apEiaqwsiuhpetBc0foNqzMDPteaJiLiGkuz-icjmctdHBqdFACHyqBtxzVtAsnB/w400-h325/GPO2.png" width="400" /></a></div><br /><p>Group Policy stores information in a variety of places including a binary registry.pol file, XML files (for Group Policy preferences), .ini files. It's a bit of a mess. The GPMC reports aggregate all of this information into a single report.</p><p><br /></p><p>For the Windows Defender Firewall the rules are actually stored in the Registry.pol file. You can view this file with the <a href="https://learn.microsoft.com/powershell/module/grouppolicy/get-gpregistryvalue" rel="nofollow" target="_blank">Get-GPRegistryValue</a> cmdlet or there is a nice GUI tool available here.</p><p><a href="https://sdmsoftware.com/general-stuff/registry-policy-viewer-1-5/">https://sdmsoftware.com/general-stuff/registry-policy-viewer-1-5/</a></p><p>You can see that the Windows Defender Firewall rule is actually stored in Group Policy as a String delimited by the | character and the GPMC just ignores the parameters it hasn't been coded to interpret.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0H0Yu1Rj0bVk6Wet1J2zrZiW5dg6amzhmolgwpr2Agenh8I_lIY3qcCMR6f2W972hyFux-BLgpiJ0vTTUPEOfzirFcuJzxMs4HKaWgbnzmF3JytaXPCqweDtklvLTiiAEoZdaL-5UucYuJ_eJ85SvoySOZsfqcbZiP6Mj9K6QnOZD4-RNwjV2WdwByF2F/s1522/GPO3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="925" data-original-width="1522" height="389" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0H0Yu1Rj0bVk6Wet1J2zrZiW5dg6amzhmolgwpr2Agenh8I_lIY3qcCMR6f2W972hyFux-BLgpiJ0vTTUPEOfzirFcuJzxMs4HKaWgbnzmF3JytaXPCqweDtklvLTiiAEoZdaL-5UucYuJ_eJ85SvoySOZsfqcbZiP6Mj9K6QnOZD4-RNwjV2WdwByF2F/w640-h389/GPO3.png" width="640" /></a></div><br /><p>The items that aren't interpreted by even the latest GPMC on Windows Server 2022 include the following:</p><p></p><ul style="text-align: left;"><li>Rule application packages</li><li>Rule compartments</li><li>Edge Traversal > Defer to user</li><li>Edge Traversal > Defer to application</li><li>Local Principals Tab</li><li>Allow the computers to dynamically negotiate encryption</li><li>IP Sec integrity algorithms aren’t all supported</li><li>Key Exchange Algorithms aren’t all supported – Diffe-Hellman Group 24 defaults to a different key exchange.</li><li>Most of the identity algorithms are not supported.</li><li>Many of the newer encryption algorithms are not supported.</li><li>The advanced settings of the authentication method are not displayed at all.</li></ul><p></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-group-policy-gpo-documentation-tool" target="_blank">Group Policy Audit and Documentation Tool</a>?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="343" src="https://www.youtube.com/embed/1qt3Y6_rB40" width="584" youtube-src-id="1qt3Y6_rB40"></iframe></div><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-78339842758453575402023-08-15T09:17:00.002-07:002023-09-25T01:17:24.021-07:00SOLVED: Active Directory Inter-Site Topology Generator shows as "Invalid"<p>You may find that the Inter-site topology generator is listed as "Invalid" in Active Directory sites and services.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT9LcRO3gjCqPzY9cVF53Jmvn1dtA2DGNsPtY3uLntLfPX-befNF4FthDxnDZgXFrVFy2uUCrKrfTaIKNDqALexiYC3IPanmaDKZV37mRFls8hMb7JIBy0irgWz-mH1S6luyRthfL0T-NIFRUMmdDlxv_YouGf6b3BRiqj4ZPeGujG0AYV864t4Bn13zha/s488/Error2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="488" data-original-width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT9LcRO3gjCqPzY9cVF53Jmvn1dtA2DGNsPtY3uLntLfPX-befNF4FthDxnDZgXFrVFy2uUCrKrfTaIKNDqALexiYC3IPanmaDKZV37mRFls8hMb7JIBy0irgWz-mH1S6luyRthfL0T-NIFRUMmdDlxv_YouGf6b3BRiqj4ZPeGujG0AYV864t4Bn13zha/s16000/Error2.png" /></a></div><br /><p>If you view the data in ADSIEdit.msc and open the NTDS Settings</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0GYe-EzGFR3Fh0-zKEW3yyId9nz3v50G9JOi8U3VDsHiVihTSdrGIEmAIFxiT6oEDb3EUu4x1dV1KtC4gxLQJ-S31lvURWK6iTZctXCX_4i-OkFCjgbOpUSoUJaQdPfDgNj9ZQ7pAKZgIHkF12a_Gc487zSBLUACyf7w89kv1_rUH4sCQG0SxY74ME0j/s866/Error3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="614" data-original-width="866" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0GYe-EzGFR3Fh0-zKEW3yyId9nz3v50G9JOi8U3VDsHiVihTSdrGIEmAIFxiT6oEDb3EUu4x1dV1KtC4gxLQJ-S31lvURWK6iTZctXCX_4i-OkFCjgbOpUSoUJaQdPfDgNj9ZQ7pAKZgIHkF12a_Gc487zSBLUACyf7w89kv1_rUH4sCQG0SxY74ME0j/w400-h284/Error3.png" width="400" /></a></div><br /><p>You see the referenced server has a 0ADEL: prefix</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj05ektAt6kNiCbxjrZrRaO7_m9eLVG79ugReN_LjjwlTten85aB-sF2HthU8jEITAbGZjs8rHmlnLV9hdAT1B3IJW3RUKijha-O7Lcrh3m3YHsi8OTtJeMWcCyP9vNF2pd4sif4YN26DOndaU82r4Wr5_o_Zig5s8w75zEtX6tjjX70deeR9sP4OVHi-wL/s455/Error4.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="455" data-original-width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj05ektAt6kNiCbxjrZrRaO7_m9eLVG79ugReN_LjjwlTten85aB-sF2HthU8jEITAbGZjs8rHmlnLV9hdAT1B3IJW3RUKijha-O7Lcrh3m3YHsi8OTtJeMWcCyP9vNF2pd4sif4YN26DOndaU82r4Wr5_o_Zig5s8w75zEtX6tjjX70deeR9sP4OVHi-wL/s16000/Error4.png" /></a></div><br /><p><br /></p><p>The 0ADEL: prefix indicates that the server to which the connection is to be made has been deleted, and the Active Directory Recycle Bin has been enabled.</p><p>The server object is in the Recycle Bin (Deleted Objects container).</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our </span><span style="text-align: left;"><span style="color: #0000ee; font-size: large;"><u><a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-active-directory-documentation-tool" target="_blank">Active Directory Documentation Tool</a></u></span></span><span style="color: #0b5394; font-size: x-large;">?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="317" src="https://www.youtube.com/embed/eLKfnjJROHQ" width="488" youtube-src-id="eLKfnjJROHQ"></iframe></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-85700968822041759652023-08-15T09:12:00.003-07:002023-09-25T01:17:17.965-07:00SOLVED: Why does Active Directory Sites and Services show a replication connection with 0ADEL: in the server name?<p>In Active Directory Sites and Services you may see a replication connection with 0ADEL: in the name.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLiA1KM3AHE1vXcVURPeOivT_NAni32c0dcQFdCrnt1X6l4zuayQyHOBwiZXPeiD8bz348NintC2DSjeStIdZGhAFQuKPd7jPj0dzLNDh58TQZICAeAlFO6QVcIEFG2oTgbhZI4Dv3Ttu7diprCvJD1EROj0MaklctZ0CKI2DyUs-tn7HEJTns5R-DDvKp/s1282/Error.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="846" data-original-width="1282" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLiA1KM3AHE1vXcVURPeOivT_NAni32c0dcQFdCrnt1X6l4zuayQyHOBwiZXPeiD8bz348NintC2DSjeStIdZGhAFQuKPd7jPj0dzLNDh58TQZICAeAlFO6QVcIEFG2oTgbhZI4Dv3Ttu7diprCvJD1EROj0MaklctZ0CKI2DyUs-tn7HEJTns5R-DDvKp/w640-h422/Error.png" width="640" /></a></div><br /><p>The 0ADEL: prefix indicates that the server to which the connection is to be made has been deleted, and the Active Directory Recycle Bin has been enabled.</p><p>The server object is in the Recycle Bin (Deleted Objects container).</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our </span><span style="text-align: left;"><span style="color: #0000ee; font-size: large;"><u><a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-active-directory-documentation-tool" target="_blank">Active Directory Documentation Tool</a></u></span></span><span style="color: #0b5394; font-size: x-large;">?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="317" src="https://www.youtube.com/embed/eLKfnjJROHQ" width="488" youtube-src-id="eLKfnjJROHQ"></iframe></div><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-71257697030388518592023-08-11T08:02:00.004-07:002023-09-25T01:12:10.231-07:00Loading and accessing Group Policy Object settings XML reports in C#.NET and PowerShell<p>If you want to access the settings stored in a Group Policy object you can run the <a href="https://learn.microsoft.com/powershell/module/grouppolicy/get-gporeport" target="_blank">Get-GPOReport</a> PowerShell cmdlet with the name and report type parameters.</p><p>Get-GPOReport -Name "Default Domain Policy" -ReportType Xml<br /><br />(If you want to do this for a Starter GPO there's an extra step to follow <a href="https://david-homer.blogspot.com/2023/06/get-html-or-xml-starter-group-policy.html" target="_blank">detailed here</a>).</p><p>You can also use the Group Policy Management Console.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLdabAmld9EIc02F_e-eX1T1NfxByaJFSY82inlgHfr1FYyxorWJuHFD-Nnqt9MSl7EZqtB_6NGubvRf1wcOawySG_rDUHfWZt5vSOyJfsjbJ3BG2cVnNLpuR3V45vOukbf6yyBsSA8ieD2zu_zCzKJaYB6ITU5afb4kQ0AoY8ofa-708VMUTdK1-R3Ewr/s436/GenerateGroupPolicyObjectReport.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="436" data-original-width="394" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLdabAmld9EIc02F_e-eX1T1NfxByaJFSY82inlgHfr1FYyxorWJuHFD-Nnqt9MSl7EZqtB_6NGubvRf1wcOawySG_rDUHfWZt5vSOyJfsjbJ3BG2cVnNLpuR3V45vOukbf6yyBsSA8ieD2zu_zCzKJaYB6ITU5afb4kQ0AoY8ofa-708VMUTdK1-R3Ewr/w361-h400/GenerateGroupPolicyObjectReport.png" width="361" /></a></div><br /><p>The output however is somewhat complex and there (doesn't seem to be) an XSL file or data model that corresponds to the entire report file.</p><p>To resolve this we have provided a .NET API based on the .NET Framework 4.8.</p><p><br /></p><p><b>CENTREL.ThirdParty.Microsoft.GroupPolicy.Model.dll</b></p><p>This FREE data model and test harness can be found here.<br /><a href="https://www.centrel-solutions.com/support/tools.aspx?feature=GroupPolicyReportApi">https://www.centrel-solutions.com/support/tools.aspx?feature=GroupPolicyReportApi</a></p><p>The API:</p><p></p><ul style="text-align: left;"><li>Loads the GPO report as strongly typed .NET objects.<br /><br /></li><li>Supports PowerShell.<br /><br /></li><li>Allows you to find extensions by type.</li></ul><p></p><p><br /></p><p>We are using this data model in our Server Documentation tool XIA Configuration Server.</p><p><a href="https://www.centrel-solutions.com/xiaconfiguration/it-documentation-software.aspx">https://www.centrel-solutions.com/xiaconfiguration/it-documentation-software.aspx</a></p><p>XIA Configuration Server adds the ability to</p><p></p><ul style="text-align: left;"><li>View the Group Policy object settings in a full user interface.<br /><br /></li><li>Compare the settings between two Group Policy Objects, or two versions of the same Group Policy Object.<br /><br /></li><li>Export the settings to PDF documentation.<br /><br /></li><li>Execute reports against multiple Group Policy Objects in multiple domains in the environment.</li></ul><p></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-group-policy-gpo-documentation-tool" target="_blank">Group Policy Audit and Documentation Tool</a>?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="343" src="https://www.youtube.com/embed/1qt3Y6_rB40" width="584" youtube-src-id="1qt3Y6_rB40"></iframe></div><p><br /></p><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0tag:blogger.com,1999:blog-7892312315294901054.post-58309396409472230002023-08-02T03:24:00.003-07:002023-09-25T01:12:00.597-07:00SOLVED: ActiveDirectory PowerShell error "Get-GPO : Current security context is not associated with an Active Directory domain or forest"<p>When you run the GroupPolicy PowerShell cmdlet <a href="https://learn.microsoft.com/powershell/module/grouppolicy/get-gpo" rel="nofollow" target="_blank">Get-GPO</a> you get the following error:</p><p><i>Get-GPO : Current security context is not associated with an Active Directory domain or forest</i></p><p><br /></p><p>The same thing happens if you run the <a href="https://learn.microsoft.com/powershell/module/grouppolicy/get-gporeport" rel="nofollow" target="_blank">Get-GPOReport</a> cmdlet (and the fix is the same).</p><p><br /></p><p>This can occur if the user who is executing the command is not a member of a domain - perhaps you are running the command using a <b>runas /netonly</b> from a workgroup machine.</p><p><br /></p><p>To resolve this issue you can specify both the server name to use to process the request and the domain from which to read the Group Policy objects.</p><p>Get-GPO -Server "demo-xcs-2022.demoxcs2022.int" -Domain "demoxcs2022.int" -All</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #0b5394; font-size: large;"> While you're here -<br />Why not check out our <a href="https://www.centrel-solutions.com/xiaconfiguration/capabilities.aspx?capability=microsoft-windows-group-policy-gpo-documentation-tool" target="_blank">Group Policy Audit and Documentation Tool</a>?</span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="343" src="https://www.youtube.com/embed/1qt3Y6_rB40" width="584" youtube-src-id="1qt3Y6_rB40"></iframe></div><p><br /></p>David Homerhttp://www.blogger.com/profile/09004880670776520228noreply@blogger.com0