How to run 'Get-AssignedAccess' or 'Set-AssignedAccess' power shell commands in c# Application

Hi,
I have console application using which i am trying to run power shell command  like 'Get-AssignedAccess' or 'Set-AssignedAccess'.
i am using below code for this it is throwing exception 'Get-AssignedAccess' doesn't exist in cmdlet which is correct because these commands belongs to function category.
using (PowerShell pwInstance = PowerShell.Create())
                        pwInstance .AddScript("Get-AssignedAccess");
                        var result = pwInstance .Invoke();
How can we execute this kind of command using c#?
Thanks,

Hi prakashlight,
Thank you for comming back and tell us the result. For more information about how to run PowerShell script in C# language, you can refer to this blogpost here:
Executing PowerShell scripts from C#
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to Execute Power Shell Command From Windows Application.

    Hi All Experts,
    I want to execute power shell commands from my windows application.
    Is it possible ?
    Please let me know your comments..
    Thanks.

    I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
    Let me know how it goes...
    public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
    // Powershell ~= RunspaceFactory - i.e. Create a powershell context
    var runspace = RunspaceFactory.CreateRunspace();
    var resultString = new StringBuilder();
    try
    // load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
    PSSnapInException snapInError;
    runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
    runspace.Open();
    // set a web variable.
    runspace.SessionStateProxy.SetVariable("webContext", web);
    // and some user defined parameters
    runspace.SessionStateProxy.SetVariable("param1", param1);
    runspace.SessionStateProxy.SetVariable("param2", param2);
    var pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(powershellText);
    // add a "return" variable
    pipeline.Commands.Add("Out-String");
    // execute!
    var results = pipeline.Invoke();
    // convert the script result into a single string
    foreach (PSObject obj in results)
    resultString.AppendLine(obj.ToString());
    finally
    // close the runspace
    runspace.Close();
    // consider logging the result. Or something.
    return resultString.ToString();
    Ok. We've written some code. Let us test it.
    var runner = new PowershellRunner();
    runner.RunPowershellScript(@"
    $web = Get-SPWeb 'http://server/web' # or $webContext
    $web.Title = $param1
    $web.Update()
    $web.Dispose()
    ", null, "New title", "not used");
    -Sangeetha

  • HT4157 I just got an iPad 16GB+3G. When I try to set up a cellular data account (settings cellular data view account) it wants the login info and password,which I don't have because I have yet to set up the account. How do I get to a "set up account" scre

    I have a new iPad2 16GB+3G. ( Only got this yesterday.)  I have set up a wireless router so am able to use WiFi at home. When I attempt to set up a cellular data connection (ATT) I get to the "view account" which asks for my login ID and password, which of course I do not have yet because I haven't set up an account yet. How do I get to a "set up account" screen?

    I'm taking that this is a used iPad. Have you removed the microSIM and got one of your own?
    Also, have you cleared it out with Settings > General > Reset > Erase All Content and Settings?
    And if that does not work you may need to contact the cell provider.

  • Apple ID.  My newly updated iPad 2 wants an email for the apple ID.  My apple ID is not an email address.  How can I get past the set-up screen?

    My newly updated iPad 2 wants an email for the apple ID.  My apple ID is not an email address.  How can I get past the set-up screen?
    I can't change my Apple ID.  It would mess all my stuff up.

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone (if you're using iOS 7), then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • HT4759 I don't use other i-devices. How do I get past the "Set up iCloud on a device ..." redirect to set up iCloud?

    I don't use other i-devices. How do I get past the "Set up iCloud on a device ..." redirect to set up iCloud? I want to use icloud for a calendar, storage of my photos and ebooks plus the Calibre reader app with chrome browser. OS is windows 7, but I will change to windows 8 soon.

    You need to set up an iCloud account before you can back it up. And you back it up directly from the device - iCloud.com has nothing to do with it. Follow the instructions in the link below to set up your iCloud account and to set up Automatic Backups:
    https://www.apple.com/icloud/setup/ios.html
    Cheers,
    GB

  • HT4859 how do you get to the set up assistant

    how do you get to the set up assistant

    Nothing will happen until/unless the shuffle shows an light (LED) when connected through the dock to a USB port... make sure the shuffle is properly positioned and pressed into the dock.

  • How do u get the ringtones setting on itunes

    how do u get the ringtones setting in itunes

    There is no icon, just go in Settings- icloud and sign in with your apple id. Once you do you will be able enable different icloud options.
    Apple - iCloud - Learn how to set up iCloud on all your devices.

  • How can i get notification of new emails in Mail without having the application open?

    How can i get notification of new emails in Mail without having the application open?

    Leave Mail running, but close its window (click red dot or ⌘W).
    Right-click the Mail icon and use "Options" to enable "Open at Login".  In the "Login Items" tab of "Users & Groups" system preference, check the "Hide" box next to Mail so it doesn't open a window when starting.

  • How do I get LR2 to "load from device" via command line?

    Hi,
    how do I get LR2 to "load from device" via command line?
    I've got XP to load LR2 when a "camera" (and only a camera) is connected but really cool would be if LR2 would also import the pictures.
    cu,
    Michael

    1. Make sure you are using IOS 7.
    2. Make sure your iPad is register in My Support Profile.
    https://supportprofile.apple.com/
    3. Try downloading again; it should be free.

  • How do I get administrator permissions on my Power PC 1.4 mac?

    How do I get administrator permissions on my Power PC 1.4 mac?

    Sashakis wrote:
    Thanks So much for your response, ok then I guess what I ment to ask is , How do I get Root permissions and access to all my cumputer files. When using the Terminal it only allow me to go back so far to view my user folder but not the root folders?
    If you have admin access in your account, then in Terminal, you can go to the file root with
    cd   /  <enter>
    and then go from there.  (The single forward slash is the shorthand for the filesystem mount point.)  You should be able to a number of things otherwise blocked by using the sudo command before the normal Unix command, as in, for instance,
    sudo   touch   /System/Library/Extensions  <enter>
    which is a command which changes the modification date to the current time on the Extensions folder.  When using sudo, you will be asked for your password, and after successful authentication, the command will execute.

  • How can i get my wife set up in iTunes - Same computer

    Hi guys
    I'm trying to figure out the best way to get my wife set up using her own iTunes accounts.
    She has an iPhone and iPad but her laptop is pretty rubbish so i set up a user account on my MBA for her. I use iTunes match under my account, under hers she just has a conventional iTunes Apple ID. As soon as we sign in it warns us any downloaded past purchases will prevent the other Apple ID associated with that computer from working for 90 days. I've read about this and understand there is nothing we can do.
    But can we still use her own iTunes? How about if we sign out of her Apple ID in her iTunes. If she syncs her devices can she get her music on that way without these 90 day warnings? Or will we have to transfer purchases again? Will she be able to import CD's and sync to her devices or do we face the same problem?
    This is pretty frustrating and it ***** no being able to have her own iTunes account on my computer. If the above works with syncing from device to computer, can you purchase everything on her devices and transfer from them?
    Thanks.

    I do have a seperate account for her on the OS - I still get the 1 Apple ID per device warning (we will lock you out for 90 days message).
    We are in her own OS account in her own iTunes library. I wondered if i never sign in there, would we be able to manage her music on the same laptop i use for mine?
    We will have to transfer purchases when syncing with her devices, but will this give us the same error about the 1 Apple ID per device?
    If so that would be really bad, only way to do it is buy her a new laptop. Not good!

  • I want to set up a roaming network. I have directions. I have an extreme set up and working.  I need to add an express.   When I open airport utility I get the internet pic of internet and the base station.  How do a get to the setting screens?

    Directions require that I change settings on the base station on the screen that interent connection, TCP/IP DHCP NAT how do I get to that screen through airport utility.
    Then I need to for my express to get to the screen the screen for wireless.
    This has changed since last time I did this.
    How do I get to the screens.

    Your existing Extreme might already be configured in Bridge Mode. As long as the Extreme is working now, do not change any settings on the Extreme.
    Apple incorrectly assumes that all users are connecting to a simple modem when most users are connecting to gateway devices....combination modem/routers. 
    You probably are as well and Bridge Mode would be the correct setting when connecting to that type of device.

  • Connot get it to accept cookies; privacy settings are re-set each time after I change them. How can I get the privacy setting to stick and accept cookies?

    I need to accept cookies to log into a technical site. I clear all cookies and the history and follow the instructions for setting privacy options to "Use custom settings for history" and to accept all cookies. When I go back to try logging into the site, it still tells me cookies aren't accepted. When I go back to Options-Privacy, the setting has been changed back to "Remember history" from "Use custom settings for history". I have done this about 5 times, trying various options, closing Firefox after making the change and starting it again - nothing works. How can I get the privacy settings to stay as I set them and accept cookies?

    Blocking all cookies in Safari does not work. Deleted cookies will not stay deleted. There are numerous threads on this going back years, both in these forums and elsewhere. Many claim to have submitted the issue to Apple, but I have never seen anyone post a reply.
    I have seen many suggested fixes that involve finding the cookies file, some including Terminal manipulations, and none seems to work universally. I can find noplace where Apple addresses this officially with an actual Apple-approved explanation or how-to.
    Bottom line, your browser's security features should do what they claim: delete cookies. When they come back without ever even visiting another page, this is clearly not working in the way a reasonable user would expect.
    Bottom line, Safari does not protect users' privacy in the way it pretends to and, after so many years of this issue, it appears that Apple wants it this way.
    Having spent way too much time on this, I realize the choice is between Safari which is pretty well optimized; Firefox which is a lot pokier, at least for me; and Chrome, which I assume funnels personal information directly to Google.

  • How do I get out of "Set up or restore from backup" mode?

    Hi I talked to someone from apple and told them icloud messed my contacts up and erased some but i can't sync to comp cause i don't have access to the computer that has all  my contacts on it.  So they told me to go to settings, Reset and then, Rest all settings. I did this but then it asked me to hook up to itunes to restore from backup so obviously i can't do that since i don't have the comp with me.  The worst thing is i can't use my phone now cause it's stuck in Set Up mode.  How do i get out???

    You can't get out of setup mode without a computer. Did you choose Reset All Settings, which should not have required a Restore, or Erase All Content And Settings, which DOES require a restore? Although too late now.

  • How can I get the light for the power button to go back on?

    I would like to get the power button light to work properly again. I have a p6813W desktop running Windows 7, 64 bit OS.
    The first time the machine went into sleep mode and was awoken the power button light went out and has not yet to come back on even after many shutdowns and restarts. I can't easity tell if my computer is on or off. How can I get the light to work properly again?
    Thanks.

    Mac's don't have UI scale options like Windows has.
    Either you can drop the screen resolution in Displays a wee bit and make things appear distorted, or do what I do and use the Universal Access and set a control key, then use a mouse wheel/scroll to zoom in and out where the mouse is pointed.
    For easier web surfing I've got a good solution here
    Better surfing options for hard of seeing users

Maybe you are looking for

  • My iPhone 4 will no longer charge

    After using an off brand car charger, my iPhone 4 won't charge on any other charger. Anyone have any thoughts?

  • Hidden file in a portfolio

    I've been given a Portfolio and am trying to figure out how they made it.  The initial file that's displayed is called "Cover Sheet" but does not appear to be a filename since there is no extension associated with it.  Cover sheet is several pages lo

  • Using Toad for Oracle

    Hi All, I am using Oracle 10g ver. I am able to connect to this database server using SQLDeveloper. I have recently installed Toad. I have installed Oracle Client 10.2.0 to run Toad. And as I have read tnsnames.ora needs to be created in $ORACLE_HOME

  • Upgrade procedure CPI 1.2.1.012 to 1.3.0.020

    My question is simple: Why isn't a GUI upgrade possible instead of CLI initiated upgrade? Is this (GUI) only for patch upgrades or is it a valid upgrade path to use the Cisco Prime's GUI (Administarion; Software Update) in order to upload update file

  • Installing a new iPod on a computer with another iPod already authorized

    I already have one iPod authorized for this computer. My wife has a new ipod that is not getting recognized. Should I deauthize the computer to get her ipod recognized? Thanks!