The first sorry for my english, but I need your help with powershell scripting. I must config IIS server with powershell script and I have problem with "add application". I need to check whether webapplication exist in site. I want choose all webapplication in site "testsite2"
$webapplication=Get-WebApplication | Where-Object {$_. applicationpool -eq "testsite2"} | select -expand Name;
But I have problem that command is ending with error
select : Property "Name" cannot be found.At line:1 char:75 Get-WebApplication | Where-Object {$_. applicationpool -eq "testsite2"} | select ... CategoryInfo : InvalidArgument: (Microsoft.IIs.P...gurationElement:PSObject) [Select-Object], PSArgumentException FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
I don´t understand. What have I do when I want choose value from column "Name"?
I get same result
Get-ChildItem –Path IIS:\AppPools\ | Where-Object {$_. Name -eq "testsite2"} | select -ExpandProperty applications
result:
select : Property "applications" cannot be found. At line:1 char:80 Get-ChildItem –Path IIS:\AppPools\ | Where-Object {$_. Name -eq "testsite2"} | s ... CategoryInfo : InvalidArgument: (Microsoft.IIs.P...gurationElement:PSObject) [Select-Object], PSArgumentException FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand