Powershell start-process argumentlist

I have an issue with powershell 4.0 where start-process converts my credentials from a type of System.Management.Automation.PSCredential to System.String.  Use the following lines to replicate this:
$Credentials = Get-Credential
get-member -InputObject $Credentials
start-process C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ArgumentList "Get-Member -inputobject $Credentials | out-file C:\results.txt"
If you look at the results of the 1st get-member command, the type is System.Management.Automation.PSCredential.  If you look at the results of the 2nd get-member command, the type is System.String.  Does anyone know if this is intended behavior? 
Is there a way around it?

I am using start-process to run a command which interfaces with VMware PowerCLI.  One of the cmdlets of powercli is Set-OSCustomizationSpec.  Set-OSCustomizationSpec has an argument that accepts PSCredentials, -DomainCredentials.  When the
credentials are passed without start-process, the cmdlet succeeds.  If I call it with start process, the cmdlet fails with the error
'Set-OSCustomizationSpec : Cannot bind parameter 'DomainCredentials'. Cannot convert the "System.Management.Automation.PSCredential" value of type "System.String" to type "System.Management.Automation.PSCredential"'
The actual command i am using is: "start-process powershell -argumentlist "<Add VMwareSnapins>;Set-OSCustomizationSpec <SPEC> -NamingScheme <Scheme> -NamingPrefix <Name> -DomainCredentials <Credentials>; new-vm..."
If you issue the command "get-member -inputobject $Credentials | out-file C:\results.txt" the type shows system.management.automation.pscredential.  If you issue the exact same command with start-process(start-process powershell.exe -argumentlist
"get-member....) the type shows system.string. 
The issue has nothing to do with piping to a text file.  The original post was simply a demonstration of the error.  I apologize for the initial lack of clarity. 

Similar Messages

  • Powershell v4: Start-Process rar.exe

    Good day.
    I apologize in advance for my bad english.
    I need to call rar.exe (cmd winrar) with Start-Process cmdlet (and not with &), because I need the script waits for completion of archiving, so I want to use it with -Wait parameter. But I do not really know how to type Argumentlist:
    Start-Process -FilePath "path_to_winrar\rar.exe" -ArgumentList "a -df $ArchiveName @$filelist" -Wait
    Where $filelist is the list with files to archive.
    Actually i have tried many combinations but did not succeed, the archive just does not created.
    Please help.

    2 Bill_Stewart
    I don`t know how to explain this. It works if I define variables in script, for example easy script to collect files, put them to the list, archive them and then delete (it is just an example, I know I can delete files by
    -df parameter of rar.exe):
    #get some files for archiving
    $Files = Get-ChildItem "E:\Startx" -Recurse -File
    #define list of files for archiving
    $filelist = "G:\Utilization\Reports\filelist.txt"
    #add files fullnames to the list
    $Files | foreach {$_.Fullname} | Out-File $filelist -Append
    $reportname = "G:\Utilization\Reports\Del_report.txt"
    $archivename = "G:\Utilization\Archives\archive.rar"
    #add files from $filelist to archive
    if ($Files -ne $null) {&"C:\Users\kopilov\Desktop\WinRar\rar.exe" a $Archivename "@$filelist"}
    #then delete all these files
    foreach ($file in $Files)
    if ($file -ne $null)
    "Deleting $($file.Fullname)" | Out-File $ReportName -Append
    Remove-Item $file.Fullname | Out-Null
    else
    "No files for deletion" | Out-File $ReportName -Append
    BUT there is another example, where files collected by lastaccesstime attribute (actually it does not matter),
    however variables are set as parameters during start of the script:
    C:\Users\kopilov\Desktop\arraytest.ps1 -TargetFolder "E:\Startx" -Minutes 1
    And the file deletion function does not wait for the rar.exe to complete, and files are deleted
    before archiving.
    The script itself:
    param(
    [parameter(Mandatory = $true)]
    $TargetFolder,
    [parameter(Mandatory = $true)]
    $Minutes
    $Now = Get-Date
    $LastAccess = $Now.AddMinutes(-$Minutes)
    $Files = Get-ChildItem $TargetFolder -Recurse -File | Where {$_.LastAccessTime -le "$LastAccess"}
    $NameDate = (Get-Date).tostring("dd.MM.yyyy")
    $ReportName = 'G:\Utilization\Reports\' + "$((Get-Item $TargetFolder).name)_" + $NameDate + '.txt'
    $ArchiveName = 'G:\Utilization\Archives\' + "$((Get-Item $TargetFolder).name)_" + $NameDate + '.zip'
    $filelist = 'G:\Utilization\Reports\'+ "$((Get-Item $TargetFolder).name)list_" + $NameDate + '.txt'
    $Files | foreach {$_.Fullname} | Out-File $filelist -Append
    if ($Files -ne $null) {&"C:\Users\kopilov\Desktop\WinRar\rar.exe" a $ArchiveName "@$filelist"}
    foreach ($file in $Files)
    if ($file -ne $null)
    "Deleting $($file.Fullname)" | Out-File $ReportName -Append
    Remove-Item $file.Fullname | Out-Null
    else
    "No files to delete" | Out-File $ReportName -Append
    It is almost the same, but call operator & works different. Do not know how to explain this.
    P.S. i just figured out that Start-Process with -Wait parameter works like call operator &.
    Sorry, I was wrong. I don`t know why scripts above works different :(

  • Powershell using start-process OR Invoke-Item to access directory are getting warning permissions popup.

    I am new in PS so please forgive me for any idiocy I speak. I have a File Server in Windows 2012 R2, a couple days ago I added one domain user to local administrator group in this File Server. For any folder that I try to access I am getting the Warning message
    saying: "You don't currently have permissions to access this folder. Click Continue to permanently get access to this folder." When I click "Continue" the Windows grants to me the rights permissions, ok it is perfect but I have to do it
    for any folder in my file server.
    So, let's to I tried so far..
    I know I can use Set-acl to set the permissions to the user but for this likely I will need change almost the whole permissions structure.
    Actually I am trying use Invoke-Item and Start-Process to simulate the folder access and ofcourse the Warning permissions popup came up. What I am thinking about and can't realize is make each time the Warning permissions popup come up by using Invoke-Item
    or Start-Process whatever the Powershell automaticaly clicks on the "Continue" button.
    Any one can help me with, please?

    Hi Michel,
    you can circumvent the ACL System by enabling Backup and Restore privileges (when running locally). There's a
    great Module for that.
    However, for a more pragmatic approach, shouldn't access-permissions be handled using Domain Groups? If you want a File Server Admin, why not create a single group named "Data Administrators", set it to full control for all directories (that'll
    take changing the permissions once, which will probably take some time) and add that user to this group.
    That way, if you later want to have another user administrate the folder structure, all you need to do is change group membership. Furthermore it avoids having to add local administrative privileges for a function that doesn't really require them (least
    privilege best practice).
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • Start-Process : This command cannot be run due to the error: The system cannot find the file specified.

    Hi, 
    I need some help with my script. It copies the file to the remote laptops but when it needs to install the .exe it fails.
    If I run 1 line at the time in Powershell ISE, then it works. Somebody has an idea why it doesn't work or can help me on the right way?
    Script: 
    $laptops = Get-Content -Path "C:\Users\bruyld01\Documents\STEPSTONE\Powershell\SAP\LaptopList.txt"
    foreach ($laptop in $laptops)
        Copy-Item "C:\Users\bruyld01\Desktop\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V5.exe" -Destination \\$laptop\C$\
        Enter-PSSession $laptop
        $version = Get-WmiObject -Class Win32_Product | where {$_.Name -like "*SAP Business*"} | Select-Object Version
        if ($version -ne "135.0.2071.1047")
            Start-Process -Filepath "C:\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V5.exe" -ArgumentList "/quiet"
        else
            Write-Host "SAP outlook add-in is up to date!" -ForegroundColor Green
        Exit-PSSession
    Error message:
    Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
    At line:2 char:1
    + Start-Process -Filepath "C:\SAP_Business_ByDesign_Add-In_for_Microsoft_Outlook_V ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    Thanks, 
    Dimitri

    Hi,
    Enter-PSSession is used for interactive remote sessions. Look into Invoke-Command instead.
    http://ss64.com/ps/invoke-command.html
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Error trap with Start-Process

    I am trying to use Start-Process to drive Regedit merging a REG file with this code.
    Start-Process regedit -Argumentlist:"/S $TempReg" -Wait -ErrorAction:Stop
    When the REG file is properly formatted this works a treat, but I can't seem to address the error condition. If I do a Try/Catch it seems to produce a successful Try. I tried doing it with a return code as well, and that didn't seem to see the error either.
    Am I doing something wrong in the code, or is Regedit a special case, and if so, can I catch errors from it at all?
    Thanks!
    Gordon

    Hmm, I assume you mean Regedit can't be used "with an error trap"? So, perhaps a different form of the question. First thing to note is that I have tried to address this with direct PowerShell access to the registry, and for some reason Autodesk
    products don't respond well to that approach. Everything looks right when I do it, but then the Autodesk product will push it's own settings over the top, and their settings are idiotic. However, when I push my settings via REG file the Autodesk products accept
    it and move on.
    So, does anyone have a suggestion for either
    A: Identifying exactly what the difference is between the .REG and Set-ItemProperty approaches, so the more elegant solution can be made to also work? Or
    B: Another approach to REG file merge that does allow for error trapping?
    My only other option I think is to implement it without error trapping, as the functionality is pretty important, and the most likely errors will show up in testing not production anyway.
    Thanks!
    Gordon

  • Invoke-WMIMethod failed to start process on remote server

    Hi Folks,
    I am trying to run an exe in remote server to automate some of my application startup process in disconnected mode(Using powershell 2.0). However Invoke-WmiMethod does not trigger the application but start-process triggers it fine. I am trying following
    command -
    $FullExecutable = "\\remoteserver\abc\project\environment\ServerApplications\ApplicationDirectory\App.exe"
    $Arguments = "stanza=ApplicationVariable"
    PS Microsoft.PowerShell.Core\FileSystem::\\remoteserver\abc\project\environment\ServerApplications\ApplicationDirectory> Invoke-WmiMethod -class Win32_process -name Create -ArgumentList "$FullExecutable $Arguments"
    I tried these options but no luck -
    http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx
    Please help me fixing this issue. Thanks for any advice.
    Charlie

    Hi Charlie,
    Since I have no test app.exe file, I tested with notepad.exe and ran these scripts to open local file D:\1.txt, would you please list the test results with app.exe:
    $a="Notepad.exe"
    $b="D:\1.txt"
    Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "$a $b"
    ([wmiclass]"win32_Process").create("$a $b")
    Start-Process $a -ArgumentList $b -wait -NoNewWindow -PassThru
    If you have any other questions, please feel free to let me know.
    Best Regards,
    Anna Wang

  • Invoke-command -computername RemoteServer {start-process c:\install\.bat}

    I am running an invoke command from a PC to run a .bat file on a remote server. However i would like to see the output of the .bat file run in my powershell window on my local PC. Any tips on this?
    I have this at the moment
    invoke-command -computername Server {start-process c:\install\.bat}
    however this just completes without showing  me anything. Can i see the output of the .bat file on my local PC?
    Thanks in advance

    invoke-command -computername Server01 -filepath c:\Scripts\scriptname.ps1
    The script has to be on the local machine or has access to it.
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • BPM Start Process

    We have scenario(file to file) where we get multiple files and is merged using BPM, transformed and sent to the receiver. We have file This is a time based collection. Incoming file adapter is set to poll every 30 sec, and the block in BPM timeout in 2 mins ( for testing purpose).
    The BPM receive step (inside the loop) has the start process turned on. The expected behaviour was to receive all files in one instance of BPM and send the merged one out.
    It is spawning the multiple BPM instance based on number of files in the sender file adapter. My guess is it is doing this since we have the start process on receive step and for each receive it is starting a new process. How do we eliminate this to have only one instance start as I am not finding any other step prior to receive ( block , and loop) where I can start the process.
    Any help is appericiated.
    Thanks,
    Samir

    1. If you want to merge the same file format , Use "Loop" step before "Recevie" step. Put some deadline branch , which will ensure your time limit.
    This would resolve your problem.
    2. If you want to merge different file format , you need to have multiple "Receive" steps and for that you need to use the "Fork" step.
    Let me know if you still find any problem.
    Thanks & Regards,
    Dijesh Tanna.

  • Existing Categories are not listed in the Start Process

    Hello,
    I am currently using LC ES3 with SP3 and start having an issue with no Catgory listed in the Workspace ES3.
    I checked the AdminUI > Application n Services > Categories and no Category is there either. If I create a new Category in the Admin UI then I can see it is listed in the Workspace ES3 but not sure why all of the existing Categories are not listed there.
    Does any one have idea about this issue or any advise on this? Can you please share.
    Thanks in advance,
    HD

    The -1 simply means it has no parent.  I'm not sure when they enabled trees in the categories(much needed improvement!) as we just upgraded finally from 8.2....  For example if you have Category 1 and Category 2.  If they are both -1 you will see them both on the "Start Process" screen.  Where as if Category 1 was OID(2001) and parent_oid(-1) and Category 2 was OID(2005) and parent_oid(2001) then Category 2 would be under Category 1 in a treeview.
    You just need to make sure that the parent_oid column is not nothing.  If you did an upgrade it most likely is like ours was and the column is empty since it was a new column that 8.2 did not have.
    Pic1 is (-1) for both.
    Pic2 is Category 2 having Category 1 as it's parent.
    Pic of the database for With Category 2 using Category 1 as a parent.

  • Can't get batch from droplet to start processing

    I'm using Compressor 4.0.7 running 10.8.5, but I've seen similar posts on other boards (Creative Cow) reaching back 2-3 years with same issue so I don't think it is new.
    When using a droplet to submit a batch vs. submitting manually through Compressor, the droplet batch appears in Share Monitor, but hangs with a status of "Waiting" and never begins to get processed by my QuickCluster.
    It clearly seems to be a bug as I did an A-B test without restarting any machines (host or clients) in the cluster and tried to submit 8 files by dragging them to the droplet.
    Within a few seconds the batch appeared as expected in Share Monitor, but was stuck "waiting."
    After a few minutes I manually created a batch in Compressor using the exact same 8 files, with same settings and same destination and submitted it directly from Compressor.
    After a few seconds that batch also appeared in Share Monitor and immediately started processing correctly.
    After it was finished successfully I then thought that maybe the "waiting" batch would then start up since things had gotten started in the queue.
    No such luck - it just continued to hang with the "waiting" status.
    Any ideas? It sure would save a ton of time to be able to use the droplet over and over ...
    thx in advance.

    Thank you very much for helping Allan. Something must have been wrong with the iTunes software. I switched it from Automatically sync when the iPhone is connected, to manual, clicked apply, then switched it back to Automatic, and now sync is in process. As a side note, I'm on Windows 7 and that may have had something to do with it. But it's working now, and why it didn't before when I did exactly the same thing is beyond me.
    But again, thanks for your help.

  • Using CREATE PROCESS and START PROCESS in a JSP

    Hi,
    I have built a simple JSP page. I want to call my workflow program from this page.
    How should I use the CREATE PROCESS() AND START PROCESS() inside the JSP page?
    Also I want to get the value entered in the text field (which will be a hidden field) to be passed to the ITEM_ATTRIBUTE, which I have defined in my program. How can this be achieved?
    Please give me the syntax for this.
    Please find below the JSP page
    =========================================================
    <%@page import= "java.util.Date" %>
    <script language="javascript" src="ibeCButton.js"> </script>
    <html>
    <head>
    <title>First Page</title>
    </head>
    <body>
    <H3>Today is:
    <%= new java.util.Date() %>
    <INPUT TYPE="text" NAME="CART_ID">
    <INPUT TYPE="submit" onclick = >
    </H3>
    </body>
    </html>
    ==========================================================
    To use LAUNCHPROCESS in JSP, the following is the syntax.
    public static boolean launchProcess
    (WFContext wCtx,
    String itemType,
    String itemKey,
    String process,
    String userKey,
    String owner)
    Should WFContext have the connection information of the DB.
    If I pass only the WFContext and itemType attributes are they enough? Please let me know.
    Thanks

    There are two options.
    1. Good one.
    Include wf*.jar files in your system CLASSPATH. Use oracle.apps.fnd.wf.engine.WFEngineAPI class to access engine APIs. You would need to pass WFContext for which you need WFDB.
    You basically created WFDB with username, password and connect string. Pass it to WFContext and use it for all Workflow Engine APIs.
    2. OK one.
    You can get JDBC connection using the default mechanism that your custom Java and JSP code could be using. Call the PLSQL procedures WF_ENGINE.CreateProcess and WF_ENGINE.LaunchProcess over JDBC.
    Anyways option 1 makes life easier.

  • Create Requisition Request - MSS (Start Process Grey Out-No Data available)

    Hello All
    We are using SRQ2 extended requesition request. Currentlt i am on Devlopment system and just want to see the standard requistion request from MSS so that later i can make a Z copy and customize
    Now when i logged in as a Manager and click on the "Create Requisition Request" from recruiting role it's opening and showing me the Start Process window and everything is non editable and showing me that No Data Avaialble
    Is there any config missing for this
    Also when is see the SRQ2 from SPRO "Define Own Scenarios for Request to Change Master Data" node i made the SRQ2  application as H and aslo tried. But nothing useful.
    Can any one tell me any configuration missing or any other things

    Solved.
    Problem was in MSS the Ehp4 links for erecruiting refers to SRQ3. So i had to pull the iviews from MSS 1.31 BP which will be Webdynpro Java

  • Unable to start process via GP API in which group is exposed as input

    Hi,
         I am not been able to start process using GP API for the particular senario.
    I created Process at design time.
    In this process I mapped parameters to a group and exposed this group, So that input is required for initiating the process.
    Now I want to initiate this process via GP API.
    I got sucess in starting processes which takes parameters as inputs or which does not need any inputs, but i was not been able to start process where group is exposed.
    it's giving me GP INVOCATION Exception.
    Please Help ASAP
    Regards,
    Pratik

    Pratik,
    I try to simulate with scenario described by you and I got success with my test.
    Follow my java code:
         public boolean initiateProcessSDN () {
              boolean ret = false;
              try {
                   IUser user = UMFactory.getUserFactory().getUserByLogonID("uces");
                   IGPUserContext userContext = GPContextFactory.getContextManager().createUserContext(user);
                   IGPProcess processTemplate
                        = GPProcessFactory.getDesigntimeManager().getActiveTemplate(
                                  "8DC0B411957D11DDB7910017F2EBE4A5", userContext);
                   IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
                   IGPStructure params     = GPStructureFactory.getStructure(processTemplate.getInputParameters());
                   params.setAttributeValue("NameGroup", "Pedro");
                   params.setAttributeValue("AddressGroup", "XPTO");
                   IGPProcessRoleInstanceList roles = rtm.createProcessRoleInstanceList();
                   IGPProcessInstance prInstance
                        = rtm.startProcess(     processTemplate,
                                            "Test 1",
                                            "Test 2",
                                            user,
                                            roles,
                                            params,
                                            user);
                   ret = true;
                   } catch (Exception ex) {
                        ret = false;
              return ret;
    Print screen about my GP design:
    Callable Object with 4 parameters
    http://img530.imageshack.us/img530/16/sdngpgroup001bt5.jpg
    Action grouping CO parameters into 2 groups
    http://img147.imageshack.us/img147/2006/sdngpgroup002xy3.jpg
    Process reflecting these groups as input parameters
    http://img147.imageshack.us/img147/9184/sdngpgroup003pp0.jpg
    Process started by java code above
    http://img530.imageshack.us/img530/8833/sdngpgroup004no4.jpg
    Best Regards,
    Pedro Nunes

  • Cannot start BPM process, "Start process" button is disabled: Why?

    Dear all,
    I am working on the BPM example "Modeling Your First Process with SAP NetWeaver Business Process Management" with the "Purchase process". I did everything as mentioned in the tutorial.
    At the end, I would like to start the process using
    NWA > Configuration management > Processes and Tasks > Process Repository
    I can see my WD example that I have deployed and I see the my task definitions and my process definition. In the tutorial it says, that I can select the process definition and click "Start process". But the button "Start process" is always disabled. I cannot click the button. I don't know why. Did I miss something?
    I am logged in as Administrator. I am using NW AS 7.2 and I am developing with NWDS 7.1 SP04.
    Anyone has an idea what can I do to start the process?
    Thanks in advance
    Edited by: Patrick Beck on Jun 25, 2010 4:55 PM

    Thanks for the link.
    I added the new context attribute in the XSD files (under Process Modeling > Data Types > XSD Files).
    Since I added a new context attribute "Comment" of type String in my Web Dynpro, I added the following on the corrent position of the XSD files:
                             <xsd:element name="Comment" type="com.sap.dictionary.string">
                   <xsd:annotation>
                        <xsd:appinfo>
                             <xsd:attribute name="ReadOnly" type="xsd:boolean" fixed="false"/>
                                                                          </xsd:appinfo>
                   </xsd:annotation>
              </xsd:element>     
    I also edited input and output mapping of the human and automated activities to support the new attribute "Comment". I thought this is enough to pass the new "Comment" parameter from activity to activity.
    But when I started the process, I filled in the comment field in Web Dynpro and went to the next step in the process. Seems like the new attribute value for "Comment" got lost. It does not appear in the next process step.
    Did I miss something?
    These are the steps I did:
    - edit Web Dynpro UI to support the new context attribute "Comment". created new input field and mapped to the Comment context attribute (that is defined in my WDP interface).
    - edited XSD files (one for each human activity) to support the new Comment attribute as mentioned above.
    - edited the mapping between the activities to support pass-through of the new Comment attribute between the activities
    But it seems like it's not saved in the context attribute "Comment". It got lost after the first step.
    Any ideas?

  • Collect BPM - Start process and correlation in one Receiver

    I'm using collect pattern based on timeout. Somehow in my infinite loop, in the receive step, I cannot combine "start process" with creating correlation and using it. All in the same receiver. When I try to activate my BPM, in the processing log I get, "start process" trigger removed.
    Can someone throw any light on this....I've being trying this for over few hours now. I cannot get start process and correlation in one receiver. I must be doing something wrong.
    Even the copied BPMCollectPattern removes the start process from the receiver.
    thank you,
    Pam
    Additional info:
    The first message received starts the process within an infinite loop and activates the correlation "Correlation" by using IDoc message tyoe. Each subsequent message uses this correlation. The messages are received in the container element CollectMessage.In the loop the received messages are attached to the multiline container element CollectMessageList.

    Hi,
    We are also in SP12. So start process is not a problem, because you are getting an Information saying that "start trigger removed" right? It is not an error.
    Are you getting this eror "expression must not return multiline value" after your complete Integration Process desgin ? If So...
    I think you are getting this error in Transformation Step where you are doing N:1 mapping. In this step you are mentioning Interface mapping right? Once you mention Interface Mapping in Transformation step you need to give Source Message Structure as well as Target Message Structure. According to my understanding you are getting error here. You can check these errors, while design time itself. If your entries are showing with Red Border then it is understood that there is an error.
    So if error is here then I think you need to check your N:1 Mapping. In this mapping your Source side Messages should be 0...unbounded. Similarly in Interface Mapping also. Just check for Source Message Occurences...
    I think it will solve your problem.
    Thanks,
    Moorthy

Maybe you are looking for