Set-ADTItemPermission doesn't seem to be imported

Hello everyone,

I’m having some trouble with “Set-ADTItemPermission” v4.0.4.
I’m starting the script within VSCode 1.96.2 btw and have the folder structure as mentioned on the psadt website.

The particular function/cmdlet doesn’t seem to be recognized, as it drops the following error message.

C:\temp\2024.2.1.0 - 4.0.4\Invoke-AppDeployToolkit.ps1: The name "Set-ADTItemPermission" was not recognized as the name of a cmdlet, function, script file, or executable program. 
Check the spelling of the name or whether the path is correct (if included) and repeat the process

Here my line of code:

Set-ADTItemPermission -Path "$envProgramFilesX86\<AppVendor>" -User "$adtSession.user" -Permission "FullControl" -Inheritance "ObjectInherit,ContainerInherit" -Propagation "None" -PermissionType "Allow"

$adtSession.user is defined in the variable section as ‘<Groupname>’

I run the script via “Run” → “Run w/out debugging”

As I run Invoke-AppDeployToolkit.exe from PS I get: An error occurred while running Invoke-AppDeployToolkit.ps1. Exit Code 60008

This might be another cause:

Start-ADTProcess -FilePath 'vc_redist.x64.exe' -ArgumentList '/install /passive /norestart' -WindowStyle Hidden -ErrorAction Stop -IgnoreExitCodes '1638'

I’m rather new to PSADT and of course v4 as we all are :slight_smile:

I hope some of you has an idea what might be wrong

Greetings
S1mon

That doesn’t look like a valid path to me…
That line will be looking for the folder path:
C:\Program Files (x86)\<AppVendor>
I suspect you need to correct the path in your script

Hi Adrian,

I’m using one of the predefined variables from PSADT as it is listed in the variable table.
But I can give it a try.

Thanks

Nope, doesn’t make a difference.

Set-ADTItemPermisson itself drops the error again

I think you should review the reference page: Set-ADTItemPermission · PSAppDeployToolkit

1 Like

I’ve not yet got into the newness that is v4 of PSADT so well done for being a trail blazer :grin:

I’ve had a quick read of the ADTSession reference, and realised where your confusion may have come from, the content in the triangular brackets are placeholders for you to replace.

So, Your command line:

Set-ADTItemPermission -Path "$envProgramFilesX86\<AppVendor>" -User "$adtSession.user" -Permission "FullControl" -Inheritance "ObjectInherit,ContainerInherit" -Propagation "None" -PermissionType "Allow"

should ‘probably’ look like this:

Set-ADTItemPermission -Path "$envProgramFilesX86\$($adtSession.AppVendor)" -User "$adtSession.user" -Permission "FullControl" -Inheritance "ObjectInherit,ContainerInherit" -Propagation "None" -PermissionType "Allow"

But as I have not tested this I can not confirm exactly.

However… As the error you are seeing is:

C:\temp\2024.2.1.0 - 4.0.4\Invoke-AppDeployToolkit.ps1: The name "Set-ADTItemPermission" was not recognized as the name of a cmdlet, function, script file, or executable program. 
Check the spelling of the name or whether the path is correct (if included) and repeat the process

I suspect either the Toolkit is not in the correct Deployment structure (You can check it looks like this: Deployment Structure · PSAppDeployToolkit) or it is not being dot sourced correctly (so can not find the Set-ADTPermission function), Assuming this is not some obscure new bug you have discovered, this should be handled correctly if you created the deployment using the Creating a new deployment · PSAppDeployToolkit instructions.

Beyond this I’m unsure so I’ll leave one of the PSADT v4 ‘experts’ to chip in further if needs be

Thanks for your input so far Adrian.

I noticed a slightly clumsy obfuscation on my side <AppVendor> wasn’t meant to be actual code :slight_smile:

For the rest of your tipps, I’ll check them.

I double-checked my template against the github version and discovered that I deleted maybe a little too much from the folder.

Although I find it a little strange, that inside the template folder is another PSAppDeployToolkit folder with almost the same content as in the parent folder. Am I misunderstanding here something wrong or is it a bug?

After all, it is something new and I have to figure it out, as most of us will do, I presume.

best regards
S1mon

:joy: Don’t worry, it happens
side note here: Beyond Compare or to a lesser extent WinMerge are great tools for comparing files and folders

Let me explain…
As I saw:

So I’m not sure how much of a background you have with using earlier versions of PSADT, but as v4 is a whole lot different to v3 you may need to understand how it works before using previously learned knowledge.

Had you previously been a v3 user, there are now some initial steps that you will need to carry out in order to use v4 ‘properly’
First things first (from what I understand myself) v4 should not be copied around in the same way v3 used to be copied and tweaked, mainly because it is a code signed installable module (to be installed on your ‘packaging’ workstation), once the latest version (“4.0.4” at time of writing) module is installed, you then run something along the lines of New-ADTTemplate -Destination <path> -Name <name-of-deployment> - See the Creating a new deployment · PSAppDeployToolkit, This will then create a (Native V4 Deployment Template) with the deployment structure as shown here:
Deployment Structure · PSAppDeployToolkit
It is within this templated folder structure that you modify only certain files (this folder structure will form the basis of your packaged application, with the installer ‘usually’ placed within the Files sub-folder)

N.B. Take a note of the files and folders it advises not to modify within the deployment structure as this should guide how to work with PSADT v4.0.x (Although not recommended, These ‘can’ be modified, but you have to accept that the code is no longer originally signed by PatchMyPC and either needs the ExecutionPolicy to be set to Bypass in Powershell (weakening security) or will require you to re-sign it with your own code signing cert)

Once you have an understanding of the basics (from the Docs), the Reference should help you understand it much further, i.e. the nuts and bolts of PSADT.

Good luck!

Just to be super clear, deleting anything from the PSAppDeployToolkit folder is completely unsupported by us. Please leave the module directory completely intact.

The module needs to be able to stand on its own, it’s folders are not optional. However the duplicated config and strings folders shipped with the template are. If you’re not customising anything and saving 50KB is worth it to you, you can delete those folders from the template root but not the PSAppDeployToolkit directory.

Thanks for the stellar help and assistance :fist_right::fist_left:

1 Like