Samuel
Samuel

Reputation: 651

Cannot use Powershell to set a remote application pool properties

I have script which can successfully create application pool and set properties in IIS. And I use following code to set it remotely.

Invoke-Command -ComputerName $strSvr -ScriptBlock $script

And code in script are like:

Import-Module WebAdministration

$appPool = New-Item $apppoolname        
$appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion
$appPool | Set-ItemProperty -Name "enable32BitAppOnWin64" -Value "true" 

$appPool.processModel.username = $domainusername        
$appPool.processModel.password = $domainuserpassword        
$appPool.processModel.identityType = 3
$appPool | set-item 

The problem is: the code to set identity is working, but code to set .Net version and enable32bitapplication failed. The same code works on local machine.

Any idea?

P.S. I am using PS3.0

Thanks heaps!

Upvotes: 0

Views: 2271

Answers (1)

Pavel
Pavel

Reputation: 173

Code that works for me:

  Import-Module "WebAdministration"
  $pool = New-WebAppPool -Name $poolname -Force

  $pool.processModel.username = $domainusername
  $pool.processModel.password = $domainuserpassword
  $pool.processModel.identityType = 3
  $pool | Set-Item 

  Set-ItemProperty ("IIS:\AppPools\$poolname") -Name managedRuntimeVersion -Value "v4.0"
  Set-ItemProperty ("IIS:\AppPools\$poolname") -Name managedPipelineMode -Value 0

  Start-WebAppPool -Name $poolname 

Upvotes: 2

Related Questions