Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powershell script to change feature permissions in IIS

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I am trying to create a script to follow a citrix doc to enable IIS and XML integration. (article CTX125107)

Link

One of the steps is to Edit Feature permissions within a Virtual Directory and Web Application. It must be changed to 'Execute'
I am sure there is a one liner for powershell that does this but I cannot find it.

Does anyone know how to do this?

I current have a Scripts virtual directory under the Default Web Site

The script i have so far is as follows and all I need now is to change the feature permissions to execute and create a registry key.

Of course i have not even tested this script yet so I am not sure if it will work or not.

My code is below for the script:

Code:
Import-Module "WebAdministration"
Stop-Service ctxhttp
$svc = Get-Service ctxhttp
while($svc.State -ne 'Stopped')
{
   Start-Sleep -Seconds 1
}

#Uninstalls Citrix XML Service
(Get-WmiObject Win32_Service -filter "name='ctxxmlss'").Delete()
#Creates Scripts Directory & Copies files to scripts directory
cd IIS:
Write-Host "Starting Script" -foregroundcolor "Cyan"
$dpath = "c:\inetpub\scripts"
$spath = "c:\Program Files(x86)\Citrix\System32"
Write-Host "Verifying reuired directories exist..." -foregroundcolor "Yellow"
if (!(test-path -path $dpath))
	{
	Write-Host "Creating Directory : " + dpath -foregroundcolor "Yellow"
	New-Item $dpath -ItemType directory
	}
if (!(test-path -path $dpath + "\CtxAdmin"))
	{
	Write-Host "Creating Directory : " + dpath + "\CtxAdmin" -foregroundcolor "Yellow"
	New-Item $dpath + "\CtxAdmin" -ItemType directory
	}
if (!(test-path -path $dpath + "\resource"))
	{
	Write-Host "Creating Directory : " + dpath + "\resource" -foregroundcolor "Yellow"
	New-Item $dpath + "\resource" -ItemType directory
	}
if (!(test-path -path $dpath + "\resource\en"))
	{
	Write-Host "Creating Directory : " + dpath + "\resource\en" -foregroundcolor "Yellow"
	New-Item $dpath + "\resource\en" -ItemType directory
	}
Write-Host "All directories in place and/or created" -foregroundcolor "Green"

#copy approproate files
vfile$="ctxconfproxy.dll"
Write-Host "Copying Files...Please wait.." -foregroundcolor "Yellow"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="ctxsta.config"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="ctxsta.dll"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="ctxxmlss.txt"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="radexml.dll"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="wpnbr.dll"
if (!(Test-Path $dpath + "\" + vfile$))
{
Copy-Item $spath + "\" + vfile$ $dpath
}
vfile$="ctxstaui.dll"
if (!(Test-Path $dpath + "\resources\en\" + vfile$))
{
Copy-Item $spath + "\resources\en\" + vfile$ $dpath + "\resources\en"
}
Write-Host "File Copies completed.." -foregroundcolor "Green"
Write-Host "Starting IIS configuration" -foregroundcolor "Yellow"
Write-Host "Adding new Site ISAPI Restrictions...Please Wait.." -foregroundcolor "Yellow"
set-webconfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='c:\inetpub\scripts\CtxConfProxy.dll']/@allowed" -value "True" -PSPath:IIS:set-webconfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='c:\inetpub\scripts\ctxsta.dll']/@allowed" -value "True" -PSPath:IIS:set-webconfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='c:\inetpub\scripts\radexml.dll']/@allowed" -value "True" -PSPath:IIS:set-webconfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='c:\inetpub\scripts\wpnbr.dll']/@allowed" -value "True" -PSPath:IIS:set-webconfiguration "/system.webServer/security/isapiCgiRestriction/add[@path='c:\inetpub\scripts\CtxAdmin\ctxadmin.dll']/@allowed" -value "True" -PSPath:IIS:Write-Host "Site ISAPI Restrictions completed!" -foregroundcolor "Green"
Write-Host "Creating Appplication Pools...Please Wait..." -foregroundcolor "Yellow"
New-Item IIS:\AppPools\CtxScriptsPool
Write-Host "Creating Appplication Pools...Completed..." -foregroundcolor "Green"
Write-Host "Configuring Application Pool Settings...Please Wait..." -foregroundcolor "Yellow"
Set-ItemProperty IIS:\AppPools\CtxScriptsPool -name managedRuntimeVersion -value v2.0
Set-ItemProperty IIS:\AppPools\CtxScriptsPool -name managedPipelineMode -value Classic
Set-ItemProperty IIS:\AppPools\CtxScriptsPool -name autoStart -value true
Set-ItemProperty -Path IIS:\AppPools\CtxScriptsPool-Name ProcessModel.IdentityType -value 2
Set-ItemProperty IIS:\AppPools\CtxAdminPool -name managedRuntimeVersion -value v2.0
Set-ItemProperty IIS:\AppPools\CtxAdminPool -name managedPipelineMode -value Classic
Set-ItemProperty IIS:\AppPools\CtxAdminPool -name autoStart -value true
Set-ItemProperty -Path IIS:\AppPools\CtxAdminPool-Name ProcessModel.IdentityType -value 2
Write-Host "Configuring Application Pool Settings...Complete..." -foregroundcolor "Green"

Write-Host "Creating IIS Scripts Application...Please Wait..." -foregroundcolor "Yellow"
New-Item "IIS:\Sites\Default Web Site\Scripts" -physicalPath c:\inetpub\Scripts -type Application
Set-ItemProperty iis:\Sites\Default Web Site\Scripts -Name applicationpool -Value CtxScriptsPool
Write-Host "Creating IIS Scripts Application...Complete..." -foregroundcolor "Green"
Write-Host "Creating IIS CtxAdmin Application...Please Wait..." -foregroundcolor "Yellow"
New-Item "IIS:\Sites\Default Web Site\CtxAdmin" -physicalPath c:\inetpub\Scripts\ctxadmin -type Application
Set-ItemProperty iis:\Sites\Default Web Site\CtxAdmin -Name applicationpool -Value CtxAdminPool
Write-Host "Creating IIS CtxAdmin Application...Complete..." -foregroundcolor "Green"
Write-Host "Creating CTXIntegrated Virtual Directory...Please Wait..." -ForegroundColor "Yellow"
New-Item 'IIS:\Sites\Default Web Site\Scripts\CtxIntegrated' -Type VirtualDirectory -PhysicalPath C:\inetpub\Scripts
 
Take a look at AppCmd which you can automate with PowerShell.




I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top