Application page and powershell execution

When I try to execute following code at Application page 
                Runspace runspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault());
runspace.Open(); //this line of code raises exception
                string script = "New-SPSite -URL http://testspweb/sites/testsitecollection500
-OwnerAlias \"domain\\user\" –Language 1033 -CompatibilityLevel 14";
                PowerShell powerShellCommand = PowerShell.Create();
                powerShellCommand.Runspace = runspace;
                powerShellCommand.AddScript("Add-PsSnapin Microsoft.SharePoint.PowerShell");
                powerShellCommand.AddScript(script);
                powerShellCommand.AddScript("Update-SPProfilePhotoStore
-MySiteHostLocation http://testspweb/personal/spmember");
                foreach (string result in powerShellCommand.Invoke<string>())
                runspace.Close();
                PowerShell ps = PowerShell.Create();
I get following error:
{"Requested registry access is not allowed."}
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at System.Environment.GetEnvironmentVariable(String variable, EnvironmentVariableTarget target)
   at System.Management.Automation.ModuleIntrinsics.GetExpandedEnvironmentVariable(String name, EnvironmentVariableTarget target)
   at System.Management.Automation.ModuleIntrinsics.SetModulePath()
   at System.Management.Automation.ExecutionContext.InitializeCommon(AutomationEngine engine, PSHost hostInterface)
   at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, RunspaceConfiguration runspaceConfiguration, InitialSessionState iss)
   at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
   at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
   at GenusMUIntergation.Code.Handlers.UpdateSharepointPhoto.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
HResult -2146233078
How can i resolve this problem?

I don't think is possible - to execute powershell in process that runs like IIS process.
From first thread:
" SPSecurity.RunWithElevatedPrivileges
in your codeRunwithElevatedPrivileges will run the code under App Pool identity.Powershell should be run under Farm Account credentials as a Standard.Should we try,SPSecurity.RunWithElevatedPrivileges and use UserToken of Farm Account user.Please suggest or correct me, if I am wrong."
The main problem that if I open page/httphandler with farm admin account I get exception (Microsoft.Win32.RegistryKey.OpenSubKey ) related with access rights to windows registry.
When I try to execute command in SPSecurity.RunWithElevatedPrivileges , IIS App Pool identity dont have enouth access rights (it is not farm admin)
I think that API for usage powershell is not intended to be executed from pages/webpart/httphandler/any IIS App pool process.
API for usage powershell was intended for console applications.

Similar Messages

  • Creating a table in the application pages and pasting it into iWeb 08

    I have learned today that if you create a table in pages and then copy and paste it into iWeb 08 it uses the the ORIGINAL entry in the upper left cell as the name of the png file that is created as the image for the iWeb folder.
    If that ORIGINAL name had a space in the name the resulting server can probably not link successfully the data in that png file.
    Solution: When you FIRST create the table in the application pages that you plan to copy into iWeb use a single word in that upper left cell -- you can change the content later but the "pasted" file will be that word.png.
    Enjoy!

    I use the class cl_xml_document to create XML documents.
    It has all the methods required to create XML documents...perfectly. It is fairly straightforward when you get into it...and you can produce very good xml files.
    also, try this little report...
    whilst this is not full blown XML example it may give some ideas or possibly the format generated maybe be enough for your needs. This is a simple test example of converting an ITAB into an xml type file and then it was sent to a server
    report zsjc2.
    data :
      itab   type table of sflight,
      l_xml  type ref to cl_xml_document.
    start-of-selection.
      select * from sflight into table itab up to 1 rows.
    end-of-selection.
      create object l_xml.
      call method l_xml->create_with_data( dataobject = itab[] name = 'ROOT' ).
      call method l_xml->display.
      data: v_uri type string,
            v_response type ref to  cl_xml_document.
      v_uri = 'http://broker.dev.eproc1.uk.compass:7080/saphttptest'.
      call function 'SWF_XML_SEND_VIA_HTTP_SERVER'
        exporting
          uri                            = v_uri
          request_document               = l_xml
    *   USER                           = ' '
    *   PASSWORD                       = ' '
       importing
         response_document              = l_xml. "v_response.
    You can use other methods, additional to what this example shows, to create a true XML file. You need more coding - but the above example is just a 'quick and dirty' half waay house to get you moving along in one possible direction. I actually preferred using the class than transformations.

  • Can not find applications pages and numbers after I reinstall to os X. I've read that this applications are free.

    Good day. I did an upload for my mac and now I have an Mac os X. I've read that with this system you provide applications: numbers and pages and others for free. I checked in Purchase for that and I dont see them.
    Thank you.

    Welcome to Apple Support Communities
    You only get Numbers, Pages and Keynote for free if you purchased a Mac after October 1st or if you have got iWork '09 installed. If not, you have to pay for these applications

  • Where do the files go when we deploy a user control, application page and event receiver?

    I have read that the files go into the HIVE\TEMPLATES\CONTROL TEMPLATES or \FEATURES once deployed.. 
    I have also read that we can right click on project and choose add mapped folder and select whether we want to put the page/user control under CONTROL TEMPLATES or FEATURES, etc?
    Which method is to be followed?

    The files in mapped folder created using Visual studio is copied to the appropriate folder in 14/15 hive on WSP deployment. Refer to the following articles for more information
    http://www.informit.com/articles/article.aspx?p=1626325
    http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2010/03/12/deploying-files-using-mapped-folders.aspx
    http://msdn.microsoft.com/en-us/library/ee231544.aspx
    --Cheers

  • Webdynpro Application Page in portal in CE7.1

    Hi,
        I have created a webdynpro application with property u201Csap.canBeSplitInIviewsu201D set to u201Ctrueu201D.I have deployed the application  and in Portal Content I have created a webdynpro page out of this application.So now my webdynpro page is having two iviews.
    Now I want to know the answers for below questions
    1)Can we  embed a url iview it in to the above created Webdynpro Application page in portal.I tried for it but couldnu2019t do so.
    2)So,as an alternative I created a Page,added the above created Webdynpro Application page and a url iview to that page.Now that url iview is displayed along with the Webdynpro iview.Bot the problem is url iview is getting refreshed when ever I click a button in the webdynbpro application view .It even refreshes when I select a table row in webdynpro.
    Please let me know if we can prevent url iview to refresh.
    Regards,
    Sudhir

    Hi,
    >1)Can we embed a url iview it in to the above created Webdynpro Application page in portal.I tried for it but couldnu2019t do so.
    No, I don't think so.
    >Please let me know if we can prevent url iview to refresh.
    For the parent page which hosts both the WD and the URL iview, set the property Isolation Method to URL. You can find this property under the property category Load.
    Regards,
    Satyajit.

  • Open Application Page depending on ListSettings

    I am using an Application page and want to open it in a modal dialog so I am using the current code:
    var siteUrl = _spPageContextInfo.webServerRelativeUrl;
    var options = {
    url: siteUrl + '/_layouts/MT/Page.aspx?itemid=',
    width: 640,
    height: 480
    SP.UI.ModalDialog.showModalDialog(options);
    But the user is able to change the list settings so that dialogs are usually not opened in a popup. This works fine for EditForm and those but not for mine. This still opens in popup. Is there a chance to get the list settings property by javascript, so I am
    able to decide how to open? Or do I need to customize my Custom Action with two different URLs?

    I am using a custom action that is activated by feature
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="{D283FC7A-B852-4985-B7E9-6D367E629170}"
    Location="EditControlBlock"
    RegistrationId="10003"
    RegistrationType="List"
    Sequence="700"
    Rights="EditListItems"
    Title="Title"
    Description="Descr"
    ImageUrl="/_layouts/images/p.png">
    <UrlAction Url="javascript:redirectPage({ItemId});"/>
    </CustomAction>
    <CustomAction Id="Script"
    Location="ScriptLink"
    ScriptSrc="~/_layouts/JS/CustomActionsCode.js"/>
    </Elements>
    I know this library but I did not know that I am able to get the list settings...
    You mention the GetList method. How do I get the list settings there?

  • Two applications Pages on Macbook Air

    I have two applications Pages on Macbook Air.
    The first Pages has already been buying MacBook Air in package iWorks but it was shareware. Then I paid for a working version, but now I have two applications Pages and they interfere with each other. The first Pages is not removed as part of a package iWorks. How to make sure that there is only one application Pages?
    Pages ’09 version 4.3
    MacBook Air 2011 (2) OS X 10.8.2

    tasha.life.ibook wrote:
    thanks,
    link have many different applications, which need to download it?
    Download and run the Uninstall iWork 09 script.
    Jerry

  • Associate 2 Standard Tab Sets to the same application page

    Can you associated 2 Standard Tab Sets to the same application page and only have one of the Standard Tab Sets display based on an item value on that application page?
    Thanks,
    Dan

    Hi Dan,
    to my knowledge you can't do that, because you can only assign one tab set with the page property "Standard Tab Set".
    But how about just creating one tab set where you conditionally display the tabs which are matching?
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • How can I stop the execution on a JSP page and start it again

    Hi
    I am making a program that simulates how to manage transactions when accessing a database by using locks. I have run into a problem and I hope someone has the time to help me.
    When a user does an update the transaction commits and releases its locks when the program executes
    <%stmt.executeUpdate("commit!"); %>
    I need to put a break in to stop the program executing this statement, to illustrate the lock is set correctly.
    I have tried to put in an alert box but this does not prevent the rest of the java code being executed.
    I have tried to use prompt boxes, JavaScript functions, but these functions cannot have any java code in them.
    I have tried using the java.swing JOptionPane boxes but this didn?t work either
    I have tried to get input from the user but I don?t know how to retrieve this data on the same page. (As far as I know you have to use submit and even refresh the page or retrieve it on the next page).
    Does anyone know how I can stop the execution on a JSP page and start it again (on same page)
    Mette

    I already have another client (Tomcat jsp application) running and it throws a SQLException correctly when I don�t put in a commit=true statement and don't close the database connection.
    But the problem is how to get the code above to stop to illustrate I have set this lock.
    I have tried to use the JOptionPane but because my program is running in a web browser I cannot use the JOptionPane dialog box.
    I have tired using an alert box but it executes the commit statement before the alert box is dispayed. So this does not work
    While (i < 2)
    if( i==1)
    %>alert(�The transactions commits when you press Ok�); <% //what it to stop execution here
    else
    stmt.executeUpdate(�commit�);
    I am not using threads so I cannot use the sleep function.
    I am using mysql and have already configured it to detect deadlocks and how long to wait for locks.
    Thanks for your help
    Mette

  • View application pages - view forms views and application pages. enumerate lists

    view application pages - view forms views and application pages. enumerate lists, if we disable this permission in sharepoint then user gets blocked from getting into application pages which is good. But now I have few list view web parts on a page and user
    is not able to see those reports based on view. It shows working on it. As soon as I enable view application pages permission it works.
    I need a permission level -view forms views only.
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Hi Amit,
    SharePoint has a feature called “ViewFormPagesLockDown” at site collection scope. After enabling the feature, all groups / users not having the “View Application Pages” permission will not be able to navigate to pages like “_layouts/viewlsts.aspx”
    or “pages/forms/allitems.aspx”.
    So, for your issue, please disable the ViewFormPagesLockDown feature via PowerShell command:
    $lockdownFeature = get-spfeature viewformpageslockdown
    disable-spfeature $lockdownFeature -url [the URL of your site]
    More information:
    http://sharepointtechie.blogspot.jp/2011/06/blocking-access-to-application-pages.html
    http://sureshpydi.blogspot.jp/2013/12/viewformpageslockdown-feature-in.html
    Best Regards,
    Wendy
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Wendy Li
    TechNet Community Support

  • Can i display My application iview and transaction iview in single page ?

    Hi,
    I am new in web dynpro and portal. i am doing one approval application through web dynpro. Now i need to attache sap inbox to application. For that some budy suggested me about transaction view. So my questions are as folloes.
    1.> How i attached my application to iview ?
    2.> How i created Transaction  iview ?
    3.> Can i attache my application iview with transaction iview if it is possible then how ?
    4.> Can i display My application iview and transaction iview in single page ?
    Please guide me in this procesure.
    Regards,
    Gurprit Bhatia

    Hi Gurprit,
    1.> How i attached my application to iview ?
           You can attach your application to web Dynpro IView, for this login into portal, in the Content Management tab right click on a folder, then New --> IView. Select WD java Application. Select your application and create an Iview.
    2.> How i created Transaction iview ?
           Similarly, instead of selecting WD java Application, select iView template, you will get a list of available templates, and in this you will find template for Transaction Iview, in this template define the Tx for which you want to create the template.
    3.> Can i attache my application iview with transaction iview if it is possible then how ?
          No, I dont think you can attach your application to transaction Iview. but, you can attach both IViews on single page.
    4.> Can i display My application iview and transaction iview in single page ?
          Yes, you can attach  both IViews on single page. Again in Content Management tab, crate a PAGE; Then right click on created IViews and select  add IView to Page ßß: Delta Link.
    Hope this helps.
    Regards,
    Amit

  • I downloaded the new Pages and Numbers through my app store but when I open my old documents, it still tells me my 30 day trial is over. How do I get the computer to automatically recognize the new applications?

    More information: I have a 3 year old MacBook and had been using "Microsoft for Mac" until last week when I took my MacBook in for some upgrades- including the operating system Lion. I have been unable to use the Word, Excel, etc. programs because they are not supported on the new operating system... and I already used my 30 day trial of iWork when we first purchased the computer. I decided to buy Pages and Numbers through the App Store icon. When I open the Pages and Numbers under my Applications, I can get them to work. However, when I open old documents saved on my computer, they go into the 'old' iWork messages of that my trial has expired. How do I get the computer to automatically recognize that I've purchased Pages and Numbers?

    You need to delete the trial & then reinstall from the boxed DVD or the Mac App Store. The files to delete are the iWork ’09 folder from the main HD > Applications; the iWork ’09 folder in HD > Library > Application Support & the individual iWork application plist files found in HD > Users > (your account) > Library > Preferences for each user.
    Yvan Koenig has written an AppleScript that removes the files. You can find it on his box.com account in for_iWork'09 > other_iWork'09 items > uninstall iWork '09.zip.

  • How can i deploy a silverlight application when it contains an aspx page (And Aspx page content is a DevExpress Scheduler)

    I have a silverlight application. It has containing many navigation pages in it. One of this pages is containing an .aspx page and i have used devexpress scheduler on there. It is working perfect on development machine but on production machine when client
    logged and navigate to the scheduler page there is a message top of the page saying
    webbrowser is enabled only for out-of-browser applications running with elevated permissions in Internet Explorer.
    And i have found something like that
    https://msdn.microsoft.com/en-us/library/gg192793(v=vs.95)
    But I think my problem is not that in my project properties i always checked the require permission checkbox. i couldnt understand this behavior and how can i solve. I tryed to use .pfx file by adding in project properties signing tub. Even i couldnt understand
    how why are we using this certificate and is it interesting with it
    Also now i seen in my development machine when i opened this page a popup window come up this message:
    the current webpage is trying to open a site in your trusted sites list. Do you want to allow this?
    current site: res/npctrUI.dll
    Trusted site: localhost
    warning allowing this can expose your computer to security risk. If you dont trust the current page, choose no.
    regards
    Hamit YILDIRIM

    Things that require elevated trust will always work in visual studio.
    You need elevated trust to use the webbrowser inside a Silverlight page on a user's machine.
    That means purchasing a security certificate.
    https://msdn.microsoft.com/en-us/library/gg192793(v=vs.95)
    You can open up any old web page in another tab from Silverlight and I would suggest you consider that instead of using a webbrowser control inside a Silverlight page.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Just installed os x maverick and updated my version of pages now when I try to open a document stored in pages format from old version get message "The Application "pages" can't be opened -1712  What is wrong?

    Just updated to new version of pages.  Now can not open stored documents created under al pages.  Get message "the application pages can' be opened -1712"  hat do I do?

    Apple released Pages 5.0 to run on Maverics only. They completely rewrote the program for Maverics and 64 bit compatibility. They failed to explain that this version is missing much of the previous version's capability and that it cannot read older Pages files. When they install it they leave the older Pages 4.3 in place because it is the only way to read the older Pages files and upgrade them to a level that can be read by Pages 5!
    If you still have Pages 4.3 on your computer it will tell you what to do. If you do not then go into your backups and retrieve it.
    Because of the deficiences of Pages 5 I have removed it from my Mac and gone back to working with Pages 4.3. I have also removed Pages 2 from my iPad and found Pages 1.7 in the Time Machinew backups and brought it forward and droped it onto the iTunes icon to restore it and then synced the iPad to get the Pages 1.7 running again - it is compatible with Pages 4.3 on the Mac so all is back to normal for me.
    Apple say that they will fix many of the deficiences in Pages 5 in the next six months. I suggest you wait until then and keep an eye on these communities beforte considering the "upgrade".
    Incedentaly Pages 5.0 writes files that cannot be read by anything else including Pages 4.3 - better hope no one sends you one! It does not save RTF either - what where they thinking!

  • I have updated my ipad yestarday sicne then i am not able to open any application on my ipad2. some of the application able to open in the page and not able to open all the applications in the second page. Does any one got this type of issue? any sugg?

    i have updated my ipad yestarday sicne then i am not able to open any application on my ipad2. some of the application able to open in the page and not able to open all the applications in the second page. Does any one got this type of issue? any suggestions?

    This problem has been reported a few times. The solution is to install any new App say a free one. This seems to fix whatever has gone wrong.

Maybe you are looking for