Skip to main content

Im trying to find active futures for my site from below script but im prompt with error ( cannot call a method on a null-valued expression) Appreciate your help

$activeFeatures = Get-SPFeature -Site --site URL-- $allSiteFeatures | ForEach-Object { $active = $false foreach($feature in $activeFeatures) { if($feature.Id.ToString() -eq $.Id.ToString()) { $active = $true } } if($active) { $_.DisplayName } }

$activeFeatures = Get-SPFeature -Site --site _URL--
$allSiteFeatures | ForEach-Object 
{
$active = $false
    foreach($feature in $activeFeatures)
    {
      if($feature.Id.ToString() -eq $_.Id.ToString())
      {
         $active = $true
      }
    }
    if($active)
    {
       $_.DisplayName
    }
}

ERROR----------- You cannot call a method on a null-valued expression. //At line:5 char:51 //+ if($feature.Id.ToString() -eq $_.Id.ToString <<<< ()) // + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeE xception + FullyQualifiedErrorId : InvokeMethodOnNull

ERROR----------- You cannot call a method on a null-valued expression. //At line:5 char:51 //+ if($feature.Id.ToString() -eq $_.Id.ToString <<<< ()) // + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeE xception + FullyQualifiedErrorId : InvokeMethodOnNull

Im trying to find active futures for my site from below script but im prompt with error ( cannot call a method on a null-valued expression) Appreciate your help

$activeFeatures = Get-SPFeature -Site --site URL-- $allSiteFeatures | ForEach-Object { $active = $false foreach($feature in $activeFeatures) { if($feature.Id.ToString() -eq $.Id.ToString()) { $active = $true } } if($active) { $_.DisplayName } }

ERROR----------- You cannot call a method on a null-valued expression. //At line:5 char:51 //+ if($feature.Id.ToString() -eq $_.Id.ToString <<<< ()) // + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeE xception + FullyQualifiedErrorId : InvokeMethodOnNull

Im trying to find active futures for my site from below script but im prompt with error ( cannot call a method on a null-valued expression) Appreciate your help

$activeFeatures = Get-SPFeature -Site --site _URL--
$allSiteFeatures | ForEach-Object 
{
$active = $false
    foreach($feature in $activeFeatures)
    {
      if($feature.Id.ToString() -eq $_.Id.ToString())
      {
         $active = $true
      }
    }
    if($active)
    {
       $_.DisplayName
    }
}

ERROR----------- You cannot call a method on a null-valued expression. //At line:5 char:51 //+ if($feature.Id.ToString() -eq $_.Id.ToString <<<< ()) // + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeE xception + FullyQualifiedErrorId : InvokeMethodOnNull

Source Link
user1953672
  • 341
  • 1
  • 7
  • 14

Powershell command to find active features for site collection

Im trying to find active futures for my site from below script but im prompt with error ( cannot call a method on a null-valued expression) Appreciate your help

$activeFeatures = Get-SPFeature -Site --site URL-- $allSiteFeatures | ForEach-Object { $active = $false foreach($feature in $activeFeatures) { if($feature.Id.ToString() -eq $.Id.ToString()) { $active = $true } } if($active) { $_.DisplayName } }

ERROR----------- You cannot call a method on a null-valued expression. //At line:5 char:51 //+ if($feature.Id.ToString() -eq $_.Id.ToString <<<< ()) // + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeE xception + FullyQualifiedErrorId : InvokeMethodOnNull