This module represents a set of tools for Powershell that I find useful to have available in every Powershell console. It was started as a helper project for some daily work activities and polished over the years as an internal project. Some recent commands rely on Powershell 7 syntax, so the module is marked for Powershell 7, although most of the commands actually should work in older Powershell versions.
You are welcome to use and contribute.
Installation
To make the module auto-discoverable by Powershell, clone it into your Powershell Modules folder without changing it's name:
I am trying to setup kiosk mode using powershell with ps tools. But during setting the cim instance, 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 $classNameif ($obj-ne$null) {
Write-Host"CIM instance retrieved successfully."# Debug: Output the current configurationWrite-Host"Current Configuration: $($obj.Configuration)"# Update the configuration$obj.Configuration= [System.Net.WebUtility]::HtmlEncode($assignedAccessConfiguration)
# Apply the changes using Set-CimInstanceSet-CimInstance-CimInstance $objWrite-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