Quantcast
Channel: User learning... - Stack Overflow
Viewing all articles
Browse latest Browse all 38

Set "Start Application Pool Immediately" to true and setting username password when creating app pool with power shell

$
0
0

I am creating app pools via power shell script.

  1. Even after looking around i couldn't find how to set the "Start Application Pool immediately" to true. How can i do this?

  2. Also, if the userName/password are provided then i want to set it otherwise it should be Application Pool Identity. Am i doing it correctly?

Here is the function

Function Create-AppPools($appPoolName, $appPoolDotNetVersion, $managedPipelineMode, $startMode, $userName, $password) {    if(!$appPoolName){        return;    }    Write-Host ""    #navigate to the app pools root    cd IIS:\AppPools\    #check if the app pool exists    if (!(Test-Path $appPoolName -pathType container))    {        Write-Host "`t Creating AppPool: "+ $appPoolName        #create the app pool        $appPool = New-Item $appPoolName        if($appPoolDotNetVersion){            $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $appPoolDotNetVersion        }        if(@managedPipelineMode){            $appPool | Set-ItemProperty -Name "managedPipelineMode" -Value $managedPipelineMode        }        if($startMode){            $appPool | Set-ItemProperty -Name "startMode" -Value $startMode        }        if($userName -and $password){            $apppool | Set-ItemProperty -Name processmodel -value @{userName = $userName;password=$password;identitytype=3}        }        else{            $apppool | Set-ItemProperty -Name "ProcessModel.IdentityType" -value  3        }        Write-Host "`t`t AppPool: "+ $appPoolName +" created successfully" -ForegroundColor Green    }    else{        Write-Host "`t AppPool "+ $appPoolName +" already exists" -ForegroundColor Blue    }}

Update 1: Check github for sample scripts after i got my question answered.


Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>