Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Accessing Object Model from PowerShell issue

  Asked By: Stevie    Date: Jan 08    Category: Sharepoint    Views: 3770

Got a strange problem here, posted to TechNet forums a few days ago
as well.

I have a site collection at http://altmapped.company.ru and a /doclib
therein. I usually do most things as DOMAIN\myself - member of
appropriate AD domain and member of SERVER\Administrators. The Server
farm runs under DOMAIN\farm, and other service accounts are
configured as well for IIS worker process, the content access
account, etc.

Now I have another non-sharepoint system that I want to use as a data
source to upload some data. The system is StarTeam but that's
immaterial. I use a separate domain user (DOMAIN\StarTeamSync) to run
a PowerShell PS1 script that successfully uploads data when running
in the context of DOMAIN\myself.

When run in context of DOMAIN\StarTeamSync THE SCRIPT SUCCESSfully
accesses the COM objects associated with StarTeam, but fails to get
through to SharePoint URL http://altmapped.company.ru/doclib with the
following error:

Script Error
Exception calling ".ctor" with "1" argument(s): "The Web application
at http://altmapped.company.ru/doclib could not be found. Verify that
you have typed the URL correctly. If the URL should be serving
existing content, the system administrator may need to add a new
request URL mapping to the intended application."

At line 56, position 41

$script:wssSiteCollection = New-Object

I tried to open the DocLib in Internet Explorer as
DOMAIN\StarTeamSync and it works.

The script fails whether or not I am currently logged on as

Anyone got a clue how to cope with that? Nothing gets written to
Application logs, so I really need some arcane knowledge to get out
of this trouble.



4 Answers Found

Answer #1    Answered By: Anibal Baird     Answered On: Jan 08

Where are the scripts being run  - on the server or somewhere else? It
sounds like you are either trying to run them remotely (you are using OM
calls so they must run on the server itself), or the DOMAIN\StarTeamSync
user does not have the necessary permissions to access the site  content.

Answer #2    Answered By: Karla Morrison     Answered On: Jan 08

The script  is being run  ON the server,
where, apparently, DOMAIN\StarTeamSync has insufficient privileges.

Could you please point me out the least necessary privileges this
user must have in order to perform simple actions like writing files
to the DocLib where it has Full Control?

By the way, there's one more thing (among multitude) that I don't
quite understand - when I run the script in the context  of the
logged on user, it can handle large files up to, say, 160 MB using
IO.File static ReadAllBytes method. The same script when run in a
secondary logon (runas) console session throws
System.OutOfMemoryException. Can I work around that problem? Any

Answer #3    Answered By: Patricia Richardson     Answered On: Jan 08

Depends on exactly how you are going about writing your OM scripts/app.
The specific activity of writing a file requires the user  context to
have write permissions to the existing file (if it's an overwrite or new
version) or the library/folder if it's a new file. However, depending
on how you are accessing  the context  for uploading the file, you might
be using OM methods that require additional permissions. The specific
method you list below requires the user context to have at least read
permissions to the site  collection.

Answer #4    Answered By: Alexandra Patterson     Answered On: Jan 08

Looking at your site  URL


I'm assuming you have an alternate url  mapping to this site?

Have you verified that your incoming/outgoing url's are all setup
properly and that there are entries in IIS for the urls?

Didn't find what you were looking for? Find more on Accessing Object Model from PowerShell issue Or get search suggestion and latest updates.