How to use PowerShell as admin on Hyper.js - powershell

I'm trying to use PowerShell with Hyper.js. I have this on the hyper config file:
shell: 'powershell.exe',
shellArgs: ['']
This way PowerShell is loaded as non-admin, and I receive an error because I don't have a PowerShell profile file configured, but I have a profile for admin user, I want to configure Hyper.js to use PowerShell as admin.

It's not the best solution, but you can run Hyper as admin
https://github.com/zeit/hyper/issues/1752#issuecomment-427086434
There are some other solutions in the linked issue.

Related

Ignore popup windows when executing powershell script Request-Certificate.ps1

In order to request a User ceritificate I'm using the script provided by the Powershell gallery https://www.powershellgallery.com/packages/Request-Certificate/1.5.0/Content/Request-Certificate.ps1
To execute this script I'm using the following command:
. "C:\Certificates\RequestCertificate.ps1" -CN "User Common Name" -TemplateName "User" -CAName "domain\CAserver" -Export
However when I run this command here is the output:
After this output I get a popup message with the following information:
Machine context template conflicts with user context.
If I click ok, the request is concludes successfully. However I'm trying to automate this process. Is there a way to ignore the popup window?
I already looked at the question How to suppress a popup window while using certreq to request a certificate from an enterprise CA? (How to suppress a popup window while using certreq to request a certificate from an enterprise CA?). However the solution for the problem described was to run the script as Admin or System because the certificate generated was for the Machine and not for the User.
Does anyone know why this is happening?
Thank you in advance

How to list all Power Platform solutions using PowerShell or Microsoft Graph API?

I'm looking to for way to get an entire Power Plateform list of solutions. The aim is to export all the solutions with their properties (i.e. Name, id, date of creation, etc).
As you know, solutions can contains, Power Apps application, Power Automate flows, environment variables and so on.
I already know that Power Apps applications (canvas apps) can be retreived by using this command line:
Get-AdminPowerApp
And Flows can be retreived by using this one:
Get-AdminFlow -EnvironmentName "env"
We can found command line to get environements, connections, connectors, etc.
Is there a command line that look like the following one ?
Get-AdminPowerAppsSolution -Environment "env"
Thank you all.
To be able to get solutions with PowerShell an additional PowerShell module is required and can be install by typing the following command-line:
Install-Module Microsoft.Xrm.Data.Powershell
Once the module is installed, a connection to crm online is required :
Connect-CrmOnlineDiscovery -InteractiveMode
The InteractiveMode option prompt a modal to allow the user to enter his credentals. Connection can also be acheived by creating credental manually and then pass it as a parameter:
$creds = Get-Credential
Connect-CrmOnlineDiscovery -Credential $creds
Which prompt a login window as well, but once the credental is set, it can be reused for further calls.
And finally, a lasts commands as follow :
$records = Get-CrmRecords -EntityLogicalName solution
$records.crmRecords
The crmRecords attributes contains all the solution for the selected environment with the following properties :
ReturnProperty_EntityName
solutionid
solutionid_Property
ReturnProperty_Id
EntityReference
original
logicalname
Finding all apps across all environments to which you have admin access can be done with the following command:
Get-AdminPowerApp
More information about this command can be found on Microsoft docs here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powerapps.administration.powershell/get-adminpowerapp?view=pa-ps-latest
You can get PowerApps Solutions by installing the PowerApps CLI.
Look at the Solution export command.
Example:
pac solution export --path c:\Users\Documents\Solution.zip --name SampleComponentSolution --managed true --targetversion 10.0.03 --include general

Powershell script run as administrator from .exe compiled file

I am building a simple Powershell script for AD management.
I need to run as Admin this script from the .exe file (portable between Domain Controllers and/or Enviroments). Any suggest to make the exe file to request the Admin Privileges to the end-user (PopUp shield "can this program modify...")?
Consider using ps2exe - https://github.com/MScholtes/PS2EXE
This can create an exe from a ps1 file and add things like required admin privilege's etc.
ps2exe .\source.ps1 .\target.exe -requireAdmin

How to install programs as admin in Powershell

I started to write a powershell script to automate the deployment of new Windows 10 PCs.
I've done a script to install the corporate apps and mapping the network folders and printers.
But I have a problem that I must input the admin password for each program I wish to install.
I've searched the internet and all I found was the runas command, I see that is similar to the su of Linux but I can't push the password.
This is how I made the install of all applications:
Set-Content "$DESTINO\program.bat" -value 'msiexec -i C:\progtemp\program.msi /quiet'
Start-Process $DESTINO\program.bat -Wait
Do you know a better method?
The two main ways to run something as an admin automated are as follows:
Create a Scheduled task to run a script, you can choose to run this escalated and store the credentials as required
Create a startup script using powershell (or batch file if you must!)
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789190(v=ws.11)
Startup scripts run as the user system which is the highest privilege possible. Be aware that network access may not be available at startup and some things may not be accessible to system on your local network etc.
Highly recommend looking at Chocolatey https://www.chocolatey.org and possibly boxstarter: https://boxstarter.org/
to get you started with some automation and package management.
Microsoft also have a similar technology in early stages:
https://learn.microsoft.com/en-us/windows/package-manager/
But frankly Chocolatey is an open framework and its well established and mature at this stage.

How to automatically open cmd as admin

I'm creating a program for my school project, and it is making calls to some batch files.
Some of the commands will not execute except with admin privileges. How do I resolve this please? Any solution in VBS, VB or batch code will be appreciated, as I'm coding in Visual Basic.
Use this batch code:
runas /user:ADMINUSERNAME BATCHFILE.BAT
ADMINUSERNAME is the administrator account for your computer, and BATCHFILE.BAT is the path to your batch file.