Assinged Access & Shell Launcher not working

Sayantan Basu 0 Reputation points
2024-07-02T12:25:19.89+00:00

Hello,

I am trying to set up kiosk mode using Assigned Access using psexec tool.  psexec.exe -i -s powershell.exe. However I keep getting the following error:

Set-CimInstance : A general error occurred that is not covered by a more specific error code.
At C:\Users\Atonarp\Desktop\acm-sw-installation-script\automation-scripts\setup_kiosk_mode.ps1:43 char:9
+ Set-CimInstance -CimInstance $obj
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MDM_AssignedAcc..../Vendor/MSFT"):CimInstance) [Set-CimInstance], CimExce
ption
+ FullyQualifiedErrorId : MI RESULT 1,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand

My ps1 script:

# Check for administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
  Write-Host "This script requires administrator privileges. Please run as administrator." -ForegroundColor Red
  exit $LASTEXITCODE
}

# Please run this command from an elevated command prompt "psexec.exe -i -s cmd.exe"
# This will open another shell, then run this file in it.

# Set up the kiosk mode configuration for Edge
$assignedAccessConfiguration = @"
<?xml version="1.0" encoding="utf-8"?>
<AssignedAccessConfiguration xmlns="http://schemas.microsoft.com/AssignedAccess/2017/config" xmlns:rs5="http://schemas.microsoft.com/AssignedAccess/201810/config" xmlns:v4="http://schemas.microsoft.com/AssignedAccess/2021/config">
  <Profiles>
    <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}">
      <KioskModeApp v4:ClassicAppPath="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" v4:ClassicAppArguments="-ExecutionPolicy Bypass -File %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\acm_start.lnk" />
      <v4:AllowedApps>
        <v4:AllowedApp v4:ClassicAppPath="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" v4:ClassicAppArgumemts="--kiosk http://localhost:3000/ --edge-kiosk-type=fullscreen" />
      </v4:AllowedApps>
      <v4:BreakoutSequence Key="Ctrl+A" />
    </Profile>
  </Profiles>
  <Configs>
    <Config>
      <AutoLogonAccount rs5:DisplayName="ACM_SW" />
      <DefaultProfile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}" />
    </Config>
  </Configs>
</AssignedAccessConfiguration>
"@

# Set the Assigned Access Configuration
$namespaceName = "root\cimv2\mdm\dmmap"
$className = "MDM_AssignedAccess"
$obj = Get-CimInstance -Namespace $namespaceName -ClassName $className

$obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAccessConfiguration)
Set-CimInstance -CimInstance $obj

Window Specification

Windows specification: Edition Windows 11 Enterprise Version 23H2

Installed on ‎29-‎06-‎2024

OS build 22631.3737

Experience Windows Feature Experience Pack 1000.22700.1009.0

PS:

So my question is:

Is my initial configuration is correct?

What am I trying to do: I am trying to setup kiosk mode via a script such that

  1. it will run another script in powershell which points to git bash script and wait for it to complete (for example npm run dev in git bash)
  2. Once that script finishes, then it will launch the edge browser with localhost:3000 to show the webapp and run it in kiosk mode.

Any help will be appreciated. Do forgive me if the post is not under the right topic

I am facing the same issue for shell launcher as well

Hello,

I am attempting to use the powershell WMI bridge provider and the provided xml script.

I keep getting error:


Set-CimInstance : A general error occurred that is not covered by a more specific error code.

At C:\Users\SomashekarChandrappa\Downloads\acm-sw\acm-sw-installation-script-sayantan_acm-automation-scripts\automation

-scripts\shell_laucnher.ps1:47 char:9

+         Set-CimInstance -CimInstance $obj

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (MDM_AssignedAcc..../Vendor/MSFT"):CimInstance) [Set-CimInstance], CimExce

   ption

    + FullyQualifiedErrorId : MI RESULT 1,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand

My code:


if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {

    Write-Host "This script requires administrator privileges. Please run as administrator." -ForegroundColor Red

    exit $LASTEXITCODE

}

$assignedAccessConfiguration = @"

<?xml version="1.0" encoding="utf-8"?>

<ShellLauncherConfiguration xmlns="http://schemas.microsoft.com/embedded/2011/08/shelllauncher" 

xmlns:cmd="http://schemas.microsoft.com/embedded/2013/10/shelllauncher">

  <Profiles>

    <Profile Name="ACM Kiosk Profile" Description="ACM Software Kiosk Profile">

      <LaunchAction Type="DefaultApp">

        <App User="AutoLogonUser" Path="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"

             Args="-ExecutionPolicy Bypass -File %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\acm_start.lnk" />

        <App User="AutoLogonUser" Path="%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe"

             Args="--kiosk http://localhost:3000/ --edge-kiosk-type=fullscreen" />

        <App User="AutoLogonUser" Path="cmd.exe" Args="/c echo Breakout key sequence: Ctrl+A" />

      </LaunchAction>

    </Profile>

  </Profiles>

  <AutoLogonAccount DisplayName="ACM_SW" />

  <DefaultProfile Name="ACM Kiosk Profile" />

</ShellLauncherConfiguration>

"@

# Set the Assigned Access Configuration

$namespaceName = "root\cimv2\mdm\dmmap"

$className = "MDM_AssignedAccess"

try {

    Write-Host "Getting the CIM instance."

    # Get the CIM instance

    $obj = Get-CimInstance -Namespace $namespaceName -ClassName $className

    if ($obj -ne $null) {

        Write-Host "CIM instance retrieved successfully."

        # Debug: Output the current configuration

        Write-Host "Current Configuration: $($obj.Configuration)"

        # Update the configuration

        $obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAccessConfiguration)

        # Apply the changes using Set-CimInstance

        Set-CimInstance -CimInstance $obj 

        Write-Output "CIM instance updated successfully."

    } else {

        Write-Host "No instance of class $className found."

    }

} catch {

    Write-Host "Error setting CIM instance: $_"

}

Windows specification:

Edition Windows 11 Enterprise

Version 23H2

Installed on ‎29-‎06-‎2024

OS build 22631.3737

Experience Windows Feature Experience Pack 1000.22700.1009.0

Can someone point me what is going wrong?

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,847 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.