Execute a powershell script from a windows store apps

Hello Everybody !
I'd like to launch a powershell script from a windows store apps.
In fact the purpose is install a windows store apps from an other windows store apps.
Any ideas?
Thanks

If it's a sideloaded LOB application, you can do this using a brokered component:
http://blogs.msdn.com/b/wsdevsol/archive/2014/04/14/cheat-sheet-for-using-brokered-windows-runtime-components-for-side-loaded-windows-store-apps.aspx
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.
NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
objects and unknown namespaces.

Similar Messages

  • Can we execute a Powershell script from the Javascript?

    Hi,
    I have a certain requirement to add a Custom ribbon button in document library and there was a powershell script to be run for the selected item in the library.
    I have struck with executing a Powershell script from the javascript function.
    Can anyone please suggest me if this was achievable
    Thanks, Swaroop Vuppala

    Hi Swaroop,
    To execute server side code in a custom ribbon button script, using application page is a common way to do this, besides, you can also use a page dialog, which is similar with application page but display as model dialog, another way is javascript
    _dopostback and delegate control, the following article contains detailed information about this, please refer to it for more information:
    Invoke server side code on SharePoint ribbon click:
    http://sharepointnadeem.blogspot.in/2012/07/invoke-server-side-code-on-sharepoint.html
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Login to WebApi (MVC + WebApi) with Microsoft Account from Windows Store App

    Hi
    How can I access a WebApi Controller (ASP.NET MVC+WebApi) that is secured with Microsoft Account from a Windows Store App?
    I have no idea how to login. I tried the LiveSDK but this gives me only access to OneDrive, Callender and so on.
    Could someone please point me in the right direction.
    Thanks
    Guenter

    Hi Guenter,
    To be clear, you are using Microsoft account as login and at same time you have your own REST service for other functionalities?
    Let's say if you login with LiveSDk, you should be able to get some access token, see this for more information:
    Signing users in, after that use the token to access your REST service, as I understand REST service is a kind of http request, we can use HTTPClient to request data from the address.
    I'm afraid there is no existing sample here but the only thing I found is HTTPClient sample:
    https://code.msdn.microsoft.com/windowsapps/HttpClient-sample-55700664, you can use POST to send your token information to the server.
    --James
    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.

  • Printing in Windows Store Apps

    So,
    I am changing this post because my problem is far more complicated (annoying) than originally expected.  If I were creating a WinForms app I would have access to System.Drawing and the Win32 API, but as I am currently trying to create this as a Windows
    Store app, it renders those possibilities moot.
    The idea is to print a small 1x1 inch to a specific printer.  Now, in the Runtime intrerop functionality I could search for the printer driver and just assign that value to the PrintDocument.  Using a graphics I could just draw the in memory bitmap
    to the document and send it away.
    However, in this hyper security limited context of the metro interface "store app" I have found so far only Windows.Graphics.Printing and WIndows.UI.Xaml.Printing namespaces.  Though they seem to allow for sending data to
    a printer thus far I have not found any indication I determine
    which printer.
    The whole idea is a closed box system, so no extraneous dialogs or user interactions.  They pick the image, set the quanity, and the golden hamster wheel spits out a printed label.
    Now, I can do this very simply in a WinForms application, which I will be working on concurrently so I have a final product to deliver, but for myself (and the client) we would prefer a windows 8 metro style app to do this.  (now if store apps just
    access the entirety of .Net that would so much simpler, but wishes and horses).
    So could anyone provide me a map for more advanced control of the Printing process from a Windows Store App that I might figure out how to send the print document to the printer I want?
    Thanks
    Jaeden "Sifo Dyas" al'Raec Ruiner

    Excellent, thanks for the quick reply.
    For clarification, you mentioned a few terms that i would like to clarify:
    1.  windows runtime component / desktop printing API
    this sound like an actual windows 8 desktop application.  Like what you'd run on windows 7 and windows 8 desktop.  (Full .net 3.5/4/4.5 not the "Windows Store App").  Basically a Windows Forms application / class library / win service
    maybe?
    2. brokered
    this term sounds like there is a way to communicate from a Windows Metro/Store (XAML) App to a windows desktop component (a process maybe?).  If so, how does one do that.  If I create a WinForms application and create a class library for it. 
    That class library can be used by any .net application that references it but in the Windows Store App project I can't reference a standard class library, but your use of the term "brokered" suggests there is a way to do this.  Where would I
    find how to do that?
    3. desktop
    Finally, by the mention of the term "desktop" red flags go up.  I personally will never use Windows RT because it lacks the desktop.  However, by the suggestions you've made here the only way to get my goal seems to be in using Windows
    Desktop features.  If I were to create the XAML App and the "brokered component" to thus have access to "desktop printing", is that something that will even work on a Windows RT machine?
    Thanks so much,
    J"SD"a'RR
    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it
    correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

  • Wi-Fi SSID in Windows Store App using Win32 API

    Hi Friends,
    I am trying to get the available WiFi SSID and Signal strength of the networks. As there is no managed API that supports in Windows Store App, I though to creating Win32 DLL of  the WiFi SSID
    code and access from my C# code. Well I am able to access the Win32 DLL from my Windows Store App using C# code but the code fails at
    dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
    if (dwResult != ERROR_SUCCESS) {
    wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
    return 1;
    // You can use FormatMessage here to find out why the function failed
    I think its because the Windows Store App doesn't have support to access the network so it refuse the Win32 code as well. Please correct me if I am wrong.
    Then I was trying to find a way, and for C++/CX, will this help me, or a better solution if any.
    My goal is to get the SSID and the signal strength of the networks.
    And could you please let me know if there any way to get the Signal Frequency also, So that I can apply this
    formula.
    Regards
    Somnath

    WlanOpenHandle is available to desktop apps only: see the version information in the docs.

  • Execute powershell script from ssis?

    Hi,
    I was trying to use the execute process task to kick off a powershell script.  However, nothing happens when I run in debug (the component turns yellow and stays yellow).  Any idea if what I am trying to do is possible and the proper way to configure
    it?
    btw, I am using powershell for the remoting capabilites.  I need to execute a bat file on a remote server which runs a process in a legacy program. 
    Update:  When I name the ps1 script file in the executable window, it opens it in notepad.  This would be like the default if you double clicked the file.
    Mark

    To run a PowerShell Script from SSIS package. Add a "Execute Process Task" in SSIS and use the following command text.
    This works just great, plus the "-ExecutionPolicy ByPass" switch will take care of any server script policies.
    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
    -ExecutionPolicy ByPass -command ". 'L:\Powershell_Script\Script1.ps1' 'param1' 'param2'"
    Regards
    Deepak

  • An unknown error occurred while executing the PowerShell script:

    Hello all,
    Not the most descriptive title, granted. I'm hoping this may prompt the next version toprovide additional valuable content.
    Kindly requesting any help on this problem. I'm running VMM 2012 R2 version 3.2.7668
    When I try to look at properties of an existing Private Cloud, I get this error, only if I "look" at certain attributes. If I stay away from the specific attributes, everything is hunky dory. For reasons unknown, after I get this error, I have
    to exit and go back into VMM in order to get anything else to run.
    The text in the error dialogue box is not entirely applicable because I was connected to the VMM server and will connect again, when I exit/relaunch.
    An unknown error occurred while executing the PowerShell script:
    The connection to the VMM management server scvmm2.mmmmmm.com was lost.
    Ensure that scvmm2.mmmmmm.com is online and that you can access the server remotely from your computer. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. Or, you can ensure that the Virtual Machine Manager service is started
    on scvmm2.mmmmmm.com. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. If the command fails again because of a connection failure, restart the Virtual Manager service and then try the operation again.
    Try the operation again. If the issue persists, contact Microsoft Help and Support.
    ID: 27235
    This is what I get in Events
    Warning 4/9/2015 3:27:04 PM PowerShell (Microsoft-Windows-PowerShell) 4100 Executing Pipeline
    Log Name:      Microsoft-Windows-PowerShell/Operational
    Source:        Microsoft-Windows-PowerShell
    Date:          4/9/2015 3:27:04 PM
    Event ID:      4100
    Task Category: Executing Pipeline
    Level:         Warning
    Keywords:      None
    User:          mmmmmm\paufra
    Computer:      tools-francis.mmmmmm.com
    Description:
    Error Message = The connection to the VMM management server scvmm2.mmmmmm.com was lost. (Error ID: 1610)
    Ensure that scvmm2.mmmmmm.com is online and that you can access the server remotely from your computer. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. Or, you can ensure that the Virtual Machine Manager service is started
    on scvmm2.mmmmmm.com. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. If the command fails again because of a connection failure, restart the Virtual Manager service and then try the operation again.
    Fully Qualified Error ID = 1610,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.GetSCReplicationGroupCmdlet
    Recommended Action = Ensure that scvmm2.mmmmmm.com is online and that you can access the server remotely from your computer. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. Or, you can ensure that the Virtual Machine Manager
    service is started on scvmm2.mmmmmm.com. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. If the command fails again because of a connection failure, restart the Virtual Manager service and then try the operation again.
    Context:
            Severity = Warning
            Host Name = Default Host
            Host Version = 4.0
            Host ID = 94963cd4-5979-4786-9da2-c8814de8c7c3
            Host Application = C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\Bin\VmmAdminUI.exe
            Engine Version = 4.0
            Runspace ID = 359d7a46-3752-4929-8c09-0de4152d10e4
            Pipeline ID = 16
            Command Name = Get-SCReplicationGroup
            Command Type = Cmdlet
            Script Name =
            Command Path =
            Sequence Number = 91
            User = mmmmmm\paufra
            Shell ID = Microsoft.PowerShell
    User Data:
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-Windows-PowerShell" Guid="{A0C1853B-5C40-4B15-8766-3CF1C58F985A}" />
        <EventID>4100</EventID>
        <Version>1</Version>
        <Level>3</Level>
        <Task>106</Task>
        <Opcode>19</Opcode>
        <Keywords>0x0</Keywords>
        <TimeCreated SystemTime="2015-04-09T22:27:04.993655700Z" />
        <EventRecordID>285</EventRecordID>
        <Correlation ActivityID="{48059811-1A63-41E1-9057-7498D0E4FC20}" />
        <Execution ProcessID="2344" ThreadID="4076" />
        <Channel>Microsoft-Windows-PowerShell/Operational</Channel>
        <Computer>tools-francis.mmmmmm.com</Computer>
        <Security UserID="S-1-5-21-4008432563-1984933819-4238309236-2721" />
      </System>
      <EventData>
        <Data Name="ContextInfo">        Severity = Warning
            Host Name = Default Host
            Host Version = 4.0
            Host ID = 94963cd4-5979-4786-9da2-c8814de8c7c3
            Host Application = C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\Bin\VmmAdminUI.exe
            Engine Version = 4.0
            Runspace ID = 359d7a46-3752-4929-8c09-0de4152d10e4
            Pipeline ID = 16
            Command Name = Get-SCReplicationGroup
            Command Type = Cmdlet
            Script Name =
            Command Path =
            Sequence Number = 91
            User = mmmmmm\paufra
            Shell ID = Microsoft.PowerShell
    </Data>
        <Data Name="UserData">
        </Data>
        <Data Name="Payload">Error Message = The connection to the VMM management server scvmm2.mmmmmm.com was lost. (Error ID: 1610)
    Ensure that scvmm2.mmmmmm.com is online and that you can access the server remotely from your computer. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. Or, you can ensure that the Virtual Machine Manager service is started
    on scvmm2.mmmmmm.com. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. If the command fails again because of a connection failure, restart the Virtual Manager service and then try the operation again.
    Fully Qualified Error ID = 1610,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.GetSCReplicationGroupCmdlet
    Recommended Action = Ensure that scvmm2.mmmmmm.com is online and that you can access the server remotely from your computer. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. Or, you can ensure that the Virtual Machine Manager
    service is started on scvmm2.mmmmmm.com. Then connect to scvmm2.mmmmmm.com and try the command again using the new connection. If the command fails again because of a connection failure, restart the Virtual Manager service and then try the operation again.
    </Data>
      </EventData>
    </Event>

    Hi Sir,
    First , please try to run the VMM configuration analyzer on that computer :
    http://www.microsoft.com/en-us/download/details.aspx?id=41555
    In addition , please try to use "VMMTrace" mentioned in following article to collect trace log and find some useful information :
    http://blogs.technet.com/b/jonjor/archive/2011/01/07/vmmtrace-simplified-scvmm-tracing.aspx
    Best Regards,
    Elton Ji
    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] .

  • Cannot execute an AE script from Python 2.7

    I'm trying to execute an AE script from Python and it doesn't appear that the script argument is passing correctly, or the the script won't run for some reason. I'm using Windows 7 with Python 2.7.
    If I use cmd.exe or powershell and try
    afterfx -r D:\pipeline\tests\tactic_ae\hello.jsx
    I get my "hello world" alert in the AE UI.
    However, if I try executing in Python:
    subprocess.call(["afterfx","-r","D:\pipeline\tests\tactic_ae\hello.jsx"])
    The AE UI takes focus but no alert appears. The really strange part is if I try to do something invalid like remove the -r flag:
    subprocess.call(["afterfx","D:\pipeline\tests\tactic_ae\hello.jsx"])
    I get an AE error:
    After Error Can't import file "hello.jsx": unsupported filetype or extension
    It does seem like Python is passing the arguments or the error above wouldn't be generated, but why won't the script run and display the alert? Thanks!

    I've personally been unsuccessful in trying to attempt this, but I am also not too command line savvy. There may be a creative workaround out there somewhere though.

  • Run PowerShell script from C# writing to input pipe

    Hello,
    I am trying to run a PowerShell script from C# (I have no control over what's in the script). The script may have a prompt like "Press enter to continue". So my goal is:
    1. Get text output from the script (easy, many examples available)
    3. If output contains "Press enter to continue", write a blank line to the running script's pipe to make it finish its job and quit
    4. If output does contain that prompt, just let it exit by itself without sending any input
    Note that commands in this PS script also try to get at script's file path, so I can't read script from file and pass it as text. It has to be executed as a script so it knows where it's located.
    I have done this with .exes and batch files before. All you do in that case is process.StandardInput.WriteLine() which "types" enter into the input stream of script you are trying to control. But this does not work with Power Shell. How do I do this?
    I have tried using PS object model like so:
    using (Pipeline pipeline = runspace.CreatePipeline())
    Command command = new Command(scriptPS, true, true);
       pipeline.Commands.Add(command);
       pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
       pipeline.Input.Write("\n");
       Collection<PSObject> psresults = pipeline.Invoke();   //...
    But I get an error because the script prompts:
    "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related
    commands from command types that do not support user interaction, such as Windows PowerShell workflows."
    I also tried using Process, and running PowerShell with -File switch to execute the script, then write to StandardInput with C#. I get no errors then, but the input is ignored and doesn't make it to PowerShell.
    Please help!

    No man, what kind of answer is that? You should have left it unanswered rather than waste people's time like this. I already seen those links before I posted my question. They address the issue of specifying script parameters, but not
    writing to the input pipe.
    Fortunately I did figure this out by writing a custom script host for PowerShell. Anyone interested can read about this in detail on MSDN (fortunately simple material with samples you can copy paste as I did, so this solution takes little time to implement).
    Implement PSHost interface. Nothing special here, just paste directly from MSDN sample and modify their SetShouldExit function definition to contain just a "return;". Here's the relevant link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706559(v=vs.85).aspx
    Implement PSHostUserInterface interface. This is the ticket to solving this problem
    (see below). Here's the MSDN link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706584(v=vs.85).aspx
    Implement PSHostRawUserInterface. This may not be required (not sure) but I did anyway. Nearly a direct paste from MSDN:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706601(v=vs.85).aspx
    So, there are two PSHostUserInterface function implementations that are of particular interest. First is Prompt (read header comment to see why):
    /// <summary>
    /// When script attempts to get user input, we override it and give it input programmatically,
    /// by looking up within promptInput's dictionary<string,string> or lineInput array.
    /// PromptInput dictionary is mapped by input prompt (for example, return "" in response to "Press ENTER to continue")
    /// LineInput is a regular array, and each time the script wants to prompt for input we return the next line in that array;
    /// this works much like piping inputs from a regular text file in DOS command line.
    /// </summary>
    /// <param name="caption">The caption or title of the prompt.</param>
    /// <param name="message">The text of the prompt.</param>
    /// <param name="descriptions">A collection of FieldDescription objects that
    /// describe each field of the prompt.</param>
    /// <returns>Throws a NotImplementedException exception.</returns>
    public override Dictionary<string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
    Dictionary<string, PSObject> ret = new Dictionary<string, PSObject>();
    foreach (FieldDescription desc in descriptions)
    if (this.promptInput.Count != 0)
    ret[desc.Name] = new PSObject(this.promptInput[desc.Name] + "\r\n");
    else if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    ret[desc.Name] = new PSObject(this.lineInput[this.currentLineInput++] + "\r\n");
    else
    if (desc.DefaultValue == null)
    ret[desc.Name] = new PSObject("\r\n");
    else
    ret[desc.Name] = new PSObject(desc.DefaultValue);
    return ret;
    Next is PromptForChoice. Here I opted to always return the default choice, but you could rewrite it to read from somewhere to "simulate" reading from input pipe just like the function above:
    public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection<ChoiceDescription> choices, int defaultChoice)
            return defaultChoice;
    Last but not least, here's a ReadLine implementation (again read header comment):
    /// <summary>
    /// If the LineInput is set, "read" the next line from line input string array, incrementing line pointer/// </summary>
    /// <returns>The characters that are entered by the user.</returns>
    public override string ReadLine()
    if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    return this.lineInput[this.currentLineInput++];
    else
    return Console.ReadLine();
    Both are exposed as properties:
    /// <summary>
    /// Gets or sets the input pipe override
    /// </summary>
    public string Input
    get
    return string.Join("\n", this.lineInput);
    set
    if (value != null)
    this.lineInput = value.Split('\n');
    this.currentLineInput = 0;
    else
    this.lineInput = null;
    /// <summary>
    /// Gets or sets input pipe override for named prompts
    /// </summary>
    public Dictionary<string, string> PromptInput
    get
    return this.promptInput;
    set
    this.promptInput = value;
    And finally, here's how the whole shebang is used:
    /// <summary>
    /// Runs a powershell script, with input pipe arguments
    /// </summary>
    /// <param name="script">Path of the script to execute, or script text</param>
    /// <param name="inline">Whether or not to execute script text directly, or execute script from path</param>
    /// <param name="unrestricted">Whether or not to set unrestricted execution policy</param>
    /// <param name="parameters">Parameters to pass to the script command line</param>
    /// <param name="inputOverride">Input to pass into the script's input pipe</param>
    /// <param name="inputOverrideName">Input to pass into the script's input pipe, to each prompt by label</param>
    /// <returns>Output lines</returns>
    public static string PowerShell(string script, bool inline, bool unrestricted = false, Dictionary<string, string> parameters = null, string inputOverride = null, Dictionary<string, string> inputOverrideByName = null)
    string output = null;
    ScriptHost host = new ScriptHost();
    (host.UI as ScriptHostUserInterface).Input = inputOverride;
    (host.UI as ScriptHostUserInterface).PromptInput = inputOverrideByName;
    using (Runspace runspace = RunspaceFactory.CreateRunspace(host))
    runspace.Open();
    if (unrestricted)
    RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
    runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
    using (Pipeline pipeline = runspace.CreatePipeline())
    if (inline)
    pipeline.Commands.AddScript(script);
    else
    Command command = new Command(script, true, true);
    foreach (KeyValuePair<string, string> param in parameters)
    command.Parameters.Add(param.Key, param.Value);
    pipeline.Commands.Add(command);
    pipeline.Commands.Add("Out-String");
    pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
    Collection<PSObject> psresults = pipeline.Invoke();
    var sb = new StringBuilder();
    foreach (PSObject obj in psresults)
    sb.AppendLine(obj.ToString());
    output = sb.ToString();
    pipeline.Dispose();
    runspace.Close();
    return (host.UI as ScriptHostUserInterface).Output + "\r\n" + output;
    As you can see, I also did some magic with the .Output property. That just accumulates lines of text output by the script in every WriteXXX function implemented in your custom PSHostUserInterface. The end result of all this, is that if you have a script
    that has prompts, choices or reads from standard input, you can execute the script within the context of your custom script host written as above, to control precisely what strings are passed to it in response to prompts.
     

  • Executing a powershell script for checking duplicate users while creating a AD user throug ADUC console.

    Hi,
    I have a text file in which some SamAccountNames are present.I need to check the file while creating a new users through ADUC console.If a username that is going to create through ADUC console is present in the file, then it should prompt a message
    that the user is already present in the text file.
    Is there any possibility of contacting the powershell script from the ADUC console.If so, then while creating a new user through ADUC console, what is the proceedure for executing that powershell script.
    please provide me the approriate solutions.
    Thanks
    Prasanthi k

    Run the below Powershell Script for users are exist or not in AD. Later you can create the users.
    #Find Users exist in AD or Not?
    #Biswajit Biswas
    $users = get-content c:\users.txt
    foreach ($user in $users) {
    $User = Get-ADUser -Filter {(samaccountname -eq $user)}
    If ($user -eq $Null) {"User does not exist in AD ($user)" }
    Else {"User found in AD ($user)"}
    Active Directory Users attributes-Powershell
    http://gallery.technet.microsoft.com/scriptcenter/Getting-Users-ALL-7417b71d
    Regards~Biswajit
    Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights.
    MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, MCTS, Enterprise Admin
    MY BLOG
    Domain Controllers inventory-Quest Powershell
    Generate Report for Bulk Servers-LastBootUpTime,SerialNumber,InstallDate
    Generate a Report for installed Hotfix for Bulk Servers

  • Context Menu to Execute a powershell script within selected directory.

    Hi,
    I'm trying to run a powershell script from a context menu, I've been able to create a context menu, however, when I attempt to run the script it will only run at the default location. What I'd like to do is right-click a folder then click "Do Script"
    and have it run the script with the location set to the directory I right clicked.
    So for clarities sake, if I right click C:\example then when the script runs it should recognize .\ as C:\example
    This is what I currently have in my registry entry. However it's shouting about how there is no parameter for Set-Location that matches -File, I can see that it's taking the Set-Location command, then it's trying to see if -File will is a perameter for it,
    but I' trying to use -File for the powershell command. Anyone have any ideas for that?
    PowerShell -Command "Set-Location -LiteralPath '%V'" -File C:\script\Test.ps1
    Any ideas? I'm wondering if there is something in Powershell like how Bash has something like this to do commands inline
    $ > Command -parameter <arg> && Command -parameter <arg>

    To setup a script to launch in a men from within a context menu you must create a the following.
    Create the following keys:
    HKEY_CLASSES_ROOT\Directory\Shell\<Script Name>
    HKEY_CLASSES_ROOT\Directory\Shell\<Script Name>\command
    Within <Script Name> change the (Default) value to the words you want to have as a context menu example, "Launch Script Here".
    Within the command Key change the (Default) value to
    PowerShell.exe -File "C:\Script_location\script_name.ps1" "%v"
    PowerShell.exe is executed with the -File flag followed by the scripts exact location and "%v " is a variable pointing to the location that was selected.

  • Run Powershell script from Scheduled Task as "NT Authority \ SYSTEM"

    Hello, dear Colleagues.
    Cannot make Powershell script from Scheduled Task as "NT Authority \ System"
    Action: Start a program - 
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "C:\script.ps1"
    The matter is that script is working, moreover if to run Task with Domain Account it works too.
    Checked Run with highest privileges, changed "Configure for" field, tried different arguments (-noprofile, -noexit, -executionpolicy bypass, -command, -file,") - no luck.
    Didn't you try to make it work with SYSTEM account?
    Thanks.

    Hi fapq,
    Try this link task schedulers
    Note
    To identify tasks that run with system permissions, use a verbose query (/query/v). In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and
    the Logon Mode field has a value of Background only.
    Naveen Basati

  • Powershell to get Descriptions/Reviews of Windows Store apps ?

    I am so wildly excited that Win10 will come with a real package manager as well as that the idea of programmatically accessing Windows Store items for CRUD is a supported feature. This is a huge win for MS over Apple imho.
    The other thing that drives me crazy about Apple store (ie besides being hard/impossible to programmatically add/remove) and is similar to the Windows Store for win8 is the GUI-only display of pre-sales/pre-install information.
    Is there a way to get info about a Windows store app from the command line, eg Powershell? For example, can I print a list of review with their posting dates and the manufacturer's description?
    thank you!

    I love this! ty, here is a sample output ;
    Name : Microsoft.ZuneMusic
    Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
    Architecture : X64
    ResourceId :
    Version : 2.6.672.0
    PackageFullName : Microsoft.ZuneMusic_2.6.672.0_x64__8wekyb3d8bbwe
    InstallLocation : C:\Program Files\WindowsApps\Microsoft.ZuneMusic_2.6.672.0_x64__8wekyb3d8bbwe
    IsFramework : False
    PackageFamilyName : Microsoft.ZuneMusic_8wekyb3d8bbwe
    PublisherId : 8wekyb3d8bbwe
    IsResourcePackage : False
    IsBundle : False
    IsDevelopmentMode : False
    Dependencies : {Microsoft.VCLibs.120.00_12.0.21005.1_x64__8wekyb3d8bbwe,
    Microsoft.Media.PlayReadyClient.2_2.11.2154.0_x64__8wekyb3d8bbwe,
    Microsoft.WinJS.2.0_1.0.9600.17018_neutral__8wekyb3d8bbwe,
    Microsoft.ZuneMusic_2.6.672.0_neutral_resources.scale-140_8wekyb3d8bbwe}

  • Executing a shell script from a java program

    Hi,
    I'm facing a problem while executing a shell script from a jsp page.
    I'm using exec() function.
    It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
    Will u please help me in this.
    If there is any other ways to execute a shell script from a jsp page other than Runtime.exec().If so let me know.
    Thanks in advance.

    I think this shud workMaybe - but it is wrong! Why do you create aReader
    and then read bytes which are turned into a String
    without worrying about whether or not the bytes area
    String and without worrying about the character
    encoding if the bytes do represent characters and
    without worrying about how many bytes wereactually
    read.
    Also, both you and the OP should read, digest and
    follow the advice given in
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
    traps.htmlI dont care if it is wrong. This code works for me.
    We are here to solve problems not to find which post
    is wrong.It is wrong! You are posting bad advice that is very wrong! It may work for you but it is wrong in general! WRONG WRONG WRONG.
    If you have a solution then post it I did post a solution! The reference I gave will explain to you and the OP exactly how it should be done.
    rather then
    posting rude comments.I was not rude! I was explaining just some of what was wrong!

  • Executing a shell script from a jsp page

    Hi,
    I'm facing a problem while executing a shell script from a jsp page.
    I'm using Runtime.exec() function.
    It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
    Will u please help me in this.
    If there is any other ways to execute a shell script from a jsp page other than Runtime.exec() like RMI etc,.If so let me know.
    Thanks in advance.

    Hello,
    It's hard to help you but what you can do is listening to the outputs of your script, you should read the output stream and error stream and send them to the default console.
    Check this excellent article : http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
    Best regards,
    Olivier.

Maybe you are looking for