An error The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered after launching a ps1 script from cmd file.

I'm trying to load sharepoint script from *.cmd file. 
I have Sharepoint 2010 installed on Windows 7 x64 and SQL server 2008r2.
My cmd file is: 
Powershell -v 2 -NonInteractive -NoLogo -File 1.ps1
My sharepoint file 1.ps1 is:
$snapin="Microsoft.SharePoint.PowerShell"
if ($action -eq $null -or $action -eq '')
{<br />
# Action by default is complete uninstallation.
$action='uninstall'
$uninstall = $true
else
$action = $action.ToLower()
switch($action)
{ $_ -eq "uninstall" } { $uninstall = $true; break }
{ $_ -eq "removesolution" } { $removeSolution = $true; break }
{ $_ -eq "deactivatecorpus" } { $deactivateCorpus = $true; break }
{ $_ -eq "deactivatesupport" } { $deactivateSupport = $true; break }
default { Write-Host -f Red "Error: Invalid action: $action "; Exit -1 }
Check the Sharepoint snapin availability.
if (Get-PSSnapin $snapin -ea "silentlycontinue")
Write-Host "PS snapin $snapin is loaded."
elseif (Get-PSSnapin $snapin -registered -ea "silentlycontinue")
Write-Host "PS snapin $snapin is registered."
Add-PSSnapin $snapin
Write-Host "PS snapin $snapin is loaded."
else
Write-Host -f Red "Error: PS snapin $snapin is not found."
Exit -1
$url = "http://pc1/sites/GroupWork/"
$site= new-Object Microsoft.SharePoint.SPSite($url )
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates){ write-host $child.Name " " $child.Title}<br />
$site.Dispose()
The script works fine from the Sharepoint 2010 management shell after launching the shell from the start menu (or from windows cmd by entering powershell -v 2):
PS C:\2> .\1.ps1 
PS snapin Microsoft.SharePoint.PowerShell is loaded.
GLOBAL#0 Global template
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multipage Meeting Workspace
CENTRALADMIN#0 Central Admin Site
WIKI#0 Wiki Site
BLOG#0 Blog
SGS#0 Group Work Site
TENANTADMIN#0 Tenant Admin Site
{248A640A-AE86-42B7-90EC-45EC8618D6B4}#MySite2 MySite2
{95629DC2-03B1-4C92-AD70-BC1FEAA49E7D}#MySite1 MySite1
{7F01CFE4-F5E2-408B-AC87-E186D21F624C}#NewSiteTemplate NewSiteTemplate
PS C:\2>
I have an access to the database Sharepoint_Config from current domain user and from other 2 users. All users have db_owner rights to the Sharepoint_Config database. But
i've loaded in windows from the user which is dbo in the database (dbo with windows authentication with domain\username for the current user). The dbo user has do_owner rights in the Sharepoint_Config database. I've tried to login under other users and launch
the cmd file but without success.
My PowerShell has version 2.0: 
PS C:\2> $psversiontable
Name Value
CLRVersion 2.0.50727.5477
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
After launching the script from 1.cmd file i get an errors:
C:\2>Powershell -v 2 -NonInteractive -NoLogo -File 1.ps1
PS snapin Microsoft.SharePoint.PowerShell is registered.
The local farm is not accessible. Cmdlets with FeatureDependencyId are not regis
tered.
Could not read the XML Configuration file in the folder CONFIG\PowerShell\Regist
ration.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\Registration'.
No xml configuration files loaded.
Unable to register core product cmdlets.
Could not read the Types files in the folder CONFIG\PowerShell\types.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\types'.
"No Types files Found."
Could not read the Format file in the folder CONFIG\PowerShell\format.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\format'.
No Format files Found.
PS snapin Microsoft.SharePoint.PowerShell is loaded.
New-Object : Exception calling ".ctor" with "1" argument(s): "The Web applicati
on at http://Pc1/sites/GroupWork/ could not be found. Verify t
hat you have typed the URL correctly. If the URL should be serving existing con
tent, the system administrator may need to add a new request URL mapping to the
intended application."
At C:\2\1.ps1:48 char:18
+ $site= new-Object <<<< Microsoft.SharePoint.SPSite($url )
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
Please help me. I don't understand why the script is launched from the sharepoint management shell but doesn't work from the cmd file.

I have an answer for my problem:  for solving a problem I've made several steps:
1. Run farm installation under AD admin credentials - runas /user:Domain1\DomainAdmin1 "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\psconfigui.exe".
This user has been added as farm administrator in the wizard.
This user has been added as DBO in the SQL Server. (This is the main difference with my previous attempts)
2. Execute a command Add-SPShellAdmin Domain1\UserAccount1 in
the Management Shell of Sharepoint.
3. Run SQL server and add Sharepoint_Shell_Access to the Domain1\UserAccount1
(my main account) in the Config database
4. Run CMD file only from Start->Run menu. 
runas /user:Domain1\UserAccount1 "C:\1.cmd".
Do not use Total Commander command prompt or file list for executing *.cmd of *.bat files without root administrator account.
Thanks all for help.

Similar Messages

  • HT6114 Does the 10.9.2 update fix the issue on 2011 macs where projectors with HDMI are not recognized via thunderbolt adapter?

    Hi Mac,
    Does the 10.9.2 update fix the issue on 2011 macs where projectors with HDMI are not recognized via thunderbolt adapter?
    Thanks in advance,
    Ricardo Arguelles

    Sordidloam wrote:
    So to be clear, this issue occurs on any input with the Denon Receiver.  Occurs from both HDMI out and MiniDisplay Port out.  Goes away when we reinstall the OS and update it to 10.9.2.  Comes back as soon as we update to 10.9.3.
    Cheers
    MLE
    Have you been able to use the Mac Mini directly attached to the plasma/LCD/projector with out going through the Denon AVR? Even with 10.9.3 installed?
    I have a Pioneer AVR and I have the Mac attached via a HDMI to HDMI and all is working for me. Can your Denon do some upscaling? Some AVR, like my VSX-53 can change the scaling of the input video. Meaning if I still had my Apple TV 2 which outputs 720P only, can be upscaled in my AVR to 1080i or 1080P or even 24fps. Heck, I could even plug in an old style Red, White, Yellow cable and upscale it to 1080P and output it HDMI.
    I am wondering if your Denon is able to do that and it might be set wrong. Check the owners manual for such settings. Even the plasma/LCD/project could be doing the upscaling too. So check that too.
    KOT

  • Error:  The local root folder, ZZZZZZ, does not exist.  Please...

    Dreamweaver newest - Cloud
    Windows 7 Prof 64b SP1
    Everyday now upon firing up Dreamweaver I am getting the same error. As long as I worked on this certain site last the day before, dreamweaver of course tries to load that site upon the next startup.
    The error:  The local root folder, ZZZZZZ, does not exist.  Please choose a new local root folder
    I have typed the path myself and browsed to it many times.  When I go into the Site manager/edit site to correct this, it already has the correct path listed there.  If I just leave what is there and hit save, it doesn't work.  Once re entering is done it allows me to work on the site again. Connecting to remote/upload files and everything works fine.  I can close DW and reopen and all will be fine, for a while.    If I close it and maybe two hours later come back to work on it, DW will report that same error again on startup.
    Other editors of the site with same cloud version of DW and same site settings are not having this error. We've combed for differences.
    I've deleted the site definition altogether and recreated it.  It does not stop the error.
    I found some old references to this issue in the old macromedia forums dealing with Mac and spaces or odd characters being an issue in the local folder path. I'm on windows, but the complaints sounded so similar I decided to try a test suggested there.  Their suggestion was to create a new blank html file, without saving, add some text, select the text, use the link icon in the properties manager to drag a link out to any file in the files panel.  Upon doing so, DW creates a full local path that you can see in your html since you haven't saved the file yet.  The suggestors of this test said you should see if your "mac" and DW was having trouble with spaces or odd characters in the path.   Well the following path shows a PIPE character being created in the path by DW on my test page. 
    file:///W|/private/09 Websites/zzzzzz/index.html
    Could this be showing there is some kind of issue that I need to correct?  Or is this typical?  See the pipe character being listed after the network drive letter of W
    Our local root folder path:
    W:\private\09 Websites\zzzzzz\
    Server Settings:
         Root Directory:
    public_html/zzzzzz.com/
         Web URL:
    HypertextTransferProtocolCOLON//worldwideweb.zzzzzz.commercial/
    Any help or suggestions would be appreciated.

    Sudarshan Thiagarajan wrote:
    remote
    /home/zzzzz/public_html/zzzzz.com
    Is this how your remote setting is defined? If it is, do you have a folder called zzzzz.com on your remote server trailing public_html? Ideally public_html is your website root - index.html resides within that, unless your configuration states otherwise.
    To come to your actual question of the local root folder, yes, your file manager wont show files if the connection fails. However, accessing it depends on the permissions you have on your network drive. Have you checked that?
    I'm not sure why our guy has another folder underneath public_html. My guess is he has some company related hosted test folders for various things under there.  I can see a couple other folders under public_html while checking with filezilla. I suppose he just directed our domain to our web folder under public_html. 
    Again, two others here are using these exact same settings with no root folder errors from DW. We've checked many times and all is the same for them.
      Here are some screen grabs of the settings if this makes it more clear.
    This last one showing the remote connection address under the files/assets panel is the one that looks strange to me.  It shows a home folder / then a folder with our site name / then public_html / then our sitename.com .    Seems convoluted to me.  But it works for everyone else so I'm not sure if this error I'm getting has anything to do with these settings or if there is just some old DW settings file hung up in my system that I need to find and delete or what.
    Thanks for any ideas.

  • SharePoint Remote Powershell Session - Can't find the local farm

    Hi,
    I've been trying to configure a remote PS session to connect to a SharePoint Farm to create site objects.  I can get connected and load the SharePoint PS snap in successfully but when I try commands like Get-SPWeb all I get is an error "Cannot
    access the local farm".
    If I launch PS on the SharePoint server and add the snap in I can use the CMDLETs fine.  I've ensured PS remoting is enabled and granted access so that the client computer is authorised to connect to the SharePoint server.
    Here is the connection code I've used:
    $RunAsAccount = "domain\user"
    $RunAsPass = "password"
    $pass = $RunAsPass | ConvertTo-SecureString -AsPlainText -Force
    $credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $RunAsAccount, $pass
    enter-pssession -computername spserver.domain.local -credential $credentials
    Add-PSSnapin Microsoft.SharePoint.Powershell
    The connection user is a local administrator on the sharepoint server and is a dbowner of the sharepoint config and content databases (for testing) and also has shell access on the sharepoint config DB.
    Any ideas?
    Thanks,
    Tim

    Remoting isn't quite that nice.
    I believe you need to use an invoke-command to run the snapin on the destination server, or import the commandlets locally to slightly different names.
    To borrow the important section for your needs first you'd need to put the session into a variable for later use, then use the invoke-command cmdlet
    "$session = New-PSSession -computername "SPServer" -Authentication CredSSP -Credential $crd
    Start Remoting on you Client Computer
    Now your client computer is ready to actually create the session and import the SharePoint commands from the Server.
    The next command adds the SharePoint PowerShell commands to your session.
    Invoke-Command -Session $session -ScriptBlock{Add-PsSnapin Microsoft.SharePoint.PowerShell}
    Note, that at this point, you can run whatever administrative PowerShell commands you need to run by using the Invoke-Command -Session $session -ScriptBlock{} syntax."
    http://blogs.msdn.com/b/varun_malhotra/archive/2010/06/10/configure-power-shell-for-remote-use-of-sp-2010.aspx

  • Add-spshelladmin : Cannot access the local farm - SharePoint 2013

    Hello,,
    We installed a SharePoint tool on a SharePoint 2013 server, and now the site is down.  One error is happening:
    add-spshelladmin : Cannot access the local farm. Verify that the local farm is
    properly configured, currently available, and that you have the appropriate
    permissions to access the database before trying again.
    Prior to installing this tool, the SharePoint PowerShell was working. I am running the power shell with admin rights.  The farm account is still in the local admin group, and its in the WSS_RESTRICTED_WPG_V4 group.  All commands and the site were
    working fine, until we installed the tool.
    How can I get the PowerShell Management shell working again?
    Thanks.
    Paul

    It sounds like your tool has brought down SharePoint or messed with your permissions. Restart the server and then starting at the SQL work your way through SQL connections, IIS Application Pools, IIS Sites, event logs and so on until you find a reason for
    where the farm is broken.
    Also try to identify what exactly else is and isn't working. If the entire farm is dead then complaining that PowerShell doesn't work is like complaining that your water seems to be seeping into your stateroom on the titanic and it's getting the carpet damp,
    it may be true but it's not the most significant issue...

  • Redeemed the iTunes gift card it gave an error: The gift certificate or prepaid card code you entered has not been properly activated.

    Redeemed the iTunes gift card it gave an error: The gift certificate or prepaid card code you entered has not been properly activated.

    do you have the receipt from where you bought it? If so take it back and see what they will do for you.

  • Error: The local BEA product registry is corrupted when installing OEPE

    Hi,
    When trying to install Oracle Enterprise Pack for Eclipse that comes with the installer of weblogic 10.3.6 + coherence im getting the following error: "The local BEA product registry is corrupted. Please select another Middleware Home or contact Oracle Support"
    What could be the reason of this error ?? do i need something as a prerequisite??
    Regards
    Carlos

    Check the settings in the file silent.xml.
    <?xml version="1.0" encoding="UTF-8"?>
    <bea-installer>
    <input-fields>
    <data-value name="BEAHOME" value="<bea-home>"/>
    <data-value name="WLS_INSTALL_DIR" value="<middleware-home>"/>
    <data-value name="NODEMGR_PORT" value="<port>"/>
    <data-value name="COMPONENT_PATHS" value="<component>/<subcomponent>[|...]"
    <data-value name="LOCAL_JVMS" value="<jvm-location>"/>
    </input-fields>
    </bea-installer>
    For example:
    <?xml version="1.0" encoding="UTF-8"?>
    <bea-installer>
    <input-fields>
    <data-value name="BEAHOME" value="/u01/Oracle/Middleware"/>
    <data-value name="WLS_INSTALL_DIR" value="/u01/Oracle/Middleware/wlserver_10.3"/>
    <data-value name="NODEMGR_PORT" value="5556"/>
    <data-value name="COMPONENT_PATHS" value="WebLogic Server/Core Application Server|WebLogic Server/Administration Console|WebLogic Server/Configuration Wizard and Upgrade Framework"/>
    <data-value name="LOCAL_JVMS" value="/u01/java/jre1.6.0_21"/>
    </input-fields>
    </bea-installer>
    Put the .jar generic installer and the silent.xml files in the same directory
    Change to that directory and run the command below for launching the installation using generic jar installer.
    java -jar wls_generic.jar -log=mylog.txt -log_priority=debug -mode=silent -silent_xml=./silent.xml

  • HT201209 I bought my Apple iTunes & Apple AppStore Card's at Best Buy, but when I try to use them I get this error: The Gift Certificate or Prepaid Card code you entered has not Ben properly activated. What did I do wrong or did Best Buy not scan it right

    I bought my Apple iTunes &amp; Apple AppStore Card's at Best Buy, but when I try to use them I get this error: The Gift Certificate or Prepaid Card code you entered has not Ben properly activated. What did I do wrong or did Best Buy not scan it right! Real Geniuses in that store!

    If so, then review the first link to see if you can troubleshoot your issue yourself. If that doesn't work, then contact iTunes Support via the second link below:
    Invalid, inactive or illegible codes:
    http://support.apple.com/kb/TS1292
    Contact iTunes support here:
    http://www.apple.com/support/itunes/contact/
    Cheers,
    GB

  • "one or more of the items in your selection contains Aperture albums that are not supported in iphoto".

    I have some folders in iPhoto called 'Recovered Folder'. When I try to delete them I get this message: "one or more of the items in your selection contains Aperture albums that are not supported in iphoto".
    I don't use Aperture (did install it to try it out), and have deleted Aperture App from my Mac.
    How can I get rid of these fodlers?

    i finally figured this out:
    fyi, iphoto and aperture can now share (i.e., access) the same library. apple details it here:
    http://support.apple.com/kb/HT5260?viewlocale=en_US&locale=en_US
    i use both iphoto and aperture, and i suspect something went amiss, at some point, while aperture was accessing my iphoto library.
    this is how i fixed the problem:
    i launched aperture, then (per the instructions linked above) switched to (i.e., accessed) my iphoto library. i was then able to delete the "recovered folder" and the album it contained. i then quit aperture and relaunched iphoto.
    NOTE: at that time, although i expected the "recovered folder" to be gone, it was still present. but this time, i was able to delete the folder from within iphoto without the "contains aperture items" error message.
    (Sparky030405, i realize you've since deleted aperture. while i can't say my method is the *only* way to solve this problem, it's the way i was able to solve it. so, you might consider reinstalling aperture in order to delete the folder, then uninstalling aperture, once again.)

  • Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work. Please help. Thanks.

    Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work. Please help. I am getting lots of spelling errors as the MacBook laptop screen is too small. Thank you so much! .

    Contentmom6 wrote:
    Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work.
    Normally, you just connect the monitor to the MacBook using a VGA adaptor that you can buy from an Apple Store.  Now try System Preferences > Displays > Detect Displays.  You should now be able to select a display mode for the monitor.  If it still doesn't work, then I'd check that everything is properly connected.  I've had problems with colours disappearing due to a faulty connection in the VGA adaptor.
    Bob

  • Hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?, hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?

    hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?, hey guys . . how come I get updates, but can not updates them as they are "not applicable" for the "version" of the pad?

    The only people who can possibly assist you with this is Apple Customer Relations, call your local Apple contact number and ask for Customer Relations then explain your situation clearly and politely (be firm but don't rant).
    You might want to investiage what the local laws are regarding defective goods and 'fit for use' definitions on warranties etc. Consumer Protection can be a useful tool to use or bargain with if needed ...

  • My wife and I share the same email address and Apple ID.  We are not able to send and receive Text Messages to one another.

    My wife and I share the same email address and Apple ID. We are not able to send and receive Text Messages to one another. Is the cause of this because we share the same Apple ID? Will we have to set up 2 separate primary email addresses to be able to  send and receive Tex Messages to one another? Like I said, we share the same email address and woul like to keep it that way to keep up with our email together. Is there a way to by-pass having to set up 2 primary emaill addresses if this is the problem?
    Thanks.

    go to the settings and turn off imessage
    but that don't change the issue that you will never be able to facetime eachtoher
    the appleID is really meant as the handle that identify you it was not meant to be shared
    but can see that people may want to do not buy apps more then once

  • Have a 4S and in the lock screen it is coming up with a screen (Not Enough Storage - This iphone cannot be backed up because there is not enough iCloud storage available. You can manage your storage in settings) it then has option close or settings.....bu

    I have a 4S and in the lock screen it is coming up with a screen (Not Enough Storage - This iphone cannot be backed up because there is not enough iCloud storage available. You can manage your storage in settings) it then has option close or settings.....but i am unable to click on either or turn off the phone. I have plugged it into itunes on the computer and manually backed it up but i cannot use my phone as i cant get past this message

    Welcome to the Apple Community.
    You might try a forced shutdown to begin with, hold down the top and home buttons together until the device shuts down, then restart it.

  • Child DC cannot Replicate to Parent DC, because of connection errors. MS PortQryUI shows that ports 3268 and 3269 are not listening,

    I started a support case with Microsoft to help me with raising the our domain Forest level because i received a message stating that there were Windows 2000 PDC still listed in the database. These PDCs were removed years ago. The tech saw all of the problems
    i was having with domain replication so that is where he started. running the MS PortQryUI shows that ports 3268 and 3269 are not listening, (TCP port 3268 (unknown service): NOT LISTENING) when run FROM a Child domain controller against the Parent
    Domain controller. Between the 2 Child domain controllers these ports are listening.
    The Windows firewall is not running on any of the controllers, i removed a virus protect client from all of the servers, although i didn't enable the firewall there either, but these ports are still not listening on the Parent DC.
    I need help debugging this. I am not very familiar with network sniffers so if i need to run one i'll need some guidance. This DC only has one NIC, all IP addresses are static, all servers are setup like this. All servers are in the same subnet, on the same
    lan, on the same cisco switch, there shouldn't be anything blocking this port from starting.
    I looked over other post that show this same problem, but they don't give a solution. If i am not using the Windows firewall why wouldn't these ports be open?
    Any ideas? web searches are all over the map on trying to find the reason for this.
    Bobby

    Try running the below command on the DCs that you think have the ports blocked or all the DCs.
    netdiag /test:ipsec /debug > c:\dcname-ipseclog.log
    Open that from the C drive and see if there is anything saying block or filters. 
    Also, just for kicks have you disabled the firewall service on the DCs? 
    And just for kicks have you tried enabling firewalls ports on all the DCs?  The KB is below
    http://support.microsoft.com/kb/555381/en-us
    Step 1 - netdiag results
    Step 2 - disable the firewall service on all DCs if step 1 was negative
    Step 3 - enable the firewalls on all DCs per KB 555381 if step 2 doesn't work
    Let us know how it goes!
    If it answered your question, remember to “Mark as Answer”.
    If you found this post helpful, please “Vote as Helpful”.
    Postings are provided “AS IS” with no warranties, and confers no rights.
    Active Directory: Ultimate Reading Collection

  • The speaker of my brand new mac book pro are not working and I cannot plug in the earphones, the hole looks smaller than the pin or with an obstruction. anybody can help? thanks

    the speakers of my brand new mac book pro are not working and I cannot plug in the earphones, the hole looks smaller than the pin or with an obstruction. anybody can help? thanks

    Hi talero,
    Contact AppleCare or bring it into an Apple Store or AASP.

Maybe you are looking for