I need to add an application pool remotely and I was trying to use the following:
$script = {
Import-Module WebAdministration;
New-Item IIS:\AppPools\$IRTPoolName;
}
Invoke-Command -ComputerName $targetName -ScriptBlock $script -credential $cred -UseSSL
The problem is that once I run it I get a prompt with:
type:
I don't have any problems with authentication and I can invoke other commands like a simple dir but not that one. Any thoughts?
The new-item
cmdlet is asking you to specify a type, because it doesn't know what $IRTPoolName
is.
Invoke-Command -ComputerName $targetName -ScriptBlock {
Param($IRTPoolName)
Import-Module WebAdministration
New-Item IIS:\AppPools\$IRTPoolName
} -ArgumentList $IRTPoolName -credential $cred -UseSSL