D danielbal New Member Jul 14, 2017 #1 Dear B4J experts, I'm new to B4J and with programming so pls be patient with me I would like to use jShell with powershell to list all windows (10) default installed apps packages. I need to capture the ouput of the following powershell command: Get -AppxPackage -AllUsers | Where-Object {$._PackageUserInformation -ilike "*Installed*"} select -Property Name Log of the StdOut from the shell processCompleted procedure is empty (running other poweshell command such as "ls" do provides output, and I think the issue is that this command needs Administrator rights. Is there a way to accomplish this? If yes, an example would be highly appreciated. Thanks, Danny.
Dear B4J experts, I'm new to B4J and with programming so pls be patient with me I would like to use jShell with powershell to list all windows (10) default installed apps packages. I need to capture the ouput of the following powershell command: Get -AppxPackage -AllUsers | Where-Object {$._PackageUserInformation -ilike "*Installed*"} select -Property Name Log of the StdOut from the shell processCompleted procedure is empty (running other poweshell command such as "ls" do provides output, and I think the issue is that this command needs Administrator rights. Is there a way to accomplish this? If yes, an example would be highly appreciated. Thanks, Danny.
D danielbal New Member Jul 14, 2017 #2 Appologize, the correct syntax for the powershell script is: Get-AppxPackage -AllUsers | Where-Object {$_.PackageUserInformation -ilike "*Installed*"} | select -Property Name Though the issue still the same. Danny. Upvote 0
Appologize, the correct syntax for the powershell script is: Get-AppxPackage -AllUsers | Where-Object {$_.PackageUserInformation -ilike "*Installed*"} | select -Property Name Though the issue still the same. Danny.
NJDude Expert Licensed User Longtime User Jul 14, 2017 #3 If you are running that from the command line you need to open the PowerShell console with admin rights otherwise you have to check and elevate the user on your script. One more thing, the PackageUserInformation will be most certainly blank, so, to get all the packages you only need: Code: Copy Get-AppxPackage -AllUsers | Select-Object -Property Name But, you can also use the code below, that will give you what you are looking for (if the PackageInfo is not blank): Code: Copy Get-AppxPackage -AllUsers | Select-Object Name, PackageUserInformation | Where-Object {$_.PackageUserInformation -like "*Installed"} Last edited: Jul 15, 2017 Upvote 0
If you are running that from the command line you need to open the PowerShell console with admin rights otherwise you have to check and elevate the user on your script. One more thing, the PackageUserInformation will be most certainly blank, so, to get all the packages you only need: Code: Copy Get-AppxPackage -AllUsers | Select-Object -Property Name But, you can also use the code below, that will give you what you are looking for (if the PackageInfo is not blank): Code: Copy Get-AppxPackage -AllUsers | Select-Object Name, PackageUserInformation | Where-Object {$_.PackageUserInformation -like "*Installed"}
D danielbal New Member Jul 14, 2017 #4 Thanks NJ. My goal was to run a PS command with Jshell (not from windows command line or PS Admin console) and retrive its output to a string variable. I was trying to avoid the need to request for username and password, but I guess it can't be done. Danny. Upvote 0
Thanks NJ. My goal was to run a PS command with Jshell (not from windows command line or PS Admin console) and retrive its output to a string variable. I was trying to avoid the need to request for username and password, but I guess it can't be done. Danny.
NJDude Expert Licensed User Longtime User Jul 15, 2017 #5 Try this: 1- Save your code as a script (e.g. App.ps1 in C:\Temp for example). 2-Run the following command from JShell. Code: Copy C:\WINDOWS\system32\RunAs.exe /SaveCred /User:Administrator "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command & {C:\Temp\App.ps1}" That will prompt you for the Administrator password only once (it will save the credentials). Upvote 0
Try this: 1- Save your code as a script (e.g. App.ps1 in C:\Temp for example). 2-Run the following command from JShell. Code: Copy C:\WINDOWS\system32\RunAs.exe /SaveCred /User:Administrator "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command & {C:\Temp\App.ps1}" That will prompt you for the Administrator password only once (it will save the credentials).