I would like to create a program in VB.NET that executes the following code in PowerShell
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
I created a .ps1 file with this code above and put it this way in VS:
Shell("powershell -noexit Start-Process powershell -Verb runAs ""C:\Users\netov\Desktop\teste.ps1""", AppWinStyle.NormalFocus, True)
It runs, calls the PS as an administrator, but gives the error that scripting has been disabled on this system and tells me to check about_Execution_Policies
I searched and saw that if I run this command Set-ExecutionPolicy Unrestricted
in PS it allows me (after typing 'S', for yes) execute scripts.
The problem is that I can not run this code through VS. I tried adding it to test.ps1 and it also does not execute.
Has anyone gone through this, or has another way to solve it? I just want to run this PowerShell command in a simple way (for ordinary users) in order to solve the problem of starting Windows to work in some moments.