i have tried the below way to execute the commands in administrator mode.
-
'PS>start-process powershell -verb runas $app = Get-AppxPackage -all| Where-Object{$_.Name-like "$ReleaseName"} '
'PS>start-process powershell -verb runas Remove-AppxPackage $app.PackageFullName '
- for the first call, it opens and executes the command successfully and closes the admin powershell instance. for the second call it requires $app information which is not available because it again opens a new PS admin window
- i can't execute "Get-AppxPackage -all" in normal mode "-all" requires admin mode only
-
' PS>start-process powershell -verb runas {
$app = Get-AppxPackage | Where-Object{$_.Name-like "$ReleaseName"};
Remove-AppxPackage $app.PackageFullName
}'
tried this way but no luck.
can someone suggest me how to execute set of instructions like above in powershell elevated mode?
thanks in advance