<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IIS | TekCookie</title>
	<atom:link href="https://tekcookie.com/category/iis/feed/" rel="self" type="application/rss+xml" />
	<link>https://tekcookie.com</link>
	<description>Everything about IT</description>
	<lastBuildDate>Sun, 13 Jun 2021 12:56:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/tekcookie.com/wp-content/uploads/2021/06/cropped-TekCookie-211.png?fit=32%2C17&#038;ssl=1</url>
	<title>IIS | TekCookie</title>
	<link>https://tekcookie.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">174510684</site>	<item>
		<title>IIS Authorization Rules using PowerShell</title>
		<link>https://tekcookie.com/iis-authorization-rules-using-powershell/</link>
					<comments>https://tekcookie.com/iis-authorization-rules-using-powershell/#comments</comments>
		
		<dc:creator><![CDATA[jeffythampi]]></dc:creator>
		<pubDate>Sun, 01 Mar 2020 08:40:00 +0000</pubDate>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Add IIS Authorization Rules]]></category>
		<category><![CDATA[Add IIS Authorization Rules using PowerShell]]></category>
		<category><![CDATA[Add or Remove IIS Authorization Rules using PowerShell]]></category>
		<category><![CDATA[IIS Authorization Rules]]></category>
		<category><![CDATA[IIS Authorization Rules using PowerShell]]></category>
		<category><![CDATA[Remove IIS Authorization Rules]]></category>
		<category><![CDATA[Remove IIS Authorization Rules using PowerShell]]></category>
		<guid isPermaLink="false">https://adminscripter.wordpress.com/?p=313</guid>

					<description><![CDATA[Add or Remove IIS Authorization Rules using PowerShell Adding to the post &#8211; https://tekcookie.com/iis-client-certificate-mapping-using-powershell/ Once the client certificate is mapped, we have to add authorization rules in the website for providing access to the users. From the client certificate mapping script, the variable $results has the user info details captured from the client certificates. Using [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">Add or Remove IIS Authorization Rules using PowerShell</h1>



<p>Adding to the post &#8211; <a href="https://tekcookie.com/iis-client-certificate-mapping-using-powershell/">https://tekcookie.com/iis-client-certificate-mapping-using-powershell/</a></p>



<p>Once the client certificate is mapped, we have to add authorization rules in the website for providing access to the users.</p>



<p>From the client certificate mapping script, the variable <code>$results</code> has the user info details captured from the client certificates. Using this we have to add allow authorization rules in the website.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">foreach($userInfo in $results) {     
   Add-WebConfiguration -Filter "system.webServer/security/authorization" `     
   -Value @{accessType="Allow"; users="$userInfo.UserName"} -PSPath IIS:\sites\websitename 
}</code></pre>



<p>The above code will create authorization rule &#8211; Allow for the users in the list.</p>



<p>Authorization rules can be created in the IIS server level which can be inherited to the website or as local to the website</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">#Add IIS Authorization rules to web site at applicationHost.config 
add-WebConfiguration -Filter "system.webServer/security/authorization" ` 
-Value @{accessType="Allow"; users="user1"} -pspath 'MACHINE/WEBROOT/APPHOST' -location 'websitename' 

#Add IIS Authorization rules to web site at web.config add-WebConfiguration -Filter "system.webServer/security/authorization" ` 
-Value @{accessType="Allow"; users="user2"} -PSPath IIS:\sites\websitename</code></pre>



<figure class="wp-block-image size-large"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/tekcookie.com/wp-content/uploads/2020/02/iis_authorizationrules.jpg?w=1080&#038;ssl=1" alt="" class="wp-image-319"/><figcaption>Configuration entry added to web.config is listed as &#8216;Local&#8217; and entry added to applicationHost.config is listed as &#8216;Inherited&#8217;</figcaption></figure>



<p>Removing authorization rules</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">#Remove IIS Authorization rules to web site at web.config 
Remove-WebConfigurationProperty -Filter "system.webServer/security/authorization" ` 
-pspath IIS:\Sites\websitename -name . -AtElement @{Users='user2'} 

#Remove IIS Authorization rules to web site at applicationHost.config 
Remove-WebConfigurationProperty -Filter "system.webServer/security/authorization" ` 
-pspath 'MACHINE/WEBROOT/APPHOST' -location 'websitename' -name . -AtElement @{Users='user1'}</code></pre>



<div style="height:70px" aria-hidden="true" class="wp-block-spacer"></div>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Thank you for reading my post, Hope this is helpful to you !!!</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://tekcookie.com/iis-authorization-rules-using-powershell/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">313</post-id>	</item>
		<item>
		<title>IIS Client Certificate Mapping using PowerShell</title>
		<link>https://tekcookie.com/iis-client-certificate-mapping-using-powershell/</link>
					<comments>https://tekcookie.com/iis-client-certificate-mapping-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[jeffythampi]]></dc:creator>
		<pubDate>Wed, 11 Dec 2019 05:38:45 +0000</pubDate>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SSL/TLS]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Client Certificate Mapping]]></category>
		<category><![CDATA[Client Certificate Mapping using PowerShell]]></category>
		<category><![CDATA[IIS Client Certificate Mapping]]></category>
		<category><![CDATA[IIS Client Certificate Mapping using PowerShell]]></category>
		<category><![CDATA[Migrate IIS client certificate]]></category>
		<category><![CDATA[Migrate IIS client certificates]]></category>
		<category><![CDATA[Migrate IIS client certificates from Windows 2003 to Windows 2016]]></category>
		<category><![CDATA[Migrate IIS client certificates from Windows 2003 to Windows 2016 using PowerShell]]></category>
		<guid isPermaLink="false">https://adminscripter.wordpress.com/?p=240</guid>

					<description><![CDATA[Migrate IIS client certificates from Windows 2003 to Windows 2016 using PowerShell To import the certificate, we need to have the public key information exported to .cer certificate file Once the Information is collected, users have to be created locally on the server After user creation, In IIS oneToOneMappings, we have to add the certificate [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">Migrate IIS client certificates from Windows 2003 to Windows 2016 using PowerShell</h1>



<p>To import the certificate, we need to have the public key information exported to .cer certificate file</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">#Get the File names of certificate
$names = Get-ChildItem C:\Users\Administrator\Desktop\Certs\
$results = @()
#looping through each certificates to fetch Public Key and User Info
foreach($name in $names) {
	#reading content of the file
    $CertData = Get-Content $name.FullName
    $CertData = $CertData[1..($CertData.Length-2)]	#To remove first and last line in the content
    $publicKey = ""
    $CertData | % {
        $publicKey += $_.ToString()
    }
	
	#Getting user name from certificate
	$certif = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
	$certif.Import($name.FullName)
	$userName = $certif.GetName().ToString().Split(",")[-1].Replace("CN=","").Replace(" ","")
    $result = New-Object -TypeName PSObject -Property @{
    FileName = $name.Name
    UserName = $userName
    PublicKey = $publicKey
    }
	
	#List of all certificate data and user name
    $results += $result
}
#$results | select FileName, UserName, PublicKey</code></pre>



<p>Once the Information is collected, users have to be created locally on the server</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">foreach($userInfo in $results) {
    New-LocalUser -Name $userInfo.UserName -Password (ConvertTo-SecureString "ThisIsAGoodPassword123" -AsPlainText -Force)
    #Set-LocalUser -Name $userInfo.UserName -Password (ConvertTo-SecureString "ThisIsAGoodPassword123@2k" -AsPlainText -Force)
}</code></pre>



<p>After user creation, In IIS oneToOneMappings, we have to add the certificate public key along with the respective user name and password</p>



<p>Both foreach loops can be merged. I have divided the foreach for better readability.</p>



<pre class="wp-block-code"><code lang="powershell" class="language-powershell">foreach($userInfo in $results) {
    Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'EveryCarParts1' `
    -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication/oneToOneMappings" `
    -name '.' `
    -value @{enabled='True';userName=$userInfo.UserName;password='ThisIsAGoodPassword123';certificate=$userInfo.PublicKey}
}</code></pre>



<p>For adding Web configuration Property, I got the clue from following post<br><a href="https://stackoverflow.com/questions/29497971/configuring-iis-client-certificate-mapping-authentication" target="_blank" rel="noreferrer noopener">https://stackoverflow.com/questions/29497971/configuring-iis-client-certificate-mapping-authentication</a></p>



<div style="height:70px" aria-hidden="true" class="wp-block-spacer"></div>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Thank you for reading my post. Hope this is helpful to you.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://tekcookie.com/iis-client-certificate-mapping-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">240</post-id>	</item>
	</channel>
</rss>
