Bonjour tout le monde;
je ne suis pas un expert en PowerShell, je viens de créer le Script ci-dessous pour la création d'un Pool d'application ainsi qu'un site avec IIS, et j'arrete pas d'avoir cette erreur a la fin du script. Est-ce que quelqu'un pourrais m'aider SVP??

Message d'erreur:
Set-ItemProperty : Le type ne correspond pas. (Exception de HRESULT : 0x80020005 (DISP_E_TYPEMISMATCH))
Au niveau de D:\Appooltest.ps1*: 130 Caractère*: 35
+ $iisApp | Set-ItemProperty <<<< -Name "applicationPool" -Value $AppPoolName
+ CategoryInfo : NotSpecified: ( [Set-ItemProperty], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.SetItemPropert
yCommand



Script:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Import-Module WebAdministration

$directoryPath = "D:\Inetpub"

Write-Host -ForegroundColor Yellow "Creation de la Pool d'application"
$AppPoolName = Read-Host  "Voulez vous Saisir le nom du Pool d'application"
$iisAppPoolDotNetVersion = Read-Host  "`n`rVoulez vous Saisir la version .Net:`n`r`1-V4.0`n`r2-V2.0`n`r `n`r"
if ($iisAppPoolDotNetVersion -eq "1") 
{
	$iisAppPoolDotNetVersion = "v4.0"
}
elseif ($iisAppPoolDotNetVersion -eq "2") 
{
	$iisAppPoolDotNetVersion = "v2.0"
}

$Pipeline=  Read-Host  "`n`rVoulez vous Saisir le mode de la Pipline Gerer:`n`r`1-Integrated`n`r2-Classic`n`r`n`r"
if ($Pipeline -eq "1") 
{
	$Pipeline = "0"
}
elseif ($Pipeline -eq "2") 
{
	$Pipeline = "1"
}

$Identity= Read-Host  "`n`rVoulez vous indiquez quel identité pour le compte:`n`r`1-LocalSystem`n`r`2-LocalService`n`r`3-NetworkService`n`r`4-Specified user`n`r"
if ($Identity -eq "1") 
{
	$Identity = 0
	$AppPoolPath = "IIS:\AppPools"
	cd $AppPoolPath
	if (Test-Path $AppPoolName) { Write-Host -ForegroundColor red "$AppPoolName existe deja, modifier le nom de l'application pool." }
	else
	{
		$appPool = New-Item $AppPoolName
		$appPool | Set-ItemProperty -Name managedRuntimeVersion -Value $iisAppPoolDotNetVersion
		$appPool | Set-ItemProperty -Name managedPipelineMode -Value $Pipeline
		$appPool | Set-ItemProperty -Name processModel.identityType -Value $Identity
		
		
	}
}

elseif ($Identity -eq "2") 
{
	$Identity = 1
	$AppPoolPath = "IIS:\AppPools"
	cd $AppPoolPath
	if (Test-Path $AppPoolName) { Write-Host -ForegroundColor red "$AppPoolName existe deja, modifier le nom de l'application pool." }
	else
	{
		$appPool = New-Item $AppPoolName
		$appPool | Set-ItemProperty -Name managedRuntimeVersion -Value $iisAppPoolDotNetVersion
		$appPool | Set-ItemProperty -Name managedPipelineMode -Value $Pipeline
		$appPool | Set-ItemProperty -Name processModel.identityType -Value $Identity
		
		
	}
}
elseif ($Identity -eq "3") 
{
	$Identity = 2
	$AppPoolPath = "IIS:\AppPools"
	cd $AppPoolPath
	if (Test-Path $AppPoolName) { Write-Host -ForegroundColor red "$AppPoolName existe deja, modifier le nom de l'application pool." }
	else
	{
		$appPool = New-Item $AppPoolName
		$appPool | Set-ItemProperty -Name managedRuntimeVersion -Value $iisAppPoolDotNetVersion
		$appPool | Set-ItemProperty -Name managedPipelineMode -Value $Pipeline
		$appPool | Set-ItemProperty -Name processModel.identityType -Value $Identity
		
	}
}

elseif ($Identity -eq "4") 
{
	$Identity = 3
	$AppPoolUser = Read-Host  "Voulez vous Saisir le nom du compte Domaine\utilisateur :   "
	$AppPoolPwd = Read-Host  "Voulez vous Saisir Le mot de passe:"
	$AppPoolPath = "IIS:\AppPools"
	cd $AppPoolPath
	if (Test-Path $AppPoolName) { Write-Host -ForegroundColor red "$AppPoolName existe deja, modifier le nom de l'application pool" }
	else
	{
		$appPool = New-Item $AppPoolName
		$appPool | Set-ItemProperty -Name managedRuntimeVersion -Value $iisAppPoolDotNetVersion
		$appPool | Set-ItemProperty -Name managedPipelineMode -Value $Pipeline
		$appPool | Set-ItemProperty -Name processModel.identityType -Value $Identity
		$appPool | Set-ItemProperty -Name processModel.username -Value $AppPoolUser
		$appPool | Set-ItemProperty -Name processModel.password -Value $AppPoolPwd

		
	}
	
}

#Création ddu site


Write-Host "******Creation du Site d'application*******"
#navigate to the sites root
$iisAppName = Read-Host "`n`rVoulez vous Saisir le nom du site `n`r"
$IISPath = "IIS:\Sites\"

cd $IISPath

$IpAdressBinding = "IIS:\SslBindings"


#check if the site exists
if (Test-Path $iisAppName -pathType container)
{
    return "Le site, $iisAppName, Existe deja!";
}
else
{
#create the site
    $Protocol = Read-Host "`n`rVoulez vous choisir le Protocol :`n`r1- HTTP`n`r2- HTTPS`n`r"
	dir $IpAdressBinding
    $IP = Read-Host "`n`rVoulez vous Saisir l'adress IP : `n`r"
	$HH = Read-Host "`n`rVoulez vous Saisir le host header : `n`r"

    if ($Protocol -eq "1") 
    {
        
        $Binding = @{protocol="http";bindingInformation=$IP + ":"+ 80 + ":" + $HH}
    	$iisApp = New-Item $iisAppName -bindings $Binding -physicalPath $directoryPath
        $iisApp | Set-ItemProperty -Name "applicationPool" -Value $AppPoolName
        
    }
    elseif ($Protocol -eq "2") 
    {
        $Binding = @{protocol="https";bindingInformation=$IP + ":"+ 443 + ":" + $HH}
    	$iisApp = New-Item $iisAppName -bindings $Binding -physicalPath $directoryPath
        $iisApp | Set-ItemProperty -Name "applicationPool" -Value $AppPoolName
        
    } 
}