Arrays 在powershell中的Foreach登录中的Foreach

Arrays 在powershell中的Foreach登录中的Foreach,arrays,powershell,foreach,Arrays,Powershell,Foreach,如何使此逻辑在powershell中工作 $i = ("SharePointCDPTestProject1_Feature1", "SharePointCDPTestProject1_Feature2", "SharePointCDPTestProject1_Feature3"); $a = Get-SPSite http://localhost/sts*; Foreach($id in $i) { Foreach($p in $a) { Enable-SPF

如何使此逻辑在powershell中工作

$i = ("SharePointCDPTestProject1_Feature1", "SharePointCDPTestProject1_Feature2", "SharePointCDPTestProject1_Feature3"); 
$a = Get-SPSite  http://localhost/sts*;
Foreach($id in $i)
{
    Foreach($p in $a)
    {
        Enable-SPFeature –identity $id -URL $p
    }
}

对不起。。我在ps

ForEach对象中是noob:无法绑定参数“Process”。无法将类型“System.String”的“{”值转换为类型“System.Management.Automation.ScriptBlock”。在第1行char:13+$i | Foreach$i=(“SharePointCDPTestProject1_功能1”、“SharePointCDPTestProject1_功能2”、“SharePointCDPTestProject1_功能3”);$a=Get SPWebApplication”“| Get SPSite-Limit All | Get SPWeb-Limit All-Foreach($id in$i){Foreach($p in$a){Enable-SPFeature–identity$id-URL$p.URL}对我有用
$i = ("SharePointCDPTestProject1_Feature1", "SharePointCDPTestProject1_Feature2", "SharePointCDPTestProject1_Feature3"); 
$a = Get-SPSite  http://localhost/sts*;
$i | Foreach{
    #save current id
    $id=$_
    $a | Foreach{
        Enable-SPFeature –identity $id -URL $_
    }
}