Skip to main content
edited tags
Link
JoannaW_MSFT
  • 6.6k
  • 1
  • 8
  • 10

Get Site columns: Unauthorized operation in Powershell script

I'm a newby to both powershell scripting and Sharepoint. I'mI am trying to write the following powershell script that will Getget all site columns from my Sharepoint 2010 site and put them in a csv file.

 Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = <My Site URL>
$fileName = "<MyDirectory>\siteColumns.csv"
"Column Title `t Site Column ID `t InternalName `t StaticName `t MaxLength `t Description `t Group `t TypeShortDescription " | out-file $fileName

$site = new-object Microsoft.SharePoint.SPSite($url)
$web = $site.rootweb.Fields
echo "Generation File..."
ForEach ($id in $web)
{
    "$($id.Title) `t $($id.Id) `t $($id.InternalName) `t $($id.StaticName) `t $($id.MaxLength)/$($id.MaxLength) `t $($id.Description) `t $($id.Group) `t $($id.TypeShortDescription) " | Out-File $fileName -Append
}
$site.Dispose()

The script runs fine until it reaches the ForEach loop. When it reaches this point I getam getting the following error:

The following exception was thrown when trying to enumerate the collection: "Attempted to perfo
rm an unauthorized operation.".
At C:\Users\IP2560_a\Documents\PSScripts\GetSiteColumns.ps1:9 char:8
+ ForEach <<<<  ($id in $web)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : ExceptionInGetEnumerator

I am running in a shell that has Administrator error. Are ther somethere any permissions I need to set up in Sharepoint itself or something else? 

Any help would be appreciated.

Unauthorized operation in Powershell script

I'm a newby to both powershell scripting and Sharepoint. I'm trying to write the following powershell script that will Get all site columns from my Sharepoint 2010 site and put them in a csv file.

 Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = <My Site URL>
$fileName = "<MyDirectory>\siteColumns.csv"
"Column Title `t Site Column ID `t InternalName `t StaticName `t MaxLength `t Description `t Group `t TypeShortDescription " | out-file $fileName

$site = new-object Microsoft.SharePoint.SPSite($url)
$web = $site.rootweb.Fields
echo "Generation File..."
ForEach ($id in $web)
{
    "$($id.Title) `t $($id.Id) `t $($id.InternalName) `t $($id.StaticName) `t $($id.MaxLength)/$($id.MaxLength) `t $($id.Description) `t $($id.Group) `t $($id.TypeShortDescription) " | Out-File $fileName -Append
}
$site.Dispose()

The script runs fine until it reaches the ForEach loop. When it reaches this point I get the following error:

The following exception was thrown when trying to enumerate the collection: "Attempted to perfo
rm an unauthorized operation.".
At C:\Users\IP2560_a\Documents\PSScripts\GetSiteColumns.ps1:9 char:8
+ ForEach <<<<  ($id in $web)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : ExceptionInGetEnumerator

I am running in a shell that has Administrator error. Are ther some permissions I need to set up in Sharepoint itself or something? Any help would be appreciated.

Get Site columns: Unauthorized operation in Powershell script

I'm a newby to both powershell scripting and Sharepoint. I am trying to write the following powershell script that will get all site columns from my Sharepoint 2010 site and put them in a csv file.

Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = <My Site URL>
$fileName = "<MyDirectory>\siteColumns.csv"
"Column Title `t Site Column ID `t InternalName `t StaticName `t MaxLength `t Description `t Group `t TypeShortDescription " | out-file $fileName

$site = new-object Microsoft.SharePoint.SPSite($url)
$web = $site.rootweb.Fields
echo "Generation File..."
ForEach ($id in $web)
{
    "$($id.Title) `t $($id.Id) `t $($id.InternalName) `t $($id.StaticName) `t $($id.MaxLength)/$($id.MaxLength) `t $($id.Description) `t $($id.Group) `t $($id.TypeShortDescription) " | Out-File $fileName -Append
}
$site.Dispose()

The script runs fine until it reaches the ForEach loop. When it reaches this point I am getting the following error:

The following exception was thrown when trying to enumerate the collection: "Attempted to perfo
rm an unauthorized operation.".
At C:\Users\IP2560_a\Documents\PSScripts\GetSiteColumns.ps1:9 char:8
+ ForEach <<<<  ($id in $web)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : ExceptionInGetEnumerator

I am running in a shell that has Administrator error. Are there any permissions I need to set up in Sharepoint itself or something else? 

Any help would be appreciated.

Source Link

Unauthorized operation in Powershell script

I'm a newby to both powershell scripting and Sharepoint. I'm trying to write the following powershell script that will Get all site columns from my Sharepoint 2010 site and put them in a csv file.

 Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = <My Site URL>
$fileName = "<MyDirectory>\siteColumns.csv"
"Column Title `t Site Column ID `t InternalName `t StaticName `t MaxLength `t Description `t Group `t TypeShortDescription " | out-file $fileName

$site = new-object Microsoft.SharePoint.SPSite($url)
$web = $site.rootweb.Fields
echo "Generation File..."
ForEach ($id in $web)
{
    "$($id.Title) `t $($id.Id) `t $($id.InternalName) `t $($id.StaticName) `t $($id.MaxLength)/$($id.MaxLength) `t $($id.Description) `t $($id.Group) `t $($id.TypeShortDescription) " | Out-File $fileName -Append
}
$site.Dispose()

The script runs fine until it reaches the ForEach loop. When it reaches this point I get the following error:

The following exception was thrown when trying to enumerate the collection: "Attempted to perfo
rm an unauthorized operation.".
At C:\Users\IP2560_a\Documents\PSScripts\GetSiteColumns.ps1:9 char:8
+ ForEach <<<<  ($id in $web)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : ExceptionInGetEnumerator

I am running in a shell that has Administrator error. Are ther some permissions I need to set up in Sharepoint itself or something? Any help would be appreciated.