namespace powershell_execution
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
// function to create and execute an application to remove Microsoft.Calculator UWP app
public void executeRemoval(object sender, RoutedEventArgs ex)
{
string appName = tbInput.Text.ToString();
string command = $"Get-AppxPackage {appName} | Remove-AppxPackage";
PowerShell.Create().AddScript(command).Invoke();
// this command does not remove anything. I have admin access in my app manifest. "Start-Process notepad" as a command works fine.
tbOutput.Text = command;
}
}
}
Why would "Start-Process notepad" invoke, but "Get-appxpackage name | Remove-appxpackage" or similar commands do not invoke?